Megaventory API v2017a

<back to all web services

DiscountGet

Gets information on existing discountsUses 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.

Examples:



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.

To override the Content-type in your clients HTTP Accept Header, append the .soap12 suffix or ?format=soap12

HTTP + SOAP12

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /soap12 HTTP/1.1 
Host: api.megaventory.com 
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>

<DiscountGet xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Megaventory.APIEndpoints.Operations">
  <Filters xmlns="http://schemas.datacontract.org/2004/07/Megaventory.APIEndpoints">
    <Filter>
      <AndOr>And</AndOr>
      <FieldName>String</FieldName>
      <Group>Undefined</Group>
      <SearchOperator>Undefined</SearchOperator>
      <SearchValue>String</SearchValue>
    </Filter>
  </Filters>
  <ReturnTopNRecords xmlns="http://schemas.datacontract.org/2004/07/Megaventory.APIEndpoints">0</ReturnTopNRecords>
  <APIKEY>String</APIKEY>
  <showDeleted>showOnlyUndeleted</showDeleted>
</DiscountGet>

    </soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>

<DiscountGetResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Megaventory.APIEndpoints.Operations">
  <mvDiscounts xmlns:d2p1="https://api.megaventory.com/types">
    <d2p1:mvDiscount>
      <d2p1:DiscountID>0</d2p1:DiscountID>
      <d2p1:DiscountName>String</d2p1:DiscountName>
      <d2p1:DiscountDescription>String</d2p1:DiscountDescription>
      <d2p1:DiscountValue>0.00</d2p1:DiscountValue>
    </d2p1:mvDiscount>
  </mvDiscounts>
  <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
    <d2p1:ErrorCode>String</d2p1:ErrorCode>
    <d2p1:Message>String</d2p1:Message>
    <d2p1:StackTrace>String</d2p1:StackTrace>
    <d2p1:Errors>
      <d2p1:ResponseError>
        <d2p1:ErrorCode>String</d2p1:ErrorCode>
        <d2p1:FieldName>String</d2p1:FieldName>
        <d2p1:Message>String</d2p1:Message>
      </d2p1:ResponseError>
    </d2p1:Errors>
  </ResponseStatus>
  <InternalErrorCode>String</InternalErrorCode>
</DiscountGetResponse>

    </soap12:Body>
</soap12:Envelope>