GET POST | /Discount/DiscountGet | Gets information on existing discounts | Uses your API Key and some Filters in an array format and returns the search results using given filters.
Optionally, you can use ReturnTopNRecords to limit the number of the results to the specified number (omit, or add ReturnTopNRecords = -1 to get all the available results). The ReturnTopNRecords chooses the top records in a DiscountID descending order.
A. Get all the existing discounts (as mvDiscounts objects).
Value: {}
Response: {
"mvDiscounts": [
{
"DiscountID": 358,
"DiscountName": "End of season",
"DiscountDescription": "",
"DiscountValue": 12.5
},
{
"DiscountID": 357,
"DiscountName": "Start of season",
"DiscountDescription": "",
"DiscountValue": 7.5
},
{
"DiscountID": 356,
"DiscountName": "End of season",
"DiscountDescription": "",
"DiscountValue": 7.5
},
{
"DiscountID": 355,
"DiscountName": "Easter Festivities",
"DiscountDescription": "",
"DiscountValue": 16.5
},
{
"DiscountID": 354,
"DiscountName": "Halloween Discount",
"DiscountDescription": "Halloween Festivities",
"DiscountValue": 16.5
},
{
"DiscountID": 346,
"DiscountName": "discount",
"DiscountDescription": "",
"DiscountValue": 10
}
],
"ResponseStatus": {
"ErrorCode": "0"
}
}
B.
Returns the first 2 mvDiscount objects with DiscountValue greater than 5 whose name contains the word "season".
We can add two Filters by using the AndOr operator as shown below:
Value: {
"Filters": [
{
"FieldName": "DiscountValue",
"SearchOperator": "GreaterThan",
"SearchValue": 5
},
{
"AndOr": "And",
"FieldName": "DiscountName",
"SearchOperator": "Contains",
"SearchValue": "season"
}
],
"ReturnTopNRecords": 2
}
Response: {
"mvDiscounts": [
{
"DiscountID": 358,
"DiscountName": "End of season",
"DiscountDescription": "",
"DiscountValue": 12.5
},
{
"DiscountID": 357,
"DiscountName": "Start of season",
"DiscountDescription": "",
"DiscountValue": 7.5
}
],
"ResponseStatus": {
"ErrorCode": "0"
}
}
As we can see, the 356 discount was not returned because the ReturnTopNRecords chooses the top records in a DiscountID descending order. |
---|