Orders-orderId-discounts:GET

From Hostway API Documentation
Revision as of 09:50, 10 September 2014 by Pa.dinh (Talk)
Jump to: navigation, search

GET /orders/{orderId}/discounts

Get discounts that were added at the Order level. Discounts that are applied to an entire order will be applied to all of the product and services within the order.

Contents


Request

GET /orders/{orderId}/discounts

Request Parameters

orderId - string
The unique order Id. The URI of the order is returned by the POST /orders call.

URI Parameters

None.

Request Headers

Cookie
A cookie named OwnerId to identify the client (for most browser clients, the browser will do this automatically, depending on the browser configuration). The value of the cookie would come from the response to the create order request in the Set-Cookie response header.

Response

Status Code

Status Code Error Message Description
200 OK - The request was executed successfully.
401 Unauthorized - The request was not properly authorized.
403 Forbidden Unauthorized: DiscountsView failed permission check The client does not have sufficient privileges.
404 Not Found Resource not found Order does not exist.
502 Bad Gateway - Unexpected backend response. Cannot retrieve order discounts.

Response Body

{
  "discounts": [
    {
      "priceName": "recurring",
      "recurrences": -1,
      "type": "amount",
      "value": "1.00"
    }
  ],
  "links": [
    {
      "href": "https://api.hostway.com/orders/{orderId}/account/user/",
      "rel": "self"
    }
  ]
}
 

Parameters

discounts - list
A list of discounts. Each discount contains the following:
priceName - string
The type of price to which the discount will be applied.
recurrences - integer
The number of times that the discount will be applied. A value of "-1" means the discount will be applied every time the fee is charged.
type - string
Specifies the discount type which determines the method used to calculate the amount that is discounted. Possible values are:
amount: Discount will be treated as an exact amount.
value - string
The discount amount. The value will be interpreted based on the specified discount type.
links - list
Hypermedia for this resource. Links to self.


Example

Success

Request

GET /orders/{orderId}/discounts
Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch
Cookie: OwnerId={owner_id}; Path=/

Response

200 OK
Content-Type : application/json; charset=UTF-8

{
  "discounts": [
    {
      "priceName": "recurring",
      "type": "amount",
      "value": "5.00",
      "recurrences": -1
    }
  ],
  "links": [
    {
      "href": "https://api.hostway.com/orders/000001485584ddfe2c27d60a007f000000010001/discounts/",
      "rel": "self"
    }
  ]
}

Missing authorization

Request

GET /orders/{orderId}/discounts
Cookie: OwnerId={owner_id}; Path=/

Response

401 Unauthorized
Content-Type : text/plain; charset=UTF-8

401 Unauthorized

This server could not verify that you are authorized to access the document you requested.
Either you supplied the wrong credentials (e.g., bad password),
or your browser does not understand how to supply the credentials required.

Insuffucient privileges

Request

GET /orders/{orderId}/discounts
Authorization: Basic ZWdjUlBtZWZiWnJVQHNpdGVjb250cm9sX2hvc3R3YXlfdXNfbWFpbjpTdnVROGlWOUFTVTc0
Cookie: OwnerId={owner_id}; Path=/

Response

403 Forbidden
Content-Type : application/json; charset=UTF-8

{
  "forbidden": {
    "guid": "b5b513b8-8436-4eee-b49e-ac1d369a9d1b",
    "message": "Unauthorized: DiscountsView failed permission check",
    "code": 403,
    "details": ""
  }
}

Order does not exist

Request

GET /orders/{non-existent_orderId}/discounts
Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch
Cookie: OwnerId={owner_id}; Path=/

Response

404 Not Found
Content-Type : application/json; charset=UTF-8

{
  "itemNotFound": {
    "guid": "402282af-9f53-4973-8437-469087465843",
    "message": "Resource not found",
    "code": 404,
    "details": ""
  }
}

See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox