(Quick Reference)
Service: Create a promotion list Description: Returns the created promotion list in json format when successful. Returns a json response, describing the failure condition when unsuccessful. URL: https://BASE_URL/api/VERSION/promotionLists Method: POST Request content type: application/json
Parameters: Name | Description | Type | Required | Example values |
---|
reference | | String | yes | | description | | String | yes | | startDate | Should be formatted as yyyy-MM-dd | Date | yes | | endDate | Should be formatted as yyyy-MM-dd | Date | yes | | isActive | By default, it is set to true and it tell if the promotion list is active or not | Boolean | no | true, false | applyToAllCustomers | By default, it's set to false and it tell if the promotion list is assigned to all customers or not | Boolean | no | true, false | promotionInputs | It contain the sequence inputs for the promotion | JSON | yes | | promotionOutputs | It contain the sequence outputs concluded from the inputs of the promotion | JSON | yes | | useExternalId | By default, it is set to false. set it to true if you want to use external ids. | Boolean | no | true , false |
Promotion details parameters : Parameter name: promotionInputs Parameter type: a json structure Name | Description | Type | Required | Example values |
---|
inputType | Should be equal to 1 for item quantity , 2 for item group , 3 for invoice amount , 4 for item amount and 5 for item category | Integer/String | yes | 1,2,3,"4","5" | value | Should be a double if inputType is an amount (3,4) or integer if inputType is a quantity (1,2,5) | Double/Integer | yes | | sequence | Used to manage input/ouput sequences | Integer | yes | | serial | In every sequence, input can have one or more serials connected by operator AND | Integer | yes | | itemId | Required if inputType equal to '1' or '4' | Long/String | - | | unitId | Required if inputType equal to '1' or '4' | Long/String | - | | itemGroupId | Required if inputType equal to '2' | Long/String | - | | itemCategoryId | Required if inputType equal to '5' | Long/String | - | | enablePromotionSum | By default it is set to false | Boolean | no | true, false | applyToAllItemsInput | By default it set to false and it tell if the promotion inputs are applied for all items or not, it is considered only if inputType equal to '1' or '4' | Boolean | yes | true , false | promotionType | It define the promotion type and it take one of this value : '1' for greater than , '2' for less than and '3' for equal | Integer/String | yes | 1,2,"3" |
the numeric value used in sequence attribute to declare a sequence must at least used one time for sequence in the promotion output
In case inputType equal to '1' or '4' so itemId and unitId are required, there is one more condition is that the item extracted from the specified itemId must be assigned to the unit related to the specified unitId Parameter name: promotionOutputs Parameter type: a json structure Name | Description | Type | Required | Example values |
---|
outputType | Should be equal to 1 if Item quantity , 2 if Item Discount , 3 if Item Group , 4 if Item Group Discount , 5 if Invoice Discount , 6 if Item Category and 7 if Item Category Discount | Integer/String | yes | 1,2,3,4,5,6,7 | value | Should be a double if outputType is a discount (2,4,5,7) or integer if outputType is a quantity (1,3,6) | Double/Integer | yes | | discountType | Should be equal to 1 if Percentage, 2 if Value, required if outputType is a discount (2,4,5,7) | Integer/String | - | 1,2 | sequence | Used to manage input/ouput sequences | Integer | yes | | serial | In every sequence, input can have one or more serials connected by operator AND
| Integer | yes | | itemId | Required if inputType equal to '1' or '2' | Long/String | - | | unitId | Required if inputType equal to '1' or '2' | Long/String | - | | itemGroupId | Required if inputType equal to '3' or '4' | Long/String | - | | itemCategoryId | Required if inputType equal to '6' or '7' | Long/String | - | | duplicatePromotion | By default, it is set to false | Boolean | no | true, false | applyToAllItemsOutput | By default it set to false and it tell if the promotion outputs are applied to all items or not, it is considered only if outputType@ equal to '1' or '2' | Boolean | yes | true , false |
the numeric value used in sequence attribute to declare a promotion output must be already used in a promotion input.
In case outputType equal to '1' or '2' so itemId and unitId are required, there is one more condition is that the item extracted from the specified itemId must be assigned to the unit related to the specified unitId . Example:
{
"reference": "R-P-08969",
"description": "Five for double five",
"startDate": "2016-08-01",
"endDate": "2016-08-31",
"isActive": true,
"paymentTypeId": 7,
"applyToAllCustomers":true,
"promotionInputs": [
{
"itemId": 13,
"unitId": 1,
"inputType": "5",
"sequence": 1,
"serial": 1,
"value": "5",
"enablePromotionSum": true,
"applyToAllItemsInput":true,
"promotionType" : 1,
"itemGroupId" : 1,
"itemCategoryId" :1
}],
"promotionOutputs": [
{
"itemId": 13,
"unitId": 1,
"outputType": "7",
"itemGroupId": "1",
"discountType": "1",
"sequence": 1,
"serial": 1,
"value": "5",
"duplicatePromotion":true,
"applyToAllItemsOutput":false,
"itemGroupId" : 1,
itemCategoryId:1
},
{
"itemId": 13,
"unitId": 1,
"outputType": "7",
"itemGroupId": "1",
"discountType": "2",
"sequence": 1,
"serial": 2,
"value": "5",
"duplicatePromotion":true,
"applyToAllItemsOutput":false,
"itemGroupId" : 1,
"itemCategoryId" :1
}]
} Success Output Success case: response.status = 201 {
"id": 18,
"reference": "R-P-08969",
"description": "Five for double five",
"startDate": "2016-08-01",
"endDate": "2016-08-31",
"isActive": true,
"applyToAllCustomers": true,
"promotionInputs": [
{
"id": 46,
"href": "/api/v1.0/promotionInputs/46"
}
],
"promotionOutputs": [
{
"id": 48,
"href": "/api/v1.0/promotionOutputs/48"
},
{
"id": 49,
"href": "/api/v1.0/promotionOutputs/49"
}
],
"organization": "New Delice",
"dateCreated": "2016-10-07T15:38:30Z",
"lastUpdated": "2016-10-07T15:38:30Z"
}
Failure Output Failure case:response.status = 400 {
"error": "not_unique",
"error_description": "reference already used"
} {
"error": "missing_param",
"error_description": "discountType parameter is missing"
} {
"error": "missing_param",
"error_description": "itemId parameter is missing"
} {
"error": "invalid_sequence",
"error_description": "Input options should be equal to output options."
} Failure case:response.status = 404
{
"error": "not_found",
"error_description": "The item with the id 999 doesn't exist."
} {
"error": "not_found",
"error_description": "The unit with the id 100 doesn't exist."
} {
"error": "not_found",
"error_description": "The unit with the id 100 doesn't exist."
} {
"error": "not_found",
"error_description": "The item group with the id 618 doesn't exist."
} Failure case:response.status = 500
{
"error": "server_error",
"error_description": "Oops! Something went wrong..."
}
|
|