Orders-orderId-account:PUT

From Hostway API Documentation
(Difference between revisions)
Jump to: navigation, search
m (1 revision: Release 99)
 

Latest revision as of 09:06, 14 October 2014

PUT /orders/{orderId}/account

Assign an Account to an Order.

Contents


Request

PUT /orders/{orderId}/account

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

Request Body for adding a new Account to the Order

{
 "currency": "{currency}",
 "language": "{language}"
}
 

Request Body for adding an existing Account to the Order

{
 "accountNumber": "{accountNumber}"
}
 

Request Parameters

currency - string
An ISO-4217[1] currency code assigned to the account.
language - string
An IETF[2] language tag (ex. en, en-CA, en-US, etc.) specifying account's language.
accountNumber - string
The unique account number for an existing account.

Response

Status Code

Status Code Error Message Description
204 No Content - The account was successfully set.
400 Bad Request POST data error The request body format is invalid.
Missing language or currency.
Currency {unsupported_currency} not allowed for this franchise The currency is not supported by the franchise.
Language {unsupported_language} not allowed for this franchise The language is not supported by the franchise.
401 Unauthorized - No owner Id specified or the specified owner is not authorized to perform add account for this order.
403 Forbidden Trying to add a non-test account with invalid credentials: test partner agents cannot add non-test accounts -
Unauthorized: OrderAccount failed permission check Set order account as an authenticated user, not associated with the order.
409 Conflict Trying to add an account with inconsistent currency: the order has already products with {product_currency} while the account you are adding uses {account_currency} Attempt to set currency that is different from currencies of the products or that of the existing account.
502 Bad Gateway - Unexpected backend response.

Response Body

None.

Example

The currency is not supported by the franchise

Request

PUT /orders/{orderId}/account
Cookie: OwnerId={owner_id}; Path=/

{
  "currency": "BGN",
  "language": "en-US"
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "computeFault" : {
    "guid" : "ee39580b-8c74-4c0a-aa11-4de5864d8e51",
    "message" : "Currency BGN not allowed for this franchise",
    "code" : 400,
    "details" : ""
  }
}

Missing currency

Request

PUT /orders/{orderId}/account
Cookie: OwnerId={owner_id}; Path=/

{
  "language": "en-US"
}

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest": {
    "guid": "6f96c728-e6b6-4ca3-bd97-f931d2cd326c",
    "message": "POST data error",
    "code": 400, "details": {
      "currency": "Required"
    }
  }
}

Missing currency and language

Request

PUT /orders/{orderId}/account
Cookie: OwnerId={owner_id}; Path=/

{ }

Response

400 Bad Request
Content-Type : application/json; charset=UTF-8

{
  "badRequest" : {
    "guid" : "f4b6f4b6-fa15-4649-9c31-ec9b7b8150db",
    "message" : "POST data error",
    "code" : 400,
    "details" : {
      "accountNumber" : "Either accountNumber or both currency AND language should be provided"
    }
  }
}

No authorization

Request

PUT /orders/{orderId}/account

{
  "currency": "USD",
  "language": "en-US"
}

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.

Unassociated user without cookie

Request

PUT /orders/{orderId}/account
Authorization: {unassociated_user_authorization}

{ 
  "accountNumber": "smith909090"
}

Response

403 Forbidden
Content-Type: application/json; charset=UTF-8

{
  "forbidden" : {
    "guid" : "f9583d13-1ad3-4ea9-bf26-a5315af5f234",
    "message" : "Unauthorized: OrderAccount failed permission check",
    "code" : 403,
    "details" : ""
  }
}

A test partner agent assigns a non-test account

Request

PUT /orders/{orderId}/account
Authorization: {test_partner_agent_authorization}
Content-Type : application/json; charset=UTF-8
Cookie: OwnerId={owner_id}; Path=/

{ 
  "accountNumber": "smith909090"
}

Response

403 Forbidden
Content-Type : application/json; charset=UTF-8

{
  "forbidden" : {
    "guid" : "7a7d4ce6-241c-44a2-a2e3-cefb26f33a69",
    "message" : "Trying to add a non-test account with invalid credentials: test partner agents cannot add non-test accounts",
    "code" : 403,
    "details" : ""
  }
}

Inconsistent currency

Request

PUT /orders/{orderId}/account
Cookie: OwnerId={owner_id}; Path=/

{ 
  "currency": "CAD",
  "language": "en-US"
}

Response

409 Conflict
Content-Type : application/json; charset=UTF-8

{
  "conflict" : {
    "guid" : "8ec26107-a368-4809-8590-3523d9178893",
    "message" : "Trying to add an account with inconsistent currency: the order has already products with USD while the account you are adding uses CAD",
    "code" : 409,
    "details" : ""
  }
}


See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox