Orders-orderId-account-products:POST

(Difference between revisions)
Jump to: navigation, search
m (1 revision: Release 98)
(POST /orders/{orderId}/account/products)
Line 28: Line 28:
 
   "promoCode": "{promoCode}",
 
   "promoCode": "{promoCode}",
 
   "displayName": "My custom product name",
 
   "displayName": "My custom product name",
   "partnerId": "Partner purchased plan Id",
+
   "partnerId": "PartnerId",
 
}
 
}
 
  </nowiki>
 
  </nowiki>
Line 40: Line 40:
 
: A custom display name for the product.
 
: A custom display name for the product.
 
; partnerId - ''string'' (optional)
 
; partnerId - ''string'' (optional)
: Partner purchased  plan id.
+
: Partner id.
  
 
=== 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.
Line 61: Line 61:
 
| The operation was successfully completed.
 
| The operation was successfully completed.
 
|-
 
|-
| rowspan="6"| 400 Bad Request
+
| rowspan="8"| 400 Bad Request
 
| POST data error
 
| POST data error
| Trying to create a product without passing offerings
+
| 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 with passing fake offering
+
| Trying to create a product by passing fake offering.
 
|-
 
|-
 
| Invalid offering URI
 
| Invalid offering URI
Line 72: Line 72:
 
|-
 
|-
 
| 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 {productId} with FAKE while account uses USD
+
| Trying to add inconsistent currency: product {product} with FAKE while account uses USD
| Trying to create a product with invalid currency
+
| Trying to create a product with currency, which does not match the account's currency
 
|-
 
|-
| Trying to add Internal product {productId} without authorization
+
| Currency FAKE not allowed for this franchise
| Trying to add product, marked as internal, without the proper credentials.
+
| 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.
 
|-
 
|-
 
| 401 Unauthorized
 
| 401 Unauthorized
Line 84: Line 90:
 
| The ''OwnerId'' cookie was not specified or is incorrect.
 
| The ''OwnerId'' cookie was not specified or is incorrect.
 
|-
 
|-
| 403 Unauthorized
+
| 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 get the products for non existing order.
+
| 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 112:
 
201 Created
 
201 Created
 
{
 
{
   "url" : "</nowiki>{{APIBaseURL}}<nowiki>/orders/{orderId}/account/products/{productId}/"
+
  "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 core.plangroup.dedserver.plan4 without authorization",
+
         "message": "Trying to add Internal product {product} without authorization",
 
         "code": 400,
 
         "code": 400,
 
         "details": ""
 
         "details": ""
Line 116: Line 129:
 
}
 
}
  
 +
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 151:
 
}
 
}
  
 +
400 Bad Request - trying to add a product that does not exist.
 
{
 
{
 
     "computeFault":{
 
     "computeFault":{
Line 136: Line 161:
 
}
 
}
  
 +
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 171:
 
}
 
}
  
 +
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": "5f5e84eb-d52b-4430-94bd-68093860b4d8",
+
         "guid": "742e193a-4667-47fd-a5ff-ec1f7788d459",
         "message": "The requested offering is invalid",
+
         "message": "Trying to add inconsistent currency: product {product} with FAKE while account uses USD",
 
         "code": 400,
 
         "code": 400,
 
         "details": ""
 
         "details": ""
Line 154: Line 181:
 
}
 
}
  
 +
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": {
 
     "computeFault": {
         "guid": "742e193a-4667-47fd-a5ff-ec1f7788d459",
+
         "guid": "3ee2bd37-81ee-4a57-bd63-dc84705b3985",
         "message": "Trying to add inconsistent currency: product core.plangroup.dedserver.plan4 with FAKE while account uses USD",
+
         "message": "Currency FAKE not allowed for this franchise",
 
         "code": 400,
 
         "code": 400,
 
         "details": ""
 
         "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": ""
 
     }
 
     }
 
}</nowiki>
 
}</nowiki>
Line 169: Line 206:
  
 
  <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 224:
 
         "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>

Revision as of 08:58, 1 October 2014

POST /orders/{orderId}/account/products

Adds a new 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

{
  "offering": "https://api.hostway.com/productSpecifications/{productSpecificationId}/offerings/{productOfferingId}",
  "promoCode": "{promoCode}",
  "displayName": "My custom product name",
  "partnerId": "PartnerId",
}
 

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.

Validation Rules

  1. The product specification URL ( https://api.hostway.com/productSpecifications/{productSpecificationId} ) should point to an existing product.
  2. The product offering currency should match the account currency or if no account is specified should be allowed for the franchise.
  3. The product offering URL ( https://api.hostway.com/productSpecifications/{productSpecificationId}/offerings/{productOfferingId} ) should point to an existing product offering.
  4. The product use type (public, internal, internal view only, etc.) should be allowed for the current user.
  5. The product offering should be valid according to the back-end.

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.
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": ""
    }
}
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


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox