(Quick Reference) Service: Update an exchange rate

Description: Returns the updated exchange rate in JSON format when successful. Returns a JSON response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/exchangeRates/{id}

URL with external_id:

https://BASE_URL/api/VERSION/exchangeRates/reference/{id}

The external id corresponding to the target currency (exchangeTo)

Method: PUT

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
idId of the exchange rate to updateLong/StringYes1, EUR
exchangeToISO code of target currency if useExternalId parameter is equal to true, else id of target currencyString / Longyes 
rate Doubleyes 
useExternalIdBy default, it is set to false.Booleannotrue , false

useExternalId is post as a parameter, exchangeTo and rate are post in JSON body request

Success Output

Success case: response.status=200

{
    "id": 5,
    "exchangeFrom": {
        "id": 2,
        "name": "EUR"
    },
    "exchangeTo": {
        "id": 6,
        "name": "GBP"
    },
    "rate": 0.856891234,
    "organization": "company",
    "dateCreated": "2017-04-10T13:10:47Z",
    "lastUpdated": "2017-05-16T10:19:53Z"
}

Failure Output

Failure case:response.status = 400

{
  "error": "save_failed",
  "error_description": "Failed to save instance."
}
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter rate you provided is not valid for this request."
}

{
    "error": "already_assigned",
    "error_description": "EUR is already assigned to EUR."
}

{
    "error": "already_assigned",
    "error_description": "USD is already assigned to Exchange Rate List."
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The Currency with the id 10000 doesn't exist."
}
{
    "error": "not_found",
    "error_description": "The Currency with the reference EURO doesn't exist."
}
Failure case:response.status = 500
{
  "error": "server_error",
  "error_description": "Oops! Something went wrong..."
}
Service: Create an exchange rate

Description: Returns the created exchange rate in JSON format when successful. Returns a JSON response, describing the failure condition when unsuccessful.

URL:

https://BASE_URL/api/VERSION/exchangeRates

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
exchangeToISO code of target currency if useExternalId parameter is equal to true, else id of target currencyStringyes 
rate Doubleyes 
useExternalIdBy default, it is set to false.Booleannotrue , false

useExternalId is post as a parameter, exchangeTo and rate are post in JSON body request

Success Output

Success case: response.status=200

{
    "id": 12,
    "exchangeFrom": {
        "id": 2,
        "name": "EUR"
    },
    "exchangeTo": {
        "id": 1,
        "name": "USD"
    },
    "rate": 1.10135,
    "organization": "company",
    "dateCreated": "2017-05-16T10:00:54Z",
    "lastUpdated": "2017-05-16T10:00:54Z"
}

Failure Output

Failure case:response.status = 400

{
  "error": "save_failed",
  "error_description": "Failed to save instance."
}
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter rate you provided is not valid for this request."
}

{
    "error": "already_assigned",
    "error_description": "EUR is already assigned to EUR."
}

{
    "error": "already_assigned",
    "error_description": "USD is already assigned to Exchange Rate List."
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The Currency with the id 10000 doesn't exist."
}
{
    "error": "not_found",
    "error_description": "The Currency with the reference EURO doesn't exist."
}
Failure case:response.status = 500
{
  "error": "server_error",
  "error_description": "Oops! Something went wrong..."
}