Customers¶
API endpoint for manage customers.
Data management¶
/api/customers
¶
-
GET
/storekeeper/api/customers
¶ List customers
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
Example request:
GET /storekeeper/api/customers HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "id": 1, "name": "Big Customer Ltd." }, { "id": 2, "name": "Buy Everything Co." } ]
-
POST
/storekeeper/api/customers
¶ Create customer
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 422 Unprocessable Entity – there is wrong type / missing field / customer is already exist
Example request:
POST /storekeeper/api/customers HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "name": "Big Customer Ltd." }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "id": 1, "name": "Big Customer Ltd." }
/api/customers/<id>
¶
-
GET
/storekeeper/api/customers/
(int: id)¶ Get customer
Parameters: - id – ID of selected customer for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no customer
Example request:
GET /storekeeper/api/customers/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "name": "Big Customer Ltd." }
-
PUT
/storekeeper/api/customers/
(int: id)¶ Update customer
Parameters: - id – ID of selected customer for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no customer
- 422 Unprocessable Entity – there is wrong type / missing field / customer is already exist
Example request:
PUT /storekeeper/api/customers/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "name": "new_foo" }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "name": "new_foo" }
-
DELETE
/storekeeper/api/customers/
(int: id)¶ Delete customer
Parameters: - id – ID of selected customer for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no customer
Example request:
DELETE /storekeeper/api/customers/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null