Megaventory API v2017a

<back to all web services

DiscountUndelete

The following routes are available for this service:
POST/Discount/DiscountUndeleteUndeletes a discountUses your API Key and the ID of the discount you want to undelete (DiscountIDToUndelete) the specified discount if it exists.

Examples:



A.

Undelete a discount.

To begin with, we use DiscountGet to see all of our existing discounts as shown below:

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


Then we decide to remove the Halloween discount from our list of discounts.

Value:

{
       "DiscountIDToDelete": 354
    } 


Response:

 {
       "result": true,
       "ResponseStatus": {
          "ErrorCode": "0"
       }
    }

Now the list with the existing discounts.

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": 346,
             "DiscountName": "discount",
             "DiscountDescription": "",
             "DiscountValue": 10
          }
       ],
       "ResponseStatus": {
          "ErrorCode": "0"
       }
    } 


Then we decide to reset the Halloween discount from our list of discounts.

Value:

{
       "DiscountIDToUnDelete": 354
    } 


Response:

 {
       "result": true,
       "ResponseStatus": {
          "ErrorCode": "0"
       }
    }

Then we decide to remove the Halloween discount from our list of discounts.

B.

Trying to undelete a discount that does not exist.

Value:

{
       "DiscountIDToUnDelete": 11
    } 


Response:

{
       "result": false,
       "ResponseStatus": {
          "ErrorCode": "500",
          "Message": "The Discount with ID [11] does not exist. Undelete failed"
       },
       "InternalErrorCode": "DiscountNotExists"
    } 

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

HTTP + XML

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

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

<DiscountUndelete xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Megaventory.APIEndpoints.Operations">
  <APIKEY>String</APIKEY>
  <DiscountIDToUndelete>0</DiscountIDToUndelete>
</DiscountUndelete>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<DiscountUndeleteResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Megaventory.APIEndpoints.Operations">
  <result>false</result>
  <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>
</DiscountUndeleteResponse>