API - Customers

Manage the customers


Routes

Method name Route Parameters OK return code Return
GET /api/customers 200 Results of the 'customer' loop
GET /api/customers/{entityId} entityId: The customer id 200 Results of the 'customer' loop for entityId
POST /api/customers 201 Results of the 'customer' loop for the created customer
PUT /api/customers 201 Results of the 'customer' loop for the updated customer
DELETE /api/customers/{entityId} entityId: The customer id 204 Nothing
POST /api/customers/checkLogin 200 Results of the 'customer' loop if the customer exists

Creation

If you want to create a customer, you have to send the following fields with the POST method.

General information
  • title : The customer title id
  • firstname : The customer first name
  • lastname : The customer last name
  • email : The customer email address
  • password : The customer password
  • lang_id : The customer lang id
The address
  • country : The address country id
  • zipcode : The address zipcode
  • city : The address city
  • address1 : The address (street, number, …)
  • address2 : The additional address (optional)
  • address3 : Another additional address (optional)

Example

{
    "title": 1,
    "firstname": "Thelia",
    "lastname": "Thelia",
    "address1": "street address 1",
    "city": "Clermont-Ferrand",
    "zipcode": 63100,
    "country": 64,
    "email": "dev@thelia.net",
    "password": "azerty",
    "lang_id": 1
}

Update

To update a customer, you have to send the same data (only updated ones) as for a create, but with the PUT method.

Moreover, you have to add the “id” field.

Example

{
    "id": 1,
    "title": 1,
    "firstname": "Thelia",
    "lastname": "Thelia",
    "address1": "street address 1",
    "city": "Clermont-Ferrand",
    "zipcode": 63100,
    "country": 64,
    "email": "foo@thelia.net",
    "lang_id": 1
}

Check login

You can check if an email and password correspond to a customer with the ‘/api/customers/checkLogin’ route.

The corresponding customer will be returned if one exists, or a 404 response if one does not.

Exemple

{
    "email": "foo@thelia.net",
    "password": "azerty"
}