Works

API endpoint for manage works.

Data management

/api/works

GET /storekeeper/api/works

List works

Status Codes:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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:

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"
  }
}