Tổng đài hỗ trợ - 
1900 6750
( 7:00 - 22:00 )

CustomerAddress

Một customer address là tài nguyên đại diện cho một trong nhiều địa chỉ mà khách hàng có thể có

Muốn biết thêm thông tin về tài nguyên Customers, hãy xem tài liệu API về Customer

Bạn có thể làm gì với CustomerAddress?

Sapo API cho phép bạn thực hiện các thao tác sau với tài nguyên CustomerAddress. Các phiên bản chi tiết hơn của những thao tác này có thể có:

Các thuộc tính của CustomerAddress

address1
{ "address1" : "1 Rue des Carrieres" }
address2
{ "address2" : "Suite 1234" }
city
{ "city" : "Montreal" }
company
{ "company" : "Fancy Co." }

Tên công ty (tùy chọn)

first_name
{ "first_name" : "Samuel" }
last_name
{ "last_name" : "de Champlain" }
phone
{ "phone" : "819-555-5555" }
province
{ "province" : "Quebec" }
country
{ "country" : "Canada" }
zip
{ "zip" : "G1R 4P5" }
name
{ "name" : "Samuel de Champlain" }
province_code
{ "province_code" : "QC" }
country_code
{ "country_code" : "CA" }

Mã quốc gia theo định dạng ISO 3166-1 (alpha-3). Xem danh sách mã quốc gia theo định dạng ISO hiện tại

country_name
{ "country_name" : "Canada" }

Endpoints

GET/admin/customers/207119551/addresses.json

Lấy ra tất cả địa chỉ của khách hàng

limit

Số lượng kết quả trả về

(mặc định: 50) (tối đa: 250)
page

Số trang

(mặc định: 1)

Lấy một số địa chỉ của khách hàng

GET /admin/customers/#{id}/addresses.json?limit=1&page=1
Xem kết quả
HTTP/1.1 200 OK
{
  "addresses": [
    {
      "id": 207119551,
      "first_name": null,
      "last_name": null,
      "company": null,
      "address1": "Chestnut Street 92",
      "address2": "",
      "city": "Louisville",
      "province": "Kentucky",
      "country": "United States",
      "zip": "40202",
      "phone": "555-625-1199",
      "name": "",
      "province_code": "KY",
      "country_code": "US",
      "country_name": "United States",
      "default": true
    }
  ]
}

Get all of a customers addresses

GET /admin/customers/#{id}/addresses.json
Xem kết quả
HTTP/1.1 200 OK
{
  "addresses": [
    {
      "id": 207119551,
      "first_name": null,
      "last_name": null,
      "company": null,
      "address1": "Chestnut Street 92",
      "address2": "",
      "city": "Louisville",
      "province": "Kentucky",
      "country": "United States",
      "zip": "40202",
      "phone": "555-625-1199",
      "name": "",
      "province_code": "KY",
      "country_code": "US",
      "country_name": "United States",
      "default": true
    }
  ]
}
GET/admin/customers/207119551/addresses/207119551.json

Lấy thông tin chi tiết của một địa chỉ của khách hàng

Lấy một địa chỉ khách hàng

GET /admin/customers/#{id}/addresses/#{id}.json
Xem kết quả
HTTP/1.1 200 OK
{
  "customer_address": {
    "id": 207119551,
    "first_name": null,
    "last_name": null,
    "company": null,
    "address1": "Chestnut Street 92",
    "address2": "",
    "city": "Louisville",
    "province": "Kentucky",
    "country": "United States",
    "zip": "40202",
    "phone": "555-625-1199",
    "name": "",
    "province_code": "KY",
    "country_code": "US",
    "country_name": "United States",
    "default": true
  }
}
POST/admin/customers/207119551/addresses.json

Tạo mới một địa chỉ cho khách hàng

Tạo mới địa chỉ cho khách hàng

POST /admin/customers/#{id}/addresses.json
{
  "address": {
    "address1": "1 Rue des Carrieres",
    "address2": "Suite 1234",
    "city": "Montreal",
    "company": "Fancy Co.",
    "first_name": "Samuel",
    "last_name": "de Champlain",
    "phone": "819-555-5555",
    "province": "Quebec",
    "country": "Canada",
    "zip": "G1R 4P5",
    "name": "Samuel de Champlain",
    "province_code": "QC",
    "country_code": "CA",
    "country_name": "Canada"
  }
}
Xem kết quả
HTTP/1.1 201 Created
{
  "customer_address": {
    "id": 1053317298,
    "first_name": "Samuel",
    "last_name": "de Champlain",
    "company": "Fancy Co.",
    "address1": "1 Rue des Carrieres",
    "address2": "Suite 1234",
    "city": "Montreal",
    "province": "Quebec",
    "country": "Canada",
    "zip": "G1R 4P5",
    "phone": "819-555-5555",
    "name": "Samuel de Champlain",
    "province_code": "QC",
    "country_code": "CA",
    "country_name": "Canada",
    "default": false
  }
}
PUT/admin/customers/207119551/addresses/207119551.json

Cập nhật các thông tin của địa chỉ khách hàng

Cập nhật mã bưu điện

PUT /admin/customers/#{id}/addresses/#{id}.json
{
  "address": {
    "id": 207119551,
    "zip": "H0H 0H0"
  }
}
Xem kết quả
HTTP/1.1 200 OK
{
  "customer_address": {
    "id": 207119551,
    "first_name": null,
    "last_name": null,
    "company": null,
    "address1": "Chestnut Street 92",
    "address2": "",
    "city": "Louisville",
    "province": "Kentucky",
    "country": "United States",
    "zip": "H0H 0H0",
    "phone": "555-625-1199",
    "name": "",
    "province_code": "KY",
    "country_code": "US",
    "country_name": "United States",
    "default": true
  }
}
DELETE/admin/customers/207119551/addresses/207119551.json

Xóa một địa chỉ khỏi danh sách địa chỉ của khách hàng

Cố gắng xóa địa chỉ mặc định của khách hàng sẽ trả về kết quả lỗi

DELETE /admin/customers/#{id}/addresses/#{id}.json
Xem kết quả
HTTP/1.1 422 Unprocessable Entity
{
  "data_error": {
    "status": 422,
    "errors": {
      "default_address": "Default address cannot be deleted."
    }
  }
}

Xóa một địa chỉ của khách hàng

DELETE /admin/customers/#{id}/addresses/#{id}.json
Xem kết quả
HTTP/1.1 200 OK
{}
PUT/admin/customers/207119551/addresses/1053317297/default.json

Gán địa chỉ mặc định mới cho khách hàng

PUT /admin/customers/#{id}/addresses/#{id}/default.json
Xem kết quả
HTTP/1.1 200 OK
{
  "customer_address": {
    "id": 1053317297,
    "first_name": "Bob",
    "last_name": "Norman",
    "company": null,
    "address1": "Chestnut Street 92",
    "address2": "",
    "city": "Louisville",
    "province": "Kentucky",
    "country": "United States",
    "zip": "40202",
    "phone": "555-625-1199",
    "name": "Bob Norman",
    "province_code": "KY",
    "country_code": "US",
    "country_name": "United States",
    "default": true
  }
}

Bài viết trên có hữu ích cho bạn không?

Hữu ích Không hữu ích
Số lượt đánh giá hữu ích: