Orders-orderId-account-products:POST

(Difference between revisions)
Jump to: navigation, search
m (1 revision: Release 86)
(Status Code)
Line 26: Line 26:
 
{
 
{
 
   "offering": "</nowiki>{{APIBaseURL}}<nowiki>/productSpecifications/{productSpecificationId}/offerings/{productOfferingId}",
 
   "offering": "</nowiki>{{APIBaseURL}}<nowiki>/productSpecifications/{productSpecificationId}/offerings/{productOfferingId}",
   "promoCode": "{promoCode}"
+
   "promoCode": "{promoCode}",
 +
  "displayName": "My custom product name",
 +
  "partnerId": "Partner purchased plan Id",
 
}
 
}
 
  </nowiki>
 
  </nowiki>
Line 33: Line 35:
 
; offering - ''string''
 
; offering - ''string''
 
: Link to the [[Products#Product_Offerings|product catalog offering]] specifying the new product.
 
: Link to the [[Products#Product_Offerings|product catalog offering]] specifying the new product.
; promoCode - ''string''
+
; promoCode - ''string'' (optional)
 
: A promotion code for the new product [[Orders#Promotion_Codes|promotion codes]].
 
: A promotion code for the new product [[Orders#Promotion_Codes|promotion codes]].
 +
; displayName - ''string'' (optional)
 +
: A custom display name for the product.
 +
; partnerId - ''string'' (optional)
 +
: Partner purchased  plan id.
  
 
=== Validation Rules ===
 
=== Validation Rules ===
Line 46: Line 52:
  
 
=== Status Code ===
 
=== Status Code ===
;201 Created
+
{| class="wikitable"
: The product was successfully added to the order.
+
! Status Code
 
+
! Error Message
;400 Bad Request
+
! Description
: The request body contains invalid JSON or the values do not adhere to the restrictions set for them.
+
|-
 
+
| 201 Created
;401 Unauthorized
+
| -
: The ''OwnerId'' cookie was not specified or is incorrect.
+
| The operation was successfully completed.
 
+
|-
;403 Forbidden
+
| rowspan="6"| 400 Bad Request
: The client does not have permissions to add products.
+
| POST data error
 
+
| Trying to create a product without passing offerings
;404 Not Found
+
|-
: An account has not been added to the given order or the order does not exist.
+
| Cannot add non-existent product \"fake\"
 +
| Trying to create a product with 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
 +
|-
 +
| Trying to add inconsistent currency: product {productId} with FAKE while account uses USD
 +
| Trying to create a product with invalid currency
 +
|-
 +
| Trying to add Internal product {productId} without authorization
 +
| Trying to add product, marked as internal, 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 Unauthorized
 +
| -
 +
| The client does not have permissions to add products.
 +
|-
 +
| 404 Not Found
 +
| Resource not found
 +
| The client is trying to get the products for non existing order.
 +
|}
  
 
=== Response Headers ===
 
=== Response Headers ===
Line 66: Line 98:
  
 
=== Response Body ===
 
=== Response Body ===
None.
+
==== Successful response ====
 +
<nowiki>
 +
201 Created
 +
{
 +
  "url" : "</nowiki>{{APIBaseURL}}<nowiki>/orders/{orderId}/account/products/{productId}/"
 +
}</nowiki>
 +
 
 +
==== Error responses ====
 +
<nowiki>
 +
{
 +
    "computeFault": {
 +
        "guid": "c940c886-5343-4a49-b728-0b94cbb1a3e9",
 +
        "message": "Trying to add Internal product core.plangroup.dedserver.plan4 without authorization",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
 +
 
 +
{
 +
    "badRequest":{
 +
        "guid": "0f3e0435-21ac-43e5-acfd-ac33886fbe70",
 +
        "message": "POST data error",
 +
        "code": 400,
 +
        "details": {
 +
            "offering": "Required"
 +
        }
 +
    }
 +
}
 +
 
 +
{
 +
    "computeFault":{
 +
        "guid": "12cf7a72-3261-4c57-a82e-1f2f1c124d50",
 +
        "message": "Cannot add non-existent product \"fake\"",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
 +
 
 +
{
 +
    "computeFault": {
 +
        "guid": "0ced627e-c9fc-4835-92da-1a4256165607",
 +
        "message": "Invalid offering URI",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
 +
 
 +
{
 +
    "computeFault": {
 +
        "guid": "5f5e84eb-d52b-4430-94bd-68093860b4d8",
 +
        "message": "The requested offering is invalid",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}
 +
 
 +
{
 +
    "computeFault": {
 +
        "guid": "742e193a-4667-47fd-a5ff-ec1f7788d459",
 +
        "message": "Trying to add inconsistent currency: product core.plangroup.dedserver.plan4 with FAKE while account uses USD",
 +
        "code": 400,
 +
        "details": ""
 +
    }
 +
}</nowiki>
 +
 
 +
<nowiki>
 +
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>
 +
 
 +
<nowiki>
 +
404 Not Found
 +
{
 +
    "itemNotFound": {
 +
        "guid": "e1792d8a-5b0a-43ef-adf5-34a0710c8fc5",
 +
        "message": "Resource not found",
 +
        "code": 404,
 +
        "details": ""
 +
    }
 +
}</nowiki>
  
 
== See also ==
 
== See also ==

Revision as of 08:16, 11 September 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": "Partner purchased plan Id",
}
 

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 purchased plan 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.
  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 without passing offerings
Cannot add non-existent product \"fake\" Trying to create a product with 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
Trying to add inconsistent currency: product {productId} with FAKE while account uses USD Trying to create a product with invalid currency
Trying to add Internal product {productId} without authorization Trying to add product, marked as internal, 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 Unauthorized - The client does not have permissions to add products.
404 Not Found Resource not found The client is trying to get the products for non existing order.

Response Headers

Location
Returned with successful response. Contains the URI of the newly added product.

Response Body

Successful response

201 Created
{
  "url" : "https://api.hostway.com/orders/{orderId}/account/products/{productId}/"
}

Error responses

{
    "computeFault": {
        "guid": "c940c886-5343-4a49-b728-0b94cbb1a3e9",
        "message": "Trying to add Internal product core.plangroup.dedserver.plan4 without authorization",
        "code": 400,
        "details": ""
    }
}

{
    "badRequest":{
        "guid": "0f3e0435-21ac-43e5-acfd-ac33886fbe70",
        "message": "POST data error",
        "code": 400,
        "details": {
            "offering": "Required"
        }
    }
}

{
    "computeFault":{
        "guid": "12cf7a72-3261-4c57-a82e-1f2f1c124d50",
        "message": "Cannot add non-existent product \"fake\"",
        "code": 400,
        "details": ""
    }
}

{
    "computeFault": {
        "guid": "0ced627e-c9fc-4835-92da-1a4256165607",
        "message": "Invalid offering URI",
        "code": 400,
        "details": ""
    }
}

{
    "computeFault": {
        "guid": "5f5e84eb-d52b-4430-94bd-68093860b4d8",
        "message": "The requested offering is invalid",
        "code": 400,
        "details": ""
    }
}

{
    "computeFault": {
        "guid": "742e193a-4667-47fd-a5ff-ec1f7788d459",
        "message": "Trying to add inconsistent currency: product core.plangroup.dedserver.plan4 with FAKE while account uses USD",
        "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.
404 Not Found
{
    "itemNotFound": {
        "guid": "e1792d8a-5b0a-43ef-adf5-34a0710c8fc5",
        "message": "Resource not found",
        "code": 404,
        "details": ""
    }
}

See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox