{
  "info": {
    "name": "Address Management API",
    "description": "CRUD operations for user addresses with default address functionality",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "LOCAL_URL",
      "value": "http://localhost:3000/api/v1",
      "type": "string"
    },
    {
      "key": "authtoken",
      "value": "your_auth_token_here",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Create Address",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "authtoken",
            "value": "{{authtoken}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"title\": \"Home\",\n  \"address\": \"123 Main Street, City, State, ZIP\",\n  \"lng\": -74.006,\n  \"lat\": 40.7128,\n  \"isDefault\": true\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{LOCAL_URL}}/address",
          "host": [
            "{{LOCAL_URL}}"
          ],
          "path": [
            "address"
          ]
        },
        "description": "Create a new address for the authenticated user. If isDefault is true, it will unset any existing default address."
      }
    },
    {
      "name": "Get All Addresses",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "authtoken",
            "value": "{{authtoken}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{LOCAL_URL}}/address?page=1&limit=10",
          "host": [
            "{{LOCAL_URL}}"
          ],
          "path": [
            "address"
          ],
          "query": [
            {
              "key": "page",
              "value": "1",
              "description": "Page number for pagination"
            },
            {
              "key": "limit",
              "value": "10",
              "description": "Number of addresses per page"
            }
          ]
        },
        "description": "Get all addresses for the authenticated user with pagination. Addresses are sorted by default status and creation date."
      }
    },
    {
      "name": "Get Address by ID",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "authtoken",
            "value": "{{authtoken}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{LOCAL_URL}}/address/{{addressId}}",
          "host": [
            "{{LOCAL_URL}}"
          ],
          "path": [
            "address",
            "{{addressId}}"
          ]
        },
        "description": "Get a specific address by its ID. Only the owner can access their address."
      }
    },
    {
      "name": "Update Address",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "authtoken",
            "value": "{{authtoken}}",
            "type": "text"
          },
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"title\": \"Updated Home Address\",\n  \"address\": \"456 Updated Street, New City, State, ZIP\",\n  \"lng\": -73.935242,\n  \"lat\": 40.730610,\n  \"isDefault\": false\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{LOCAL_URL}}/address/{{addressId}}",
          "host": [
            "{{LOCAL_URL}}"
          ],
          "path": [
            "address",
            "{{addressId}}"
          ]
        },
        "description": "Update an existing address. All fields are optional. If isDefault is set to true, other addresses will be unset as default."
      }
    },
    {
      "name": "Delete Address",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "authtoken",
            "value": "{{authtoken}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{LOCAL_URL}}/address/{{addressId}}",
          "host": [
            "{{LOCAL_URL}}"
          ],
          "path": [
            "address",
            "{{addressId}}"
          ]
        },
        "description": "Soft delete an address by marking it as deleted. The address will no longer appear in listings."
      }
    },
    {
      "name": "Set Default Address",
      "request": {
        "method": "PATCH",
        "header": [
          {
            "key": "authtoken",
            "value": "{{authtoken}}",
            "type": "text"
          }
        ],
        "url": {
          "raw": "{{LOCAL_URL}}/address/{{addressId}}/default",
          "host": [
            "{{LOCAL_URL}}"
          ],
          "path": [
            "address",
            "{{addressId}}",
            "default"
          ]
        },
        "description": "Set a specific address as the default address. This will unset any other default address for the user."
      }
    }
  ]
}