Methods for getting Address data for a customer from the Store API.
GET
/v1/store/api/customer/addresses/
GET
/v1/store/api/customer/addresses/{address_id}/
PUT
/v1/store/api/customer/addresses/{address_id}/
POST
/v1/store/api/customer/addresses/
Get all customer addresses
$.get('/v1/store/api/customer/addresses/');
{
"count": 1,
"next": null,
"prev": null,
"results": [{
"city": "austin",
"company": "",
"country": "US",
"id": 39161778,
"phone_number": "",
"state": "TX",
"status": 2,
"status_message": "Address Not Found. ",
"street": "352135 Solid Ln.",
"to": "Blake Messer",
"type": "address",
"unit": "",
"url": "/v1/store/api/customer/addresses/39161778/",
"zip_code": "78704"
}]
}
Get an address
GET
/v1/store/api/addresses/
$.get('/v1/store/api/addresses/39161778/');
{
"city": "austin",
"company": "",
"country": "US",
"id": 39161778,
"phone_number": "",
"state": "TX",
"status": 2,
"status_message": "Address Not Found. ",
"street": "352135 Solid Ln.",
"to": "Blake Messer",
"type": "address",
"unit": "",
"url": "/v1/store/api/customer/addresses/39161778/",
"zip_code": "78704"
}
Update and Address
PUT
/v1/store/api/customer/addresses/{address_id}/
Addresses are immutable. When you make a PUT request to change address id 1, note that the response will be the data of the old address + your changes with the a new id (2). Address 1 will be deleted in the database and no longer accessible via the API.
$.ajax({
type: 'PUT',
url: '/v1/store/api/customer/addresses/1/',
dataType: 'json',
contentType: "application/json;",
data: JSON.stringify({'to': 'New Person', 'street': '123 New St'})
})
{
city: "Austin"
company: ""
country: "US"
deleted_at: null
icon: "United-States.png"
id: 2
phone_number: ""
state: "TX"
status: 0
status_message: null
street: "123 New St"
to: "New Person"
type: "address"
unit: "30"
zip_code: "78701"
}
$.ajax({
type: 'POST',
url: '/v1/store/api/customer/addresses/',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify({
'to': 'New Person',
'street': '123 New St',
'city': 'Austin',
'state': 'TX',
'zip_code': '012345',
'country': 'US'
})
});
{
city: "Austin"
company: null
country: "US"
deleted_at: null
icon: "United-States.png"
id: 3
phone_number: null
state: "TX"
status: 0
status_message: null
street: "123 New St"
to: "New Person"
type: "address"
unit: null
zip_code: "012345"
}
$.ajax({
type: 'DELETE',
url: '/v1/store/api/customer/addresses/3/',
});
A DELETE will return the address object with the timestamp it was deleted in the deleted_at column
{
city: "Austin"
company: null
country: "US"
deleted_at: "Fri, 15 Jan 2016 23:30:45 GMT"
icon: "United-States.png"
id: 3
phone_number: null
state: "TX"
status: 0
status_message: null
street: "123 New St"
to: "New Person"
type: "address"
unit: null
zip_code: "012345"
}