Orders-orderId-account-products-productId-discounts:GET

From Hostway API Documentation
(Difference between revisions)
Jump to: navigation, search
 
m (1 revision: Release 98)
 
(2 intermediate revisions by 2 users not shown)
Line 19: Line 19:
  
 
== Response ==
 
== Response ==
 
 
=== Status Code ===
 
=== Status Code ===
;200 OK
+
{| class='wikitable'
: The request was executed successfully.
+
|-
 
+
! Status Code
;401 Unauthorized
+
! Error Message
: The request was not properly authorized.
+
! Description
 
+
|-
;403 Forbidden
+
| 200 OK
: The client does not have sufficient privileges.
+
| align="center" | -
 
+
| The request was executed successfully.
;404 Not Found
+
|-
: Returned if the order could not be found.
+
| 401 Unauthorized
 +
| align="center" | -
 +
| The request was not properly authorized.
 +
|-
 +
| 403 Forbidden
 +
| Unauthorized: DiscountsView failed permission check
 +
| The client does not have sufficient privileges.
 +
|-
 +
| rowspan="2" | 404 Not Found
 +
| rowspan="2" | Resource not found
 +
| Order does not exist.
 +
|-
 +
| Product could not be found.
 +
|-
 +
| 502 Bad Gateway
 +
| align="center" | -
 +
| Unexpected backend response. Cannot retrieve product discounts.
 +
|}
  
 
=== Response Body ===
 
=== Response Body ===
Line 72: Line 88:
 
; links - ''list''
 
; links - ''list''
 
: [[Hypermedia]] for this resource. Links to self.
 
: [[Hypermedia]] for this resource. Links to self.
 +
 +
 +
== Example ==
 +
=== Success ===
 +
'''Request'''
 +
<nowiki>
 +
GET /orders/{orderId}/account/products/{productId}/discounts
 +
Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch
 +
Cookie: OwnerId={owner_id}; Path=/</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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"
 +
  } ]
 +
}</nowiki>
 +
 +
=== Missing authorization ===
 +
'''Request'''
 +
<nowiki>
 +
GET /orders/{orderId}/account/products/{productId}/discounts
 +
Cookie: OwnerId={owner_id}; Path=/</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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.</nowiki>
 +
 +
=== Insuffucient privileges ===
 +
'''Request'''
 +
<nowiki>
 +
GET /orders/{orderId}/account/products/{productId}/discounts
 +
Authorization: Basic ZWdjUlBtZWZiWnJVQHNpdGVjb250cm9sX2hvc3R3YXlfdXNfbWFpbjpTdnVROGlWOUFTVTc0
 +
Cookie: OwnerId={owner_id}; Path=/</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
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": ""
 +
  }
 +
}</nowiki>
 +
 +
=== Order does not exist ===
 +
'''Request'''
 +
<nowiki>
 +
GET /orders/{non-existent_orderId}/account/products/{productId}/discounts
 +
Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch
 +
Cookie: OwnerId={owner_id}; Path=/</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
404 Not Found
 +
Content-Type : application/json; charset=UTF-8
 +
 +
{
 +
  "itemNotFound" : {
 +
    "guid" : "4383366c-845c-4311-97ee-9dd7d7d0045b",
 +
    "message" : "Resource not found",
 +
    "code" : 404,
 +
    "details" : ""
 +
  }
 +
}</nowiki>
 +
 +
=== Product could not be found ===
 +
'''Request'''
 +
<nowiki>
 +
GET /orders/{orderId}/account/products/{non-existent_productId}/discounts
 +
Authorization: Basic dGVzdC52cGxleEBjb3JwX2xkYXBfc2VydmljZV9jaGk6VHJAcXNQODch
 +
Cookie: OwnerId={owner_id}; Path=/</nowiki>
 +
 +
'''Response'''
 +
<nowiki>
 +
404 Not Found
 +
Content-Type : application/json; charset=UTF-8
 +
 +
{
 +
  "itemNotFound" : {
 +
    "guid" : "40caab58-6c0b-4056-97eb-2219afe92ec1",
 +
    "message" : "Resource not found",
 +
    "code" : 404,
 +
    "details" : ""
 +
  }
 +
}</nowiki>
 +
  
 
== See also ==
 
== See also ==

Latest revision as of 08:51, 15 September 2014

[edit] GET /orders/{orderId}/account/products/{productId}/discounts

Get discounts that were added at the Product level.

Contents


[edit] Request

GET /orders/{orderId}/account/products/{productId}/discounts

[edit] 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

[edit] URI Parameters

None.

[edit] 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.

[edit] Response

[edit] 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.

[edit] 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"
    }
  ]
}
 

[edit] 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.


[edit] Example

[edit] 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"
  } ]
}

[edit] 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.

[edit] 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": ""
  }
}

[edit] 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" : ""
  }
}

[edit] 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" : ""
  }
}


[edit] See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox