Megaventory API v2017a

<back to all web services

DiscountUpdate

The following routes are available for this service:
POST/Discount/DiscountUpdateInserts a discount or updates a current discount.Uses your API Key and applies a mvRecordAction value on an mvDiscount object. We can insert the mvDiscount object we specified using "Insert" as our mvRecordAction. We can update a current discount using "Update", we can insert a discount if it doesn't already exist, update a discount if it does exist using "InsertOrUpdate" and we can insert new fields or update non-empty fields of the discount using "InsertOrUpdateNonEmptyFields". Optionally, you can use mvInsertUpdateDeleteSourceApplication when an external application ( eg Magento ) is the one that triggers the DiscountUpdate call. Only the DiscountDescription can be changed during the update.

Examples:



A.

Insert a discount.

Value:

{
           "mvDiscount": {
              "DiscountID": 9,
              "DiscountName": "Summer Discount",
              "DiscountDescription": "Time for a swim",
              "DiscountValue": 4
           },
           "mvRecordAction": "Insert",
           "mvInsertUpdateDeleteSourceApplication": "WooCommerce"
        }


Response:

 {
           "mvDiscount": {
              "DiscountID": 9,
              "DiscountName": "Summer Discount",
              "DiscountDescription": "Time for a swim",
              "DiscountValue": 4
           },
           "ResponseStatus": {
              "ErrorCode": "0"
           },
           "entityID": 9
        } 

B.



Lets try to change the value and the name of a discount.

Value:

{
           "mvDiscount": {
              "DiscountID": 9,
              "DiscountName": "Start of Summer season",
              "DiscountValue": 7.5
           },
           "mvRecordAction": "InsertOrUpdate"
        }


Response:

 {
           "ResponseStatus": {
              "ErrorCode": "500",
              "Message": "Only the DiscountDescription can be changed during the update. Update Failed"
           },
           "entityID": 0,
           "InternalErrorCode": "OnlyDiscountDescriptionUpdatable"
        }

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

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

POST /json/reply/DiscountUpdate HTTP/1.1 
Host: api.megaventory.com 
Content-Type: application/json
Content-Length: length

{"APIKEY":"String","mvDiscount":{"DiscountID":0,"DiscountName":"String","DiscountDescription":"String","DiscountValue":0.00},"mvRecordAction":"Insert","mvInsertUpdateDeleteSourceApplication":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"mvDiscount":{"DiscountID":0,"DiscountName":"String","DiscountDescription":"String","DiscountValue":0.00},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String"}]},"entityID":0,"InternalErrorCode":"String"}