(Quick Reference)
33 Assign units to items - Reference Documentation
Version: 2.1
33 Assign units to items
33.1 List
Service: List item-units
Description: This web service return the list of item-units in JSON format.
URL:
https://BASE_URL/api/VERSION/itemUnits
Method: GET
Parameters:
Pagination parameters:
Name | Description | Type | Required | Possible values |
---|
offset | Tells where to start returning records from the entire set of results. | Integer | No | |
max | Limits the number of resources requested to return. | Integer | No | |
sort | Orders the results by the specified field. | String | No | |
order | Orders ascending or descending | Integer | No | asc, desc |
Filters parameters:
Name | Description | Type | Required | Example values |
---|
dateCreated_gt | Filters by the resource's creation date time and operator greater than | Date | no | 2016-08-15T14:52:48Z |
dateCreated_gte | Filters by the resource's creation date time and operator greater than or equal | Date | no | |
dateCreated_lt | Filters by the resource's creation date time and operator less than | Date | no | |
dateCreated_lte | Filters by the resource's creation date time and operator less than or equal | Date | no | |
lastUpdated_gt | Filters by the resource's last-modified date time and operator greater than | Date | no | |
lastUpdated_gte | Filters by the resource's last-modified date time and operator greater than or equal | Date | no | |
lastUpdated_lt | Filters by the resource's last-modified date time and operator less than | Date | no | |
lastUpdated_lte | Filters by the resource's last-modified date time and operator less than or equal | Date | no | |
itemReference | Wildcard search by the item's reference | String | no | itemReference=Ref-6* |
unitReference | Wildcard search by the unit's reference | String | no | unitReference=Ref-9* |
isDefault | Filters by default item unit, and vice versa | Boolean | no | |
Dates should be formatted as the ISO-8601 format (YYYY-MM-DDTHH:MM:SSZ)
Success Output
Success case: response.status = 200
{
"paging": {
"total": 61,
"max": 5,
"offset": 0,
"previous": null,
"next": "/api/v1.0/itemUnits?max=5&offset=5&sort=dateCreated&order=asc"
},
"data": [
{
"id": 1,
"itemReference": "bracelet-GRP09062",
"unitReference": "pcs",
"item": {
"id": 497,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"href": "/api/v1.0/items/497"
},
"unit": {
"id": 1,
"reference": "pcs",
"name": "pieces",
"href": "/api/v1.0/units/1"
},
"quantity": 1,
"unpacking": true,
"salesQuantity": 4,
"volume" : 5,
"weight" : 15.33,
"barcode": "(10)45566(17)161231",
"expirationDate": "2016-12-31",
"isDefault": true,
"defaultDisplay": true,
"organization": "entity1",
"dateCreated": "2015-12-17T08:17:07Z",
"lastUpdated": "2016-01-08T08:10:54Z"
},…
]
}
Failure Output
Failure case:response.status = 400
{
"error": "invalid_param",
"error_description": "The parameters [dateCreated_gta] you provided are not valid for this request."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
33.2 Show
Service: Show an item-unit
Description: Returns the requested item-unit in json format when successful. Returns a json response, describing the failure condition when unsuccessful.
Method: GET
URL:
https://BASE_URL/api/VERSION/itemUnits/{id}
Parameters:
Name | Description | Type | Required | Example values |
---|
id | The numerical ID of the desired item unit | Long | Yes | 777 |
URL with external_id:
https://BASE_URL/api/VERSION/itemUnits/reference/{itemId}/{unitId}
Parameters:
Name | Description | Type | Required | Examples values |
---|
itemId | reference of the item | String | Yes | eliteBook_820 |
unitId | reference of the unit | String | Yes | Piéce |
Success Output
Success case: response.status = 200
{
"id": 1,
"itemReference": "bracelet-GRP09062",
"unitReference": "pcs",
"item": {
"id": 497,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"href": "/api/v1.0/items/497"
},
"unit": {
"id": 1,
"reference": "pcs",
"name": "pieces",
"href": "/api/v1.0/units/1"
},
"quantity": 1,
"unpacking": true,
"salesQuantity": 4,
"volume" : 5,
"weight" : 15.33,
"barcode": "(10)45566(17)161231",
"expirationDate": "2016-12-31",
"isDefault": true,
"defaultDisplay": true,
"organization": "entity1",
"dateCreated": "2015-12-17T08:17:07Z",
"lastUpdated": "2016-01-08T08:10:54Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "invalid_param_type",
"error_description": "The type of parameter id you provided is not valid for this request."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item unit with the id 1000 doesn't exist."
}
33.3 Create
Service: Create an item-unit
Description: Returns the created item-unit in json format when successful. Returns a json response, describing the failure condition when unsuccessful.
URL:
https://BASE_URL/api/VERSION/itemUnits
Method: POST
Request content type: application/json
Parameters:
Name | Description | Type | Required | Example values |
---|
itemId | The ID of item | Long/String | yes | |
unitId | The ID of unit | Long/String | yes | |
quantity | Quantity of product by unit | Integer | yes | |
salesQuantity | Quantity used in sales operations | Integer | no | |
volume | Volume of product by unit (m^3) | Double | no | 13.11 |
weight | Weight of product by unit (kg) | Double | no | 16 |
barcode | | String | no | |
expirationDate | The expiration date field is automatically filled if the bar code meets the standard EAN 128 | Date | no | 2016-08-31 |
isDefault | This parameter is required when item don't have a default unit, otherwise it is set to false by default. | Boolean | - | true, false |
defaultDisplay | | Boolean | no | true, false |
unpacking | this parameter is set to false by default. | Boolean | no | true, false |
useExternalId | By default, it is set to false. set it to true if you want to use external ids. | Boolean | no | true , false |
Every item must have only one default unit.
Success Output
Success case: response.status = 201
{
"id": 92,
"itemReference": "bracelet-GRP09062",
"unitReference": "PACKET",
"item": {
"id": 497,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"href": "/api/v1.0/items/497"
},
"unit": {
"id": 7,
"reference": "PACKET",
"name": "packet",
"href": "/api/v1.0/units/7"
},
"quantity": 4,
"salesQuantity": 1,
"volume": null,
"weight": null,
"barcode": null,
"expirationDate": null,
"isDefault": false,
"defaultDisplay": false,
"organization": "entity1",
"dateCreated": "2016-08-24T09:17:24Z",
"lastUpdated": "2016-08-24T09:17:24Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "already_assigned",
"error_description": "Item is already assigned to unit."
}
{
"error": "is_default_error",
"error_description": "Item has already a default unit."
}
{
"error": "date_validation_error",
"error_description": "incorrect expiration date Format"
}
{
"error": "invalid_param_type",
"error_description": "An invalid value was specified for parameter: weight (must be Positive Double)"
}
{
"error": "refused_value",
"error_description": "Sales quantity should be equal to 1."
}
{
"error": "json_parsing_error",
"error_description": "A JSON parsing error occurred while parsing request parameters."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item with the id 123 doesn't exist."
}
{
"error": "not_found",
"error_description": "The unit with the id 70 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
33.4 Update
Service: Update an item-unit
Description: Returns the updated item-unit in json format when successful. Returns a json response, describing the failure condition when unsuccessful.
Method: PUT
Request content type: application/json
URL:
https://BASE_URL/api/VERSION/itemUnits/{id}
Parameters:
Name | Description | Type | Required | Example values |
---|
id | The numerical ID of the desired item-unit | Integer | yes | 123 |
itemId | The numerical ID of item | Long | yes | |
unitId | The numerical ID of unit | Long | yes | |
quantity | Quantity of product by unit | Integer | yes | |
salesQuantity | Quantity used in sales operations | Integer | no | |
volume | Volume of product by unit (m^3) | Double | no | 13.11 |
weight | Weight of product by unit (kg) | Double | no | 16 |
barcode | | String | no | |
expirationDate | The expiration date field is automatically filled if the bar code meets the standard EAN 128 | Date | no | 2016-08-31 |
isDefault | This parameter is required when item don't have a default unit,otherwise it is set to false by default. | Boolean | yes | true, false |
defaultDisplay | | Boolean | no | true, false |
unpacking | this parameter is set to false by default. | Boolean | no | true, false |
URL with external_id:
https://BASE_URL/api/VERSION/itemUnits/reference/{itemId}/{unitId}
Parameters:
Name | Description | Type | Required | Examples values |
---|
itemId | reference of the item | String | Yes | eliteBook_820 |
unitId | reference of the unit | String | Yes | Piéce |
quantity | Quantity of product by unit | Integer | yes | |
salesQuantity | Quantity used in sales operations | Integer | no | |
volume | Volume of product by unit (m^3) | Double | no | 13.11 |
weight | Weight of product by unit (kg) | Double | no | 16 |
barcode | | String | no | |
expirationDate | The expiration date field is automatically filled if the bar code meets the standard EAN 128 | Date | no | 2016-08-31 |
isDefault | This parameter is required when item don't have a default unit,otherwise it is set to false by default. | Boolean | yes | true, false |
defaultDisplay | | Boolean | no | true, false |
Every item must have only one default unit.
Success Output
Success case: response.status = 200
{
"id": 92,
"itemReference": "bracelet-GRP09062",
"unitReference": "PACKET",
"item": {
"id": 497,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"href": "/api/v1.0/items/497"
},
"unit": {
"id": 7,
"reference": "PACKET",
"name": "packet",
"href": "/api/v1.0/units/7"
},
"quantity": 4,
"unpacking": true,
"salesQuantity": 1,
"volume": 13,
"weight":100.14
"barcode": null,
"expirationDate": "2016-08-30",
"isDefault": false,
"defaultDisplay": false,
"organization": "entity1",
"dateCreated": "2016-08-24T09:17:24Z",
"lastUpdated": "2016-08-24T09:35:11Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "already_assigned",
"error_description": "Item is already assigned to unit."
}
{
"error": "date_validation_error",
"error_description": "incorrect expiration date Format"
}
{
"error": "is_default_error",
"error_description": "Item should have a default unit."
}
{
"error": "invalid_param_type",
"error_description": "An invalid value was specified for parameter: weight (must be Positive Double)"
}
{
"error": "refused_value",
"error_description": "Sales quantity should be equal to 1."
}
{
"error": "json_parsing_error",
"error_description": "A JSON parsing error occurred while parsing request parameters."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item unit with the id 96 doesn't exist."
}
{
"error": "not_found",
"error_description": "The item with the id 123 doesn't exist."
}
{
"error": "not_found",
"error_description": "The unit with the id 70 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
33.5 Upsert
Service: Upsert an item-unit
Description: This web service is used to insert an item-unit object to the database if it does not already exist, or update it.
URL with external_id:
https://BASE_URL/api/VERSION/itemUnits/reference/{itemId}/{unitId}
Method: POST
Request content type: application/json
Parameters:
Name | Description | Type | Required | Examples values |
---|
itemId | reference of the item | String | No | eliteBook_820 |
unitId | reference of the unit | String | No | Piéce |
quantity | Quantity of product by unit | Integer | yes | |
salesQuantity | Quantity used in sales operations | Integer | no | |
volume | Volume of product by unit (m^3) | Double | no | 13.11 |
weight | Weight of product by unit (kg) | Double | no | 16 |
barcode | | String | no | |
expirationDate | The expiration date field is automatically filled if the bar code meets the standard EAN 128 | Date | no | 2016-08-31 |
isDefault | This parameter is required when item don't have a default unit,otherwise it is set to false by default. | Boolean | yes | true, false |
defaultDisplay | | Boolean | no | true, false |
unpacking | this parameter is set to false by default. | Boolean | no | true, false |
Every item must have only one default unit.
Success Output
Success case: response.status = 201
{
"id": 92,
"itemReference": "bracelet-GRP09062",
"unitReference": "PACKET",
"item": {
"id": 497,
"reference": "bracelet-GRP09062",
"name": "Knot Band Bracelet",
"href": "/api/v1.0/items/497"
},
"unit": {
"id": 7,
"reference": "PACKET",
"name": "packet",
"href": "/api/v1.0/units/7"
},
"quantity": 4,
"unpacking": true,
"salesQuantity": 1,
"volume": null,
"weight": null,
"barcode": null,
"expirationDate": null,
"isDefault": false,
"defaultDisplay": false,
"organization": "entity1",
"dateCreated": "2016-08-24T09:17:24Z",
"lastUpdated": "2016-08-24T09:17:24Z"
}
Failure Output
Failure case:response.status = 400
{
"error": "already_assigned",
"error_description": "Item is already assigned to unit."
}
{
"error": "is_default_error",
"error_description": "Item has already a default unit."
}
{
"error": "date_validation_error",
"error_description": "incorrect expiration date Format"
}
{
"error": "invalid_param_type",
"error_description": "An invalid value was specified for parameter: weight (must be Positive Double)"
}
{
"error": "refused_value",
"error_description": "Sales quantity should be equal to 1."
}
{
"error": "json_parsing_error",
"error_description": "A JSON parsing error occurred while parsing request parameters."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item with the id 123 doesn't exist."
}
{
"error": "not_found",
"error_description": "The unit with the id 70 doesn't exist."
}
Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
33.6 Delete
Service: Delete an item-unit
Description: Returns a json response.
Method: DELETE
URL:
https://BASE_URL/api/VERSION/itemUnits/{id}
Parameters:
Name | Description | Type | Required | Example values |
---|
id | The numerical ID of the desired item-unit | Long | yes | 123 |
URL with external_id:
https://BASE_URL/api/VERSION/itemUnits/reference/{itemId}/{unitId}
Parameters:
Name | Description | Type | Required | Examples values |
---|
itemId | reference of the item | String | Yes | eliteBook_820 |
unitId | reference of the unit | String | Yes | Piéce |
Success Output
Success case: response.status = 200
{
"success": "true",
"success_description": "Instance deleted successfully"
}
Failure Output
Failure case:response.status = 400
{
"error": "delete_failed",
"error_description": "Failed to delete instance."
}
Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item unit with the id 70 doesn't exist."
}