8 API Reference‎ > ‎Resources‎ > ‎

Order

NOTE: Used only in Distribution API.

Order represents orders made by consumers in consumer facing applications. There is some difference in orders workflow for different offer types. For digital offers such as deals and gift cards the system returns vouchers as a result of order placement.

Attributes:
  • id string.
  • order_number string.
  • status string. "active" or "cancelled".
  • items OrderItem.
  • account_id string.
  • customer_name string.
  • purchased_at time.
  • shipping_address Location.
  • shipments list of Shipment.
  • application_id string (for standalone applications like plugins).

Data Example

JSON

{
    "id": "",
    "order_number": "",
    "status": "",
    "items": [OrderItem, ...],
    "account_id": "",
    "customer_name": "",
    "purchased_at": "",
    "shipping_address": {"
             address_line_1": "",

            "address_line_2": "",
            "city": "",
            "state_code": "",
            "postal_code": ""
    },
    "shipments": [Shipment, ...]
}

XML

<order>
    <id></id>
    <order_number></order_number>
    <status></status>
    <items>
        <item>OrderItem</item>
        ...
    </items>
    <account_id></account_id>
    <customer_name></customer_name>
    <purchased_at></purchased_at>
    <shipping_address>
   
    <address_line_1></address_line_1>
        <address_line_2></address_line_2>
        <city></city>
        <state_code></state_code>
        <postal_code></postal_code>
    </shipping_address>
    <shipments>Shipment</shipments>
</order>

Actions

Place Order

Placing new orders is most common Order object operation. For “deal” type offers the only required attributes for placing an order are valid customer name, unique order_number and offer_id/quantity combination for each order item.

As a reply for “place order” request you’ll receive order object. It’ll also have vouchers section filled if you ordered “deal” type offers.

Request type: POST
Resource URI: /orders
Sample URL: http://testapi.adility.com/distribution/beta/orders

Sample CURL requests (“deal” type offer)

JSON
curl -k -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your key>" 'http://testapi.adility.com/distribution/beta/orders' -d '{"order":{"order_number": "<order number>", "customer_name": "John Smith", "items": [{"offer_id": "<id string>", "quantity": 2}] } }'

XML
curl -k -X POST -H "Content-Type: application/xml" -H "Accept: application/xml" -H "X-ADILITY-API-KEY: <your key>" 'http://testapi.adility.com/distribution/beta/orders' -d '<?xml version="1.0" encoding="UTF-8" ?>
<order>
<order_number>myuniqueordernumber000</order_number>
<customer_name>John Smith</customer_name>
<items>
<item>
<offer_id>[valid offer id]</offer_id>
<quantity>2</quantity>
</item>
</items>
</order>'

Get Order Details

Getting order details. This operation is usually used for checking order status.

Request type: GET
Resource URI: /orders/<id>
Sample URL: http://testapi.adility.com/distribution/beta/orders/<order id>

JSON
curl -k -X GET -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your key>" 'http://testapi.adility.com/distribution/beta/orders/<order id>'

XML
curl -k -X GET -H "Content-Type: application/xml" -H "Accept: application/xml" -H "X-ADILITY-API-KEY: <your key>" 'http://testapi.adility.com/distribution/beta/orders/<order id>'

Cancel Order

This operation will cancel an order with all its vouchers. Technically order cancellation is just sending updated order status.

Request type: PUT
Resource URI: /orders/<id>
Sample URL: http://testapi.adility.com/distribution/beta/orders/<id>

JSON
curl -k -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your key>" "http://testapi.adility.com/distribution/beta/orders/<order id>" -d '{"order": {"status": "cancelled"}}'

XML
curl -k -X PUT -H "Content-Type: application/json" -H "Accept: application/json" -H "X-ADILITY-API-KEY: <your key>" "http://testapi.adility.com/distribution/beta/orders/<order id>" -d '<?xml version="1.0" encoding="UTF-8" ?>
<order>
<status>cancelled</status>
</order>'

Related resources
Offer, Voucher, Shipment

Comments