Skip to content

/client/addresses

Path: /client/addresses
Namespace: client
Resource: addresses

Overview

The Address resource in the client namespace provides customers with self-service access to their address information and contact details.

Key Difference from Admin: Client namespace provides customer self-service access, typically limited to the customer's own address.

Relationships

See Admin Addresses for complete relationship documentation. Client addresses use the same Address model with customer self-service access.

Available Operations

List Addresses (GET)

Endpoint: GET /client/addresses.json

Query Parameters:

  • q[field_predicate]=value - Ransack query filters for advanced filtering
  • page=N - Page number for pagination
  • per_page=N - Items per page (default: 25)

Request Examples:

bash
curl -X GET "https://your-company.erpax.com/client/addresses.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/client/addresses.json', {
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});
const data = await response.json();

Response (200 OK):

json
{
  "addresses": [
    {
      "id": 1,
      "code": "CUST-001",
      "name": "John Doe",
      "company": "Acme Corp",
      "email": "[email protected]",
      "phone": "+1-555-0123",
      "address1": "123 Main St",
      "city": "New York",
      "country_code": "US",
      "currency_code": "USD",
      "created_at": "2024-01-10T10:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total_pages": 1,
    "total_count": 1
  }
}

Show Address (GET /:id)

Endpoint: GET /client/addresses/:id.json

Request Example:

bash
curl -X GET "https://your-company.erpax.com/client/addresses/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/client/addresses/1.json', {
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});
const data = await response.json();

Response (200 OK):

json
{
  "address": {
    "id": 1,
    "code": "CUST-001",
    "name": "John Doe",
    "company": "Acme Corp",
    "email": "[email protected]",
    "phone": "+1-555-0123",
    "address1": "123 Main St",
    "city": "New York",
    "postal_code": "10001",
    "country_code": "US",
    "currency_code": "USD",
    "created_at": "2024-01-10T10:00:00Z",
    "updated_at": "2024-01-15T12:00:00Z"
  }
}

Create Address (POST)

Endpoint: POST /client/addresses.json

Request Example:

bash
curl -X POST "https://your-company.erpax.com/client/addresses.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "address": {
      "code": "CUST-002",
      "name": "Jane Smith",
      "company": "Tech Solutions Inc",
      "email": "[email protected]",
      "phone": "+1-555-0456",
      "address1": "456 Oak Ave",
      "city": "San Francisco",
      "postal_code": "94102",
      "country_code": "US",
      "currency_code": "USD"
    }
  }'

JavaScript Example:

javascript
const response = await fetch('/client/addresses.json', {
  method: 'POST',
  credentials: 'include',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    address: {
      code: 'CUST-002',
      name: 'Jane Smith',
      company: 'Tech Solutions Inc',
      email: '[email protected]',
      phone: '+1-555-0456',
      address1: '456 Oak Ave',
      city: 'San Francisco',
      postal_code: '94102',
      country_code: 'US',
      currency_code: 'USD'
    }
  })
});
const data = await response.json();

Response (201 Created):

json
{
  "address": {
    "id": 2,
    "code": "CUST-002",
    "name": "Jane Smith",
    "company": "Tech Solutions Inc",
    "email": "[email protected]",
    "created_at": "2024-01-15T14:30:00Z"
  }
}

Update Address (PATCH /:id)

Endpoint: PATCH /client/addresses/:id.json

Request Example:

bash
curl -X PATCH "https://your-company.erpax.com/client/addresses/1.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "address": {
      "email": "[email protected]",
      "phone": "+1-555-9999"
    }
  }'

JavaScript Example:

javascript
const response = await fetch('/client/addresses/1.json', {
  method: 'PATCH',
  credentials: 'include',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    address: {
      email: '[email protected]',
      phone: '+1-555-9999'
    }
  })
});
const data = await response.json();

Response (200 OK):

json
{
  "address": {
    "id": 1,
    "email": "[email protected]",
    "phone": "+1-555-9999",
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Delete Address (DELETE /:id)

Endpoint: DELETE /client/addresses/:id.json

Request Example:

bash
curl -X DELETE "https://your-company.erpax.com/client/addresses/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/client/addresses/1.json', {
  method: 'DELETE',
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});

Response (204 No Content):

(empty response)

Scopes

See Admin Addresses for complete scope documentation. Client namespace supports the same scopes, but filtered to the current user's addresses.

Filters

See Admin Addresses for complete filter documentation. Client namespace supports the same filters, but filtered to the current user's addresses.

Business Rules

  • Customer Self-Service: Customers can only access their own addresses
  • Same Business Rules: Follows the same business rules as admin namespace addresses

Released under an open source license.