(Quick Reference) Service: Create a discount list

Description: Returns the created discount list in json format when successful. Returns a json response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/discountLists

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
reference Stringyes 
name Stringyes 
percentageDiscountThe percentage discountDoubleyes 
billingCategoryA billing category is a root item categoryString/Longno 
itemCategoriesA list of item categoriesJSON listno[90,91]

A discount list should be assigned either to a billing category or to a list of item categories.
If you don't specify any of these parameter (billingCategory, itemCategories), discount list will be assigned to all categories.

Success Output

Status: HTTP/1.1 201 Created

{
  "id": 4,
  "reference": "discount70",
  "name": "70% discount",
  "percentageDiscount": 70.0,
  "billingCategory": null,
  "itemCategories": [],
  "organization": "entity1",
  "dateCreated": "2016-06-30T12:23:56Z",
  "lastUpdated": "2016-06-30T12:23:56Z"
}

Failure Output

Status: HTTP/1.1 404 Not Found
{
    "error": "not_found",
    "error_description": "The item category with the id 1 doesn't exist."
}

Status: HTTP/1.1 400 Bad Request

{
  "error": "save_failed",
  "error_description": "Failed to save instance"
}
{
  "error": "invalid_param_type",
  "error_description": "An invalid value was specified for parameter: percentageDiscount (must be positive)"
}
{
  "error": "not_unique",
  "error_description": "reference already used"
}
{
  "error": "missing_param",
  "error_description": "name parameter is missing"
}

{
    "error": "invalid_param",
    "error_description": "The billing category should be a root item category"
}

{
    "error": "rule_validation_error",
    "error_description": "A discount list should be assigned either to a billing category or to a list of item categories."
}

Status: HTTP/1.1 500 Internal Server Error
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}