/customer/address

Customer’s personal actions that don’t directly relate to account management, like address management.

/customer/address/get

Returns customer’s addresses.

Request

POST nameValueRequired?
session_idintegerYes

See Session Management.

If there is no addresses for user, an error array is returned instead. If latitude and longitude is not set for this address, they are not present in the response.

Response

Response data is array of objects:

[
  {
    "id": 42,
    "name": "(Optional) name of the address",
    "address": "Funny Address 1",
    "postal_code": "01234",
    "city": "TestCity",
    "latitude": 60.403415,
    "longitude": 25.104618,
    "preferred_address": false
  },
  { "more addresses" }
]

preferred_address

Customer may set an address as preferred address. This address can be then shown as first choice in lists, where customer can choose an address that will be preferred over others (favorite address).

In case there is no preferred address, last one should be chosen, as that’s latest address of customer.

Expectable errors

See error conventions section for explanation how error system works.

Label Additional data Description
NO_ADDRESSESNoneThere is no addresses for customer. Maybe ask customer if she wants to insert new address?

/customer/address/set

Sets an address for user.

Request

POST name Value Maximum length Required?
name "Funny Name" 50 No
address "Funny address 1" 150 Yes
postal_code "01234" 5 No
city "TestCity" 100 Yes
latitude "60.403415" 9, 6 decimals No
longitude "25.104618" 9, 6 decimals No
preferred_address "true" boolean No

See Session Management. session_id is required for this action to work.

Response

In case address is invalid or user has not logged in, an error will be returned.

ResponseJSON
Success:"success"
Failure:error array

Expectable errors

See error conventions section for explanation how error system works.

Label Additional data Description
NOT_UNIQUE_ADDRESSNoneReturned if the address that is tried to be saved is already saved for the user.
INVALID_POSTAL_CODENoneMalformed postal code. Customer don’t know how to type or something.
REQUIRED_DATA_MISSINGNoneaddress, city and/or postal code is missing.
ERROR_WITH_ADDRESS_SAVINGactual_error

There was an error with address saving. It maybe is not really an error, but duplicate address. At the moment only error that will be received with this is duplicate address error, and hopefully that won’t change with future versions.

actual_error is localized, as message is, so showing them to customer is maybe good way to implement this, and letting customer to fix the mistakes instead of trying to implement any automatic logic for this error.

USER_NOT_FOUNDNoneUser not found, most likely invalid user id.
INVALID_LATITUDENoneProblem in client. Please ensure latitude and longitude are doubles.
INVALID_LONGITUDENoneProblem in client. Please ensure latitude and longitude are doubles.
INVALID_PREFERRED_ADDRESSNonePlease only pass true or false as value.

/customer/address/modify

This can be used to modify an address of customer. It only changes passed values; not every field must be given to update for example latitude.

Session id and address id must be given.

Request

POST name Value Maximum length Required?
session_id Hash from login Yes
address_id "1" Yes
name "Funny Name" 50 No
address "Funny address 1" 150 Yes
postal_code "01234" 5 No
city "TestCity" 100 Yes
latitude "60.403415" 9, 6 decimals No
longitude "25.104618" 9, 6 decimals No
preferred_address "true" boolean No

Response

ResponseJSON
Success:"success"
Failure:error array

Expectable errors

See error conventions section for explanation how error system works.

Label Additional data Description
ADDRESS_ID_NOT_SETNoneIf address_id was not in the request. Naturally shouldn’t happen.
ADDRESS_NOT_FOUNDNoneThis shouldn’t either happen...

/customer/address/delete

Deletes customer’s saved address.

Request

POST nameValueRequired?
session_idintegerYes
address_idintegerYes

Response

"success" if deleting succeeded, an error array if it did not.

Expectable errors

See error conventions section for explanation how error system works.

Label Additional data Description
NOT_UNIQUE_ADDRESSNoneIf there was no modification to be done to the address; i.e. customer gave same data the address already contained.
ADDRESS_ID_NOT_SETNoneIf address_id was not in the request. Naturally shouldn’t happen.
ADDRESS_NOT_FOUNDNoneThis shouldn’t either happen...