Exchange Batch (v1)

https://github.com/folio-org/mod-finance

Table of contents

Exchange Batch API

This documents the API calls that can be made to get exchange batch operations

Calculate exchange batch

Calculate exchange batch API

POST /finance/calculate-exchange-batch

Get exchange calculation in batch

POST /finance/calculate-exchange-batch
Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Exchange rate calculation schema",
  "type": "object",
  "properties": {
    "exchangeRateCalculations": {
      "description": "The list of exchange rate calculation objects",
      "type": "array",
      "id": "exchangeRateCalculations",
      "items": {
        "type": "object",
        "properties": {
          "from": {
            "description": "Fund code to calculate the exchange rate from",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[^:]+$"
          },
          "to": {
            "description": "Fund code to calculate the exchange rate to",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[^:]+$"
          },
          "amount": {
            "description": "Amount to calculate the exchange rate for",
            "type": "number"
          },
          "rate": {
            "description": "Custom exchange rate to use for the calculation",
            "type": "number"
          },
          "calculation": {
            "description": "Calculated exchange rate value",
            "type": "number"
          }
        },
        "additionalProperties": false,
        "required": [
          "from",
          "to",
          "amount"
        ]
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "exchangeRateCalculations"
  ]
}

Example:

{
  "exchangeRateCalculations": [
    {
      "from": "USD",
      "to": "EUR",
      "amount": 1000,
      "rate": 0.85
    },
    {
      "from": "EUR",
      "to": "GBP",
      "amount": 500,
      "rate": 0.90
    },
    {
      "from": "GBP",
      "to": "JPY",
      "amount": 200,
      "rate": 150.00
    }
  ]
}

Response 200

Exchange calculation successfully retrieved

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "Exchange rate calculation schema",
  "type": "object",
  "properties": {
    "exchangeRateCalculations": {
      "description": "The list of exchange rate calculation objects",
      "type": "array",
      "id": "exchangeRateCalculations",
      "items": {
        "type": "object",
        "properties": {
          "from": {
            "description": "Fund code to calculate the exchange rate from",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[^:]+$"
          },
          "to": {
            "description": "Fund code to calculate the exchange rate to",
            "$schema": "http://json-schema.org/draft-04/schema#",
            "type": "string",
            "pattern": "^[^:]+$"
          },
          "amount": {
            "description": "Amount to calculate the exchange rate for",
            "type": "number"
          },
          "rate": {
            "description": "Custom exchange rate to use for the calculation",
            "type": "number"
          },
          "calculation": {
            "description": "Calculated exchange rate value",
            "type": "number"
          }
        },
        "additionalProperties": false,
        "required": [
          "from",
          "to",
          "amount"
        ]
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "exchangeRateCalculations"
  ]
}

Example:

{
  "exchangeRateCalculations": [
    {
      "from": "USD",
      "to": "EUR",
      "amount": 1000,
      "rate": 0.85
    },
    {
      "from": "EUR",
      "to": "GBP",
      "amount": 500,
      "rate": 0.90
    },
    {
      "from": "GBP",
      "to": "JPY",
      "amount": 200,
      "rate": 150.00
    }
  ]
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "error.schema",
  "description": "An error",
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Error message text"
    },
    "type": {
      "type": "string",
      "description": "Error message type"
    },
    "code": {
      "type": "string",
      "description": "Error message code"
    },
    "parameters": {
      "description": "Error message parameters",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "id": "parameters.schema",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      }
    }
  },
  "required": [
    "message"
  ]
}

Example:

{
  "message": "may not be null",
  "type": "1",
  "code": "-1",
  "parameters": [
    {
      "key": "moduleTo",
      "value": "null"
    }
  ]
}

Response 404

Exchange rate is not available

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "error.schema",
  "description": "An error",
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Error message text"
    },
    "type": {
      "type": "string",
      "description": "Error message type"
    },
    "code": {
      "type": "string",
      "description": "Error message code"
    },
    "parameters": {
      "description": "Error message parameters",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "id": "parameters.schema",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      }
    }
  },
  "required": [
    "message"
  ]
}

Example:

{
  "message": "may not be null",
  "type": "1",
  "code": "-1",
  "parameters": [
    {
      "key": "moduleTo",
      "value": "null"
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "error.schema",
  "description": "An error",
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Error message text"
    },
    "type": {
      "type": "string",
      "description": "Error message type"
    },
    "code": {
      "type": "string",
      "description": "Error message code"
    },
    "parameters": {
      "description": "Error message parameters",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "id": "parameters.schema",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      }
    }
  },
  "required": [
    "message"
  ]
}

Example:

{
  "message": "may not be null",
  "type": "1",
  "code": "-1",
  "parameters": [
    {
      "key": "moduleTo",
      "value": "null"
    }
  ]
}