Unit conversion

Items are sold, purchased and kept in different units of measure. To be able to sell items in different units of measure there needs to exist a unit conversion rule between the two units of measure. For an example one box contains 24 pieces of item X.

From unit x factor = To unit

The unitconversion endpoint in LS One API allows management of the conversion rules between different units of measure.

Actions

GET 

Get unit conversion
GET  Get all unit conversions

POST 

Create a new unit conversion

PUT 

Update a unit conversion

DELETE 

Delete a unit conversion

Properties

Field Data type Validation Description
id

string

N/A

Unique identifier of the item to which the unit conversion rule applies

If this is null, the unit conversion rule is considered global

fromUnitId string Required

max. length =20

Unit identifier from which the conversion is made
toUnitId string Required

max. length = 20

Unit identifier to which the conversion is made
factor decimal Required The factor for the unit conversion

Examples

Get unit conversion

Returns details of a single unit conversion.

GET /api/unitconversion/{fromUnitId}/{toUnitId}?itemId={itemId}

Permissions

  • UnitConversion:Read

For more information on authenticating to LS One APIs, see Authentication.

Request

curl -X 'GET' \
'https://lsoneapi.lsretail.com/api/unitconversion/CAN/BOX?itemId=34411' \
-H 'accept: text/plain' \
-H 'Authorization: Bearer {authentication_token}'
Parameter Data type Validation Description
fromUnitId string

Required

Part of the id since unit Id is composed of fromUnitId and toUnitId;
toUnitId string

Required

Part of the id since unit Id is composed of fromUnitId and toUnitId;
itemId string - The item id for which we need the unit conversion. Default value = "" (global conversion).

Response

{
	"id": "34411",
	"fromUnitId": "CAN",
	"toUnitId": "BOX",
	"factor": 24.000000000000
}		

Status codes

Code Text Description
200 Success Success
401 Unauthorized LS One API client did not provide a valid authentication token or it does not have permissions to read unit conversion(s)
404 Not Found The requested unit conversion was not found

Get all unit conversions

Returns a list of all unit conversions.

GET /api/unitconversion

Permissions

  • UnitConversion:Read

For more information on authenticating to LS One APIs, see Authentication.

Request

curl -X 'GET' \
  'https://lsoneapi.lsretail.com/api/unitconversion' \
  -H 'accept: text/plain' \
 -H 'Authorization: Bearer {authentication_token}'

Response

[
	{
		"id": "",
		"fromUnitId": "9 INCH",
		"toUnitId": "12 INCH",
		"factor": 1.500000000000
	},
	{
		"id": "",
		"fromUnitId": "BOTTLE",
		"toUnitId": "TBSP",
		"factor": 0.040000000000
	},
	...
]

Status codes

Code Text Description
200 Success Success
401 Unauthorized LS One API client did not provide a valid authentication token or it does not have permissions to read unit conversion(s)
404 Not Found No unit conversions found

Create a new unit conversion

Create a new unit conversion.

POST /api/unitconversion

To create a new unit conversion, the following fields are required:

  • fromUnitId

  • toUnitId

  • factor

Permissions

  • UnitConversion:Write

For more information on authenticating to LS One APIs, see Authentication.

Request

curl -X 'POST' \
  'https://lsoneapi.lsretail.com/api/unitconversion' \
  -H 'accept: text/plain' \
  -H 'Authorization: Bearer {authorization_token}' \
  -H 'Content-Type: application/json' \
  -d '{
		"fromUnitId": "CARTON",
		"toUnitId": "Plastic",
		"factor": 25
}'

Response

{
	"id": "",
	"fromUnitId": "CARTON",
	"toUnitId": "Plastic",
	"factor": 25
}

Status codes

Code Text Description
200 Success Success
401 Unauthorized LS One API client did not provide a valid authentication token or it does not have permissions to read unit conversion(s)
400 BadRequest New unit conversion could not be created

Update a unit conversion

Updates an existing unit conversion.

PUT /api/unitconversion

To update an existing unit conversion, the following fields are required:

  • fromUnitId

  • toUnitId

  • factor

Permissions

  • UnitConversion:Write

For more information on authenticating to LS One APIs, see Authentication.

Request

curl -X 'PUT' \
  'https://lsoneapi.lsretail.com/api/unitconversion' \
  -H 'accept: text/plain' \
  -H 'Authorization: Bearer {authentication_token}' \
  -H 'Content-Type: application/json' \
  -d '{
		"fromUnitId": "CARTON",
		"toUnitId": "Plastic",
		"factor": 44
}'

Response

{
	"id": "",
	"fromUnitId": "CARTON",
	"toUnitId": "Plastic",
	"factor": 44
}

Status codes

Code Text Description
200 Success Success
401 Unauthorized LS One API client did not provide a valid authentication token or it does not have permissions to write unit conversion(s)
400 BadRequest Unit conversion could not be updated
404 NotFound Unit conversion to be updated was not found

Delete a unit conversion

Delete an existing unit conversion.

DELETE /api/unitconversion/{fromUnitId}/{toUnitId}

Permissions

  • Unit conversion:Write

For more information on authenticating to LS One APIs, see Authentication.

Request

curl -X 'DELETE' \
  'https://lsoneapi.lsretail.com/api/unitconversion/CARTON/Plastic' \
  -H 'accept: text/plain' \
  -H 'Authorization: Bearer {authentication_token}'
Parameter Data type Validation Description
fromUnitId string

Required

Part of the id since unit Id is composed of fromUnitId and toUnitId;
toUnitId string

Required

Part of the id since unit Id is composed of fromUnitId and toUnitId;

Response

HTTP/1.1 204 No Content

Status codes

Code Text Description
200 Success Success
401 Unauthorized LS One API client did not provide a valid authentication token or it does not have permissions to read unit conversion(s)
404 Not Found The requested unit conversion was not found