Orders-orderId-account-products-productId-discounts:GET
From Hostway API Documentation
Revision as of 07:51, 15 September 2014 by Mike.robski (Talk | contribs)
GET /orders/{orderId}/account/products/{productId}/discounts
Get discounts that were added at the Product level.
Contents |
Request
GET /orders/{orderId}/account/products/{productId}/discounts
Request Parameters
- orderId - string
- The unique order Id. The URI of the order is returned by the POST /orders call.
- productId - string
- UUID specifying the product for which actions are to be preformed
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. |
Product could not be found. | ||
502 Bad Gateway | - | Unexpected backend response. Cannot retrieve product discounts. |
Response Body
{ "discounts": [ { "priceName": "recurring", "recurrences": -1, "type": "amount", "value": "1.00" } ], "links": [ { "href": "https://api.hostway.com/orders/{orderId}/account/product/{productId}/discounts", "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}/account/products/{productId}/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" : "http://coreapi01.ote.chicago.hostway:8092/orders/00000148598765a3088232de007f000000010001/account/products/000001485988d9197a607491007f000000010001/discounts/", "rel" : "self" } ] }
Missing authorization
Request
GET /orders/{orderId}/account/products/{productId}/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}/account/products/{productId}/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}/account/products/{productId}/discounts Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch Cookie: OwnerId={owner_id}; Path=/
Response
404 Not Found Content-Type : application/json; charset=UTF-8 { "itemNotFound" : { "guid" : "4383366c-845c-4311-97ee-9dd7d7d0045b", "message" : "Resource not found", "code" : 404, "details" : "" } }
Product could not be found
Request
GET /orders/{orderId}/account/products/{non-existent_productId}/discounts Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch Cookie: OwnerId={owner_id}; Path=/
Response
404 Not Found Content-Type : application/json; charset=UTF-8 { "itemNotFound" : { "guid" : "40caab58-6c0b-4056-97eb-2219afe92ec1", "message" : "Resource not found", "code" : 404, "details" : "" } }
See also