CurrencyManagerResource

CurrencyManager facade resource

GraphViz

Schema

The considered APS type (download) extends the Resource APS type(s) and looks as follows:

{
  "name": "CurrencyManagerResource",
  "id": "http://a8n.bss/exchangerates/currency-manager/1.0",
  "apsVersion": "2.0",
  "implements": [
    "http://aps-standard.org/types/core/resource/1.0"
  ],
  "access": {
    "global": true
  },
  "operations": {
    "initReseller": {
      "path": "/init-reseller",
      "verb": "GET",
      "errorResponse": {
        "type": "object"
      }
    },
    "getAllCurrencies": {
      "path": "/all-currencies",
      "verb": "GET",
      "response": {
        "type": "ResellerCurrenciesDTO"
      },
      "errorResponse": {
        "type": "object"
      }
    },
    "getAvailableSalesCurrencies": {
      "path": "/available-sales-currencies",
      "verb": "GET",
      "response": {
        "type": "array",
        "items": {
          "type": "SalesCurrencyWithPluginRatesDTO"
        }
      },
      "errorResponse": {
        "type": "object"
      }
    },
    "setSalesCurrency": {
      "path": "/sales-currency",
      "verb": "PUT",
      "errorResponse": {
        "type": "object"
      },
      "parameters": {
        "salesCurrencyDTO": {
          "kind": "body",
          "type": "SalesCurrencyDTO",
          "required": true
        }
      }
    },
    "setRate": {
      "path": "/exchange-rate",
      "verb": "PUT",
      "errorResponse": {
        "type": "object"
      },
      "parameters": {
        "resellerCurrencyPairDTO": {
          "kind": "body",
          "type": "ExchangeRateConfigDTO",
          "required": true
        }
      }
    },
    "getExchangeRates": {
      "path": "/exchange-rate/{accountId}",
      "verb": "GET",
      "response": {
        "type": "array",
        "items": {
          "type": "ExchangeRateDTO"
        }
      },
      "errorResponse": {
        "type": "object"
      },
      "parameters": {
        "accountId": {
          "kind": "path",
          "type": "string"
        },
        "effectiveDate": {
          "kind": "query",
          "type": "string"
        }
      }
    },
    "getActiveCurrencies": {
      "path": "/active-currencies",
      "verb": "GET",
      "response": {
        "type": "ActiveCurrenciesDTO"
      },
      "errorResponse": {
        "type": "object"
      }
    }
  },
  "structures": {
    "SalesCurrencyDTO": {
      "type": "object",
      "properties": {
        "currency": {
          "type": "CurrencyDTO"
        },
        "active": {
          "type": "boolean"
        }
      }
    },
    "CurrencyDTO": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "required": true
        },
        "name": {
          "type": "string",
          "readonly": true
        }
      }
    },
    "BillingCurrencyDTO": {
      "type": "object",
      "properties": {
        "currency": {
          "type": "CurrencyDTO"
        }
      }
    },
    "ExchangeRateConfigDTO": {
      "type": "object",
      "properties": {
        "currencyPair": {
          "type": "CurrencyPairDTO"
        },
        "autoUpdate": {
          "type": "boolean",
          "required": true
        },
        "rate": {
          "type": "number"
        },
        "period": {
          "type": "string",
          "default": "DAILY",
          "enum": [
            "DAILY",
            "WEEKLY",
            "MONTHLY"
          ]
        },
        "pluginCode": {
          "type": "string"
        },
        "pluginName": {
          "type": "string",
          "readonly": true
        },
        "fromDate": {
          "type": "string",
          "readonly": true,
          "format": "date-time"
        }
      }
    },
    "CurrencyPairDTO": {
      "type": "object",
      "properties": {
        "base": {
          "type": "CurrencyDTO"
        },
        "quote": {
          "type": "CurrencyDTO"
        }
      }
    },
    "ResellerCurrenciesDTO": {
      "type": "object",
      "properties": {
        "salesCurrencies": {
          "type": "array",
          "items": {
            "type": "SalesCurrencyDTO"
          }
        },
        "billingCurrencies": {
          "type": "array",
          "items": {
            "type": "BillingCurrencyDTO"
          }
        },
        "exchangeRates": {
          "type": "array",
          "items": {
            "type": "ExchangeRateConfigDTO"
          }
        }
      }
    },
    "PluginDTO": {
      "type": "object",
      "properties": {
        "pair": {
          "type": "CurrencyPairDTO"
        },
        "pluginCode": {
          "type": "string",
          "readonly": true
        },
        "pluginName": {
          "type": "string"
        },
        "rate": {
          "type": "number",
          "required": true
        }
      }
    },
    "SalesCurrencyWithPluginRatesDTO": {
      "type": "object",
      "properties": {
        "currency": {
          "type": "CurrencyDTO"
        },
        "plugins": {
          "type": "array",
          "items": {
            "type": "PluginDTO"
          }
        }
      }
    },
    "ExchangeRateDTO": {
      "type": "object",
      "properties": {
        "currencyPair": {
          "type": "CurrencyPairDTO"
        },
        "rate": {
          "type": "number"
        },
        "fromDate": {
          "type": "string",
          "readonly": true,
          "format": "date-time"
        }
      }
    },
    "ActiveCurrenciesDTO": {
      "type": "object",
      "properties": {
        "salesCurrencies": {
          "type": "array",
          "items": {
            "type": "CurrencyDTO"
          }
        },
        "billingCurrencies": {
          "type": "array",
          "items": {
            "type": "CurrencyDTO"
          }
        }
      }
    }
  }
}

Custom Operations

OPERATION

VERB

PATH

RETURNS

Description

initReseller

GET

/init-reseller

Reserved for future use

getAllCurrencies

GET

/all-currencies

Reserved for future use

getAvailableSalesCurrencies

GET

/available-sales-currencies

SalesCurrencyWithPluginRatesDTO

Get all sales and billing currencies and their exchange rates for the account.

setSalesCurrency

PUT

/sales-currency

Reserved for future use

setRate

PUT

/exchange-rate

Add a sales currency to an account and configure the exchange rates.

getExchangeRates

GET

/exchange-rate/{accountId}

This method returns an array of ExchangeRateDTO

Get the list of exchange rates effective on a specific date for a specific account.

getActiveCurrencies

GET

/active-currencies

ActiveCurrenciesDTO

Get the list of available sales and billing currencies.

initReseller

HTTP Request

GET /aps/2/resources/{aps-id}/init-reseller

Description

Reserved for future use

Returns

getAllCurrencies

HTTP Request

GET /aps/2/resources/{aps-id}/all-currencies

Description

Reserved for future use

Returns

getAvailableSalesCurrencies

HTTP Request

GET /aps/2/resources/{aps-id}/available-sales-currencies

Description

Get all sales and billing currencies and their exchange rates for the account.

Returns

SalesCurrencyWithPluginRatesDTO

setSalesCurrency

HTTP Request

PUT /aps/2/resources/{aps-id}/sales-currency

Description

Reserved for future use

Parameters

PARAMETER

TYPE

DESCRIPTION

salesCurrencyDTO

SalesCurrencyDTO

Returns

setRate

HTTP Request

PUT /aps/2/resources/{aps-id}/exchange-rate

Description

Add a sales currency to an account and configure the exchange rates.

Parameters

PARAMETER

TYPE

DESCRIPTION

resellerCurrencyPairDTO

ExchangeRateConfigDTO

Returns

getExchangeRates

HTTP Request

GET /aps/2/resources/{aps-id}/exchange-rate/{accountId}

Description

Get the list of exchange rates effective on a specific date for a specific account.

Parameters

PARAMETER

TYPE

DESCRIPTION

accountId

String

ID of an account for which to get the rates.

effectiveDate

String

Date for which to get the rates. If omitted, current date will be used.

Returns

This method returns an array of ExchangeRateDTO

getActiveCurrencies

HTTP Request

GET /aps/2/resources/{aps-id}/active-currencies

Description

Get the list of available sales and billing currencies.

Returns

ActiveCurrenciesDTO

Structures

SalesCurrencyDTO

A structure of this kind represents a sales currency.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

currency

CurrencyDTO

Not Required

A structure with currency name and ISO code.

active

Boolean

Not Required

Reserved for future use.

CurrencyDTO

A structure of this kind represents a currency.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

code

String

Required

Currency code in ISO 4217 format.

name

String

Not Required Read Only

Currency name that is suitable for displaying in the en_US locale.

BillingCurrencyDTO

Billing currency information

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

currency

CurrencyDTO

Not Required

A structure of this kind represents a customer payment currency.

ExchangeRateConfigDTO

A structure of this kind represents exchange rate configuration for a currency pair

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

currencyPair

CurrencyPairDTO

Not Required

autoUpdate

Boolean

Required

rate

Number

Not Required

period

Enum

Not Required

DAILY

pluginCode

String

Not Required

pluginName

String

Not Required Read Only

fromDate

String

Not Required Read Only

CurrencyPairDTO

A structure of this kind represents a pair of sales and billing currencies.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

base

CurrencyDTO

Not Required

A structure with sales currency name and ISO code.

quote

CurrencyDTO

Not Required

A structure with billing currency name and ISO code.

ResellerCurrenciesDTO

A structure of this kind represents the list of configured sales and billing currencies, and exchange rates.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

salesCurrencies

Array of SalesCurrencyDTO

Not Required

List of configured sales currencies.

billingCurrencies

Array of BillingCurrencyDTO

Not Required

List of billing currencies.

exchangeRates

Array of ExchangeRateConfigDTO

Not Required

Exchange rate configurations per currency pair.

PluginDTO

This structure represents an exchange rate for a currency pair from a plugin.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

pair

CurrencyPairDTO

Not Required

Currency pair.

pluginCode

String

Not Required Read Only

Plugin abbreviation.

pluginName

String

Not Required

Plugin name.

rate

Number

Required

Actual exchange rate.

SalesCurrencyWithPluginRatesDTO

A structure of this kind represents a list of currencies available in the system with the list of exchange rates obtained from a plugin.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

currency

CurrencyDTO

Not Required

Sales currency structure.

plugins

Array of PluginDTO

Not Required

Available plugins that can provide exchange rates for paris with that currency.

ExchangeRateDTO

A structure of this kind represents an exchange rate for a currency pair on a specific date.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

currencyPair

CurrencyPairDTO

Not Required

rate

Number

Not Required

fromDate

String

Not Required Read Only

ActiveCurrenciesDTO

A structure of this kind represents a list of available sales and billing currencies.

NAME

TYPE

ATTRIBUTES

DEFAULT

DESCRIPTION

salesCurrencies

Array of CurrencyDTO

Not Required

List of available sales currencies.

billingCurrencies

Array of CurrencyDTO

Not Required

List of billing currencies.

Examples

In this section:

Get Exchange Rates

You can get exchange rates configured for a specific account. For this purpose, use a request similar to the one below, providing identifiers of the currency manager application and of the account:

GET /aps/2/resources/367faffb-769d-4b10-a6ea-438d9405afd9/exchange-rate/24840673-1988-454e-b728-b031f4499214

As a result, you will receive a response like this:

HTTP/1.1 200 OK

  {
      "currencyPair": {
          "base": {
              "code": "CAD",
              "name": "Canadian Dollar"
          },
          "quote": {
              "code": "USD",
              "name": "US Dollar"
          }
      },
      "rate": 0.79,
      "fromDate": "2022-04-08T12:56:31.284765Z"
  }