Orders-orderId-account-products:POST
From Hostway API Documentation
(Difference between revisions)
Mike.robski (Talk | contribs) m (1 revision: Release 98) |
Mike.robski (Talk | contribs) m (1 revision: Release 101) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
= POST /orders/''{orderId}''/account/products = | = POST /orders/''{orderId}''/account/products = | ||
− | Adds a new Product to the Account's Order. | + | Adds a new or existing Product to the Account's Order. |
If, at the time the product is created, there is not yet an Account in the order, then this call will implicitly add a very rudimentary Account (containing only a default language & the currency of this product). | If, at the time the product is created, there is not yet an Account in the order, then this call will implicitly add a very rudimentary Account (containing only a default language & the currency of this product). | ||
Line 23: | Line 23: | ||
=== Request Body === | === Request Body === | ||
+ | There are two possible formats. To add a new product that does not already exist: | ||
<nowiki> | <nowiki> | ||
{ | { | ||
Line 28: | Line 29: | ||
"promoCode": "{promoCode}", | "promoCode": "{promoCode}", | ||
"displayName": "My custom product name", | "displayName": "My custom product name", | ||
− | "partnerId": " | + | "partnerId": "PartnerId", |
− | } | + | }</nowiki> |
− | </nowiki> | + | |
+ | OR | ||
+ | |||
+ | To specify an existing product, use the following: | ||
+ | <nowiki> | ||
+ | { | ||
+ | "existingProductUrl": "</nowiki>{{APIBaseURL}}<nowiki>/accounts/{accountId}/products/{productId}" | ||
+ | }</nowiki> | ||
==== Parameters ==== | ==== Parameters ==== | ||
Line 40: | Line 48: | ||
: A custom display name for the product. | : A custom display name for the product. | ||
; partnerId - ''string'' (optional) | ; partnerId - ''string'' (optional) | ||
− | : Partner | + | : Partner id. |
+ | ; existingProductUrl - ''string'' | ||
+ | : Link to [[Account#Products_Management|an existing product]]. Only required when adding an existing product to the order. | ||
=== Validation Rules === | === Validation Rules === | ||
:# The product specification URL ( ''{{APIBaseURL}}/productSpecifications/{productSpecificationId}'' ) should point to an existing product. | :# The product specification URL ( ''{{APIBaseURL}}/productSpecifications/{productSpecificationId}'' ) should point to an existing product. | ||
− | :# The product offering currency should match the account currency. | + | :# The product offering currency should match the account currency or if no account is specified should be allowed for the franchise. |
:# The product offering URL ( ''{{APIBaseURL}}/productSpecifications/{productSpecificationId}/offerings/{productOfferingId}'' ) should point to an existing product offering. | :# The product offering URL ( ''{{APIBaseURL}}/productSpecifications/{productSpecificationId}/offerings/{productOfferingId}'' ) should point to an existing product offering. | ||
:# The product use type (public, internal, internal view only, etc.) should be allowed for the current user. | :# The product use type (public, internal, internal view only, etc.) should be allowed for the current user. | ||
:# The product offering should be valid according to the back-end. | :# The product offering should be valid according to the back-end. | ||
+ | :# The account product URL ( ''{APIBaseURL}}/accounts/{accountId}/products/{productId}'' ) should point to an existing product that is open and belongs to the account. | ||
== Response == | == Response == | ||
Line 61: | Line 72: | ||
| The operation was successfully completed. | | The operation was successfully completed. | ||
|- | |- | ||
− | | rowspan=" | + | | rowspan="12"| 400 Bad Request |
| POST data error | | POST data error | ||
− | | Trying to create a product | + | | Trying to create a product with invalid body. |
|- | |- | ||
| Cannot add non-existent product \"fake\" | | Cannot add non-existent product \"fake\" | ||
− | | Trying to create a product | + | | Trying to create a product by passing fake offering. |
|- | |- | ||
| Invalid offering URI | | Invalid offering URI | ||
Line 72: | Line 83: | ||
|- | |- | ||
| The requested offering is invalid | | The requested offering is invalid | ||
− | | Trying to create a product with invalid monthly cycle | + | | Trying to create a product with invalid monthly cycle (eg: 100) |
|- | |- | ||
− | | Trying to add inconsistent currency: product { | + | | Trying to add inconsistent currency: product {product} with FAKE while account uses USD |
− | | Trying to create a product with | + | | Trying to create a product with currency, which does not match the account's currency |
|- | |- | ||
− | | Trying to add Internal product { | + | | Currency FAKE not allowed for this franchise |
− | | Trying to add product, | + | | Trying to add a product with invalid for the franchise currency to an order for which no account has been set. |
+ | |- | ||
+ | | Trying to add Internal product {product} without authorization | ||
+ | | Trying to add product, which is internal, without the proper credentials. | ||
+ | |- | ||
+ | | Trying to add Internal View Only product {product} | ||
+ | | Trying to add product, which is internal view only, without the proper credentials. | ||
+ | |- | ||
+ | | Invalid product URI | ||
+ | | Tried to add an existing product with wrong existingProductUrl | ||
+ | |- | ||
+ | | The account of the order and the account of the product doesn't match | ||
+ | | Tried to add an existing product with account, which is different from the account of the order. | ||
+ | |- | ||
+ | | Product doesn't exist. | ||
+ | | Tried to add an existing product which does not exist | ||
+ | |- | ||
+ | | Cannot add a product that is not open. | ||
+ | | Tried to add an existing product that is not open. | ||
|- | |- | ||
| 401 Unauthorized | | 401 Unauthorized | ||
Line 84: | Line 113: | ||
| The ''OwnerId'' cookie was not specified or is incorrect. | | The ''OwnerId'' cookie was not specified or is incorrect. | ||
|- | |- | ||
− | | 403 | + | | 403 Forbidden |
− | | | + | | Unauthorized: Products failed permission check |
| The client does not have permissions to add products. | | The client does not have permissions to add products. | ||
|- | |- | ||
| 404 Not Found | | 404 Not Found | ||
| Resource not found | | Resource not found | ||
− | | The client is trying to | + | | The client is trying to add a product to non existing order. |
+ | |- | ||
+ | | 502 Bad Gateway | ||
+ | | - | ||
+ | | Unexpected backend response. | ||
|} | |} | ||
=== Response Headers === | === Response Headers === | ||
; Location | ; Location | ||
− | : Returned with successful response. Contains the URI of the newly added product. | + | : Returned with successful response. Contains the URI of the newly added product and the id of the product. |
=== Response Body === | === Response Body === | ||
Line 102: | Line 135: | ||
201 Created | 201 Created | ||
{ | { | ||
− | "url" : "</nowiki>{{APIBaseURL}}<nowiki>/orders/ | + | "productId": "00000148842a5f6448a61ce6007f000000010001", |
+ | "url" : "</nowiki>{{APIBaseURL}}<nowiki>/orders/0000014884293798c68eafa5007f000000010001/account/products/00000148842a5f6448a61ce6007f000000010001/" | ||
}</nowiki> | }</nowiki> | ||
+ | : '''''Note:''''' The product Id will change once the order is provisioned. | ||
==== Error responses ==== | ==== Error responses ==== | ||
<nowiki> | <nowiki> | ||
+ | 400 Bad Request - trying to order product, which is internal, without the proper authorization. | ||
{ | { | ||
"computeFault": { | "computeFault": { | ||
"guid": "c940c886-5343-4a49-b728-0b94cbb1a3e9", | "guid": "c940c886-5343-4a49-b728-0b94cbb1a3e9", | ||
− | "message": "Trying to add Internal product | + | "message": "Trying to add Internal product {product} without authorization", |
"code": 400, | "code": 400, | ||
"details": "" | "details": "" | ||
Line 116: | Line 152: | ||
} | } | ||
+ | 400 Bad Request - trying to add a product, which is internal view only, such products cannot be added via the Public API. | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "3ee2bd37-81ee-4a57-bd63-dc84705b3985", | ||
+ | "message": "Trying to add Internal View Only product {product}", | ||
+ | "code": 400, | ||
+ | "details": "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 400 Bad Request - trying to add a product without supplying the required attributes in the body. | ||
{ | { | ||
"badRequest":{ | "badRequest":{ | ||
Line 127: | Line 174: | ||
} | } | ||
+ | 400 Bad Request - trying to add a product that does not exist. | ||
{ | { | ||
"computeFault":{ | "computeFault":{ | ||
Line 136: | Line 184: | ||
} | } | ||
+ | 400 Bad Request - trying to add a product by supplying invalid offering URI (eg: "offering": "http://coreapi01.ote.chicago.hostway:8092/productSpecifications/core.plangroup.dedserver.plan4/offerings/") | ||
{ | { | ||
"computeFault": { | "computeFault": { | ||
Line 145: | Line 194: | ||
} | } | ||
+ | 400 Bad Request - trying to add a product with invalid currency (case when account is set and the currency provided does not match the account's currency) | ||
{ | { | ||
"computeFault": { | "computeFault": { | ||
− | "guid": " | + | "guid": "742e193a-4667-47fd-a5ff-ec1f7788d459", |
+ | "message": "Trying to add inconsistent currency: product {product} with FAKE while account uses USD", | ||
+ | "code": 400, | ||
+ | "details": "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 400 Bad Request - trying to add a product with invalid for the franchise currency (case when an account is not set so the currency it is determined by the first added product, but the currency is not allowed for the franchise) | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "3ee2bd37-81ee-4a57-bd63-dc84705b3985", | ||
+ | "message": "Currency FAKE not allowed for this franchise", | ||
+ | "code": 400, | ||
+ | "details": "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 400 Bad Request - trying to add a product with invalid month cycle (eg: 100) | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "8165a0b2-80f5-436f-ab47-075d824144d9", | ||
"message": "The requested offering is invalid", | "message": "The requested offering is invalid", | ||
"code": 400, | "code": 400, | ||
Line 154: | Line 224: | ||
} | } | ||
+ | 400 Bad Request - trying to add an existing product with invalid existingProductUrl | ||
{ | { | ||
"computeFault": { | "computeFault": { | ||
− | "guid": " | + | "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", |
− | "message": " | + | "message": "Invalid product URI", |
+ | "code": 400, | ||
+ | "details": "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 400 Bad Request - trying to add an existing product that belongs to account different from the account of the order. | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
+ | "message": "The account of the order and the account of the product doesn't match", | ||
+ | "code": 400, | ||
+ | "details": "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 400 Bad Request - trying to add an existing product that does not exist | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
+ | "message": "Product doesn't exist.", | ||
+ | "code": 400, | ||
+ | "details": "" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | 400 Bad Request - trying to add an existing product that is not open | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
+ | "message": "Cannot add a product that is not open.", | ||
"code": 400, | "code": 400, | ||
"details": "" | "details": "" | ||
Line 169: | Line 270: | ||
<nowiki> | <nowiki> | ||
− | 404 Not Found | + | 403 Forbidden - the client does not have permission to add products. |
+ | { | ||
+ | "forbidden": { | ||
+ | "guid": "d336dd8e-bc52-44f3-b672-9aa2fac7fbf4", | ||
+ | "message": "Unauthorized: Products failed permission check", | ||
+ | "code": 403, | ||
+ | "details": "" | ||
+ | } | ||
+ | }</nowiki> | ||
+ | |||
+ | <nowiki> | ||
+ | 404 Not Found - the order does not exist | ||
{ | { | ||
"itemNotFound": { | "itemNotFound": { | ||
Line 176: | Line 288: | ||
"code": 404, | "code": 404, | ||
"details": "" | "details": "" | ||
+ | } | ||
+ | }</nowiki> | ||
+ | |||
+ | <nowiki> | ||
+ | 502 Bad Gateway - unexpected error from the backend. | ||
+ | { | ||
+ | "computeFault": { | ||
+ | "guid": "8ced5fe7-f6a9-4e8f-8700-cfc9fa15e6ce", | ||
+ | "timestamp": "2014-09-10 20:59:50", | ||
+ | "code": 502, | ||
+ | "errorRefId": "8ced5fe7-f6a9-4e8f-8700-cfc9fa15e6ce" | ||
} | } | ||
}</nowiki> | }</nowiki> |
Latest revision as of 22:49, 16 December 2014
POST /orders/{orderId}/account/products
Adds a new or existing Product to the Account's Order.
If, at the time the product is created, there is not yet an Account in the order, then this call will implicitly add a very rudimentary Account (containing only a default language & the currency of this product).
If there is already an Account in the order at the time this call is made, the currency of the specified product offering *must* match the currency of the Account.
Contents |
Request
POST /orders/{orderId}/account/products
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
- Content-Type
- Required. Set this header to
application/json; charset=UTF-8
- 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.
Request Body
There are two possible formats. To add a new product that does not already exist:
{ "offering": "https://api.hostway.com/productSpecifications/{productSpecificationId}/offerings/{productOfferingId}", "promoCode": "{promoCode}", "displayName": "My custom product name", "partnerId": "PartnerId", }
OR
To specify an existing product, use the following:
{ "existingProductUrl": "https://api.hostway.com/accounts/{accountId}/products/{productId}" }
Parameters
- offering - string
- Link to the product catalog offering specifying the new product.
- promoCode - string (optional)
- A promotion code for the new product promotion codes.
- displayName - string (optional)
- A custom display name for the product.
- partnerId - string (optional)
- Partner id.
- existingProductUrl - string
- Link to an existing product. Only required when adding an existing product to the order.
Validation Rules
- The product specification URL ( https://api.hostway.com/productSpecifications/{productSpecificationId} ) should point to an existing product.
- The product offering currency should match the account currency or if no account is specified should be allowed for the franchise.
- The product offering URL ( https://api.hostway.com/productSpecifications/{productSpecificationId}/offerings/{productOfferingId} ) should point to an existing product offering.
- The product use type (public, internal, internal view only, etc.) should be allowed for the current user.
- The product offering should be valid according to the back-end.
- The account product URL ( {APIBaseURL}}/accounts/{accountId}/products/{productId} ) should point to an existing product that is open and belongs to the account.
Response
Status Code
Status Code | Error Message | Description |
---|---|---|
201 Created | - | The operation was successfully completed. |
400 Bad Request | POST data error | Trying to create a product with invalid body. |
Cannot add non-existent product \"fake\" | Trying to create a product by passing fake offering. | |
Invalid offering URI | Trying to create a product by passing invalid offering (missing currency, monthly cycle or productSpecifications) | |
The requested offering is invalid | Trying to create a product with invalid monthly cycle (eg: 100) | |
Trying to add inconsistent currency: product {product} with FAKE while account uses USD | Trying to create a product with currency, which does not match the account's currency | |
Currency FAKE not allowed for this franchise | Trying to add a product with invalid for the franchise currency to an order for which no account has been set. | |
Trying to add Internal product {product} without authorization | Trying to add product, which is internal, without the proper credentials. | |
Trying to add Internal View Only product {product} | Trying to add product, which is internal view only, without the proper credentials. | |
Invalid product URI | Tried to add an existing product with wrong existingProductUrl | |
The account of the order and the account of the product doesn't match | Tried to add an existing product with account, which is different from the account of the order. | |
Product doesn't exist. | Tried to add an existing product which does not exist | |
Cannot add a product that is not open. | Tried to add an existing product that is not open. | |
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. | The OwnerId cookie was not specified or is incorrect. |
403 Forbidden | Unauthorized: Products failed permission check | The client does not have permissions to add products. |
404 Not Found | Resource not found | The client is trying to add a product to non existing order. |
502 Bad Gateway | - | Unexpected backend response. |
Response Headers
- Location
- Returned with successful response. Contains the URI of the newly added product and the id of the product.
Response Body
Successful response
201 Created { "productId": "00000148842a5f6448a61ce6007f000000010001", "url" : "https://api.hostway.com/orders/0000014884293798c68eafa5007f000000010001/account/products/00000148842a5f6448a61ce6007f000000010001/" }
- Note: The product Id will change once the order is provisioned.
Error responses
400 Bad Request - trying to order product, which is internal, without the proper authorization. { "computeFault": { "guid": "c940c886-5343-4a49-b728-0b94cbb1a3e9", "message": "Trying to add Internal product {product} without authorization", "code": 400, "details": "" } } 400 Bad Request - trying to add a product, which is internal view only, such products cannot be added via the Public API. { "computeFault": { "guid": "3ee2bd37-81ee-4a57-bd63-dc84705b3985", "message": "Trying to add Internal View Only product {product}", "code": 400, "details": "" } } 400 Bad Request - trying to add a product without supplying the required attributes in the body. { "badRequest":{ "guid": "0f3e0435-21ac-43e5-acfd-ac33886fbe70", "message": "POST data error", "code": 400, "details": { "offering": "Required" } } } 400 Bad Request - trying to add a product that does not exist. { "computeFault":{ "guid": "12cf7a72-3261-4c57-a82e-1f2f1c124d50", "message": "Cannot add non-existent product \"fake\"", "code": 400, "details": "" } } 400 Bad Request - trying to add a product by supplying invalid offering URI (eg: "offering": "http://coreapi01.ote.chicago.hostway:8092/productSpecifications/core.plangroup.dedserver.plan4/offerings/") { "computeFault": { "guid": "0ced627e-c9fc-4835-92da-1a4256165607", "message": "Invalid offering URI", "code": 400, "details": "" } } 400 Bad Request - trying to add a product with invalid currency (case when account is set and the currency provided does not match the account's currency) { "computeFault": { "guid": "742e193a-4667-47fd-a5ff-ec1f7788d459", "message": "Trying to add inconsistent currency: product {product} with FAKE while account uses USD", "code": 400, "details": "" } } 400 Bad Request - trying to add a product with invalid for the franchise currency (case when an account is not set so the currency it is determined by the first added product, but the currency is not allowed for the franchise) { "computeFault": { "guid": "3ee2bd37-81ee-4a57-bd63-dc84705b3985", "message": "Currency FAKE not allowed for this franchise", "code": 400, "details": "" } } 400 Bad Request - trying to add a product with invalid month cycle (eg: 100) { "computeFault": { "guid": "8165a0b2-80f5-436f-ab47-075d824144d9", "message": "The requested offering is invalid", "code": 400, "details": "" } } 400 Bad Request - trying to add an existing product with invalid existingProductUrl { "computeFault": { "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "message": "Invalid product URI", "code": 400, "details": "" } } 400 Bad Request - trying to add an existing product that belongs to account different from the account of the order. { "computeFault": { "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "message": "The account of the order and the account of the product doesn't match", "code": 400, "details": "" } } 400 Bad Request - trying to add an existing product that does not exist { "computeFault": { "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "message": "Product doesn't exist.", "code": 400, "details": "" } } 400 Bad Request - trying to add an existing product that is not open { "computeFault": { "guid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "message": "Cannot add a product that is not open.", "code": 400, "details": "" } }
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.
403 Forbidden - the client does not have permission to add products. { "forbidden": { "guid": "d336dd8e-bc52-44f3-b672-9aa2fac7fbf4", "message": "Unauthorized: Products failed permission check", "code": 403, "details": "" } }
404 Not Found - the order does not exist { "itemNotFound": { "guid": "e1792d8a-5b0a-43ef-adf5-34a0710c8fc5", "message": "Resource not found", "code": 404, "details": "" } }
502 Bad Gateway - unexpected error from the backend. { "computeFault": { "guid": "8ced5fe7-f6a9-4e8f-8700-cfc9fa15e6ce", "timestamp": "2014-09-10 20:59:50", "code": 502, "errorRefId": "8ced5fe7-f6a9-4e8f-8700-cfc9fa15e6ce" } }
See also