(Quick Reference) Service: Upsert a discount list

Description: This web service is used to insert a discount list to the database if it does not already exist, or update it.

URL with external_id:

https://BASE_URL/api/VERSION/discountLists/reference/{id}

Method: POST

Request content type: application/json

Parameters:

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