Works¶
API endpoint for manage works.
Data management¶
/api/works
¶
-
GET
/storekeeper/api/works
¶ List works
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
Example request:
GET /storekeeper/api/works HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "comment": "First work", "customer": { "id": 1, "name": "Big Customer Ltd." }, "id": 1, "outbound_close_timestamp": null, "outbound_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "returned_close_timestamp": null, "returned_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null } }, { "comment": null, "customer": { "id": 2, "name": "Buy Everything Co." }, "id": 2, "outbound_close_timestamp": null, "outbound_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "returned_close_timestamp": null, "returned_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null } } ]
-
POST
/storekeeper/api/works
¶ Create work
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 422 Unprocessable Entity – there is wrong type / missing field
Example request:
POST /storekeeper/api/works HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "comment": "First work", "customer": { "id": 1, "name": "Big Customer Ltd." } }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "comment": "First work", "customer": { "id": 1, "name": "Big Customer Ltd." }, "id": 1, "outbound_close_timestamp": null, "outbound_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "returned_close_timestamp": null, "returned_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null } }
/api/works/<id>
¶
-
GET
/storekeeper/api/works/
(int: id)¶ Get work
Parameters: - id – ID of selected work for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no work
Example request:
GET /storekeeper/api/works/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "comment": "First work", "customer": { "id": 1, "name": "Big Customer Ltd." }, "id": 1, "outbound_close_timestamp": null, "outbound_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "returned_close_timestamp": null, "returned_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null } }
-
PUT
/storekeeper/api/works/
(int: id)¶ Update work
Parameters: - id – ID of selected work for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no work
- 422 Unprocessable Entity – there is wrong type / missing field
Example request:
PUT /storekeeper/api/works/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "comment": "Something are not finished", "customer": { "id": 1, "name": "Big Customer Ltd." } }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "comment": "Something are not finished", "customer": { "id": 1, "name": "Big Customer Ltd." }, "id": 1, "outbound_close_timestamp": null, "outbound_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null }, "returned_close_timestamp": null, "returned_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null } }
-
DELETE
/storekeeper/api/works/
(int: id)¶ Delete work
Parameters: - id – ID of selected work for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no work
Example request:
DELETE /storekeeper/api/works/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null
/api/works/<id>/items
¶
-
GET
/storekeeper/api/works/
(int: id)/items
¶ List work items
Parameters: - id – ID of work
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no item
Example request:
GET /storekeeper/api/works/1/items HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "outbound_quantity": 132.8, "returned_quantity": null }, { "id": 2, "item": { "article_number": "SK132465", "id": 1, "location": "A12/12", "name": "Spray", "purchase_price": 60.4, "quantity": 0.0, "unit": { "id": 2, "unit": "pcs" }, "vendor": { "id": 1, "name": "Heavy Duty Ltd." }, "warning_quantity": 4.0 }, "outbound_quantity": 41.2, "returned_quantity": 2.1 } ]
-
POST
/storekeeper/api/works/
(int: id)/items
¶ Create work item
Parameters: - id – ID of work
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – can not add new work item after outbound items was closed
- 404 Not Found – there is no item
- 422 Unprocessable Entity – there is wrong type / missing field / can not add one item twice
Example request:
POST /storekeeper/api/works/1/items HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "outbound_quantity": 132.8 }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "outbound_quantity": 132.8, "returned_quantity": null }
/api/works/<id>/items/<item_id>
¶
-
GET
/storekeeper/api/works/
(int: id)/items/
(int: item_id)¶ Get work item
Parameters: - id – ID of work
- item_id – ID of selected work item for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no work item
Example request:
GET /storekeeper/api/works/1/items/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "outbound_quantity": 132.8, "returned_quantity": null }
-
PUT
/storekeeper/api/works/
(int: id)/items/
(int: item_id)¶ Update work item
Parameters: - id – ID of work
- item_id – ID of selected work item for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – can not change work item after outbound/returned items was closed
- 404 Not Found – there is no work item
- 422 Unprocessable Entity – there is wrong type / missing field / can not add one item twice
Example request:
PUT /storekeeper/api/works/1/items/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "outbound_quantity": 132.8 }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "item": { "article_number": "FO213546", "id": 2, "location": "B02/01", "name": "Pipe", "purchase_price": 0.0, "quantity": 0.0, "unit": { "id": 1, "unit": "m" }, "vendor": { "id": 2, "name": "Star Shop Ltd." }, "warning_quantity": 0.0 }, "outbound_quantity": 132.8, "returned_quantity": null }
-
DELETE
/storekeeper/api/works/
(int: id)/items/
(int: item_id)¶ Delete work item
Parameters: - id – ID of work
- item_id – ID of selected work item for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 403 Forbidden – can not delete work item after outbound/returned items was closed
- 404 Not Found – there is no work item
Example request:
DELETE /storekeeper/api/works/1/items/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null
Commands¶
/api/works/<id>/close-outbound
¶
-
PUT
/storekeeper/api/works/
(int: id)/close-outbound
¶ Close outbound items on work
Parameters: - id – ID of selected work for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no work
- 422 Unprocessable Entity – there is wrong type / missing field / outbound items have been closed /insufficient quantities for close the outbound work items
Example request:
PUT /storekeeper/api/works/1/close-outbound HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "comment": "First work", "customer": { "id": 1, "name": "Big Customer Ltd." }, "id": 1, "outbound_close_timestamp": "2016-03-18T07:57:54.972763+00:00", "outbound_close_user": { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" }, "returned_close_timestamp": null, "returned_close_user": { "admin": null, "disabled": null, "email": null, "id": null, "username": null } }
/api/works/<id>/close-returned
¶
-
PUT
/storekeeper/api/works/
(int: id)/close-returned
¶ Close returned items on work
Parameters: - id – ID of selected work for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no work
- 422 Unprocessable Entity – there is wrong type / missing field / outbound items have not been closed / returned items have been closed /insufficient quantities for close the returned work items
Example request:
PUT /storekeeper/api/works/1/close-returned HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "comment": "First work", "customer": { "id": 1, "name": "Big Customer Ltd." }, "id": 1, "outbound_close_timestamp": "2016-03-18T07:57:54.972763+00:00", "outbound_close_user": { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" }, "returned_close_timestamp": "2016-03-18T07:57:54.972818+00:00", "returned_close_user": { "admin": false, "disabled": false, "email": "foo@bar.com", "id": 2, "username": "foo" } }