openapi: 3.0.3
info:
  title: Forex Connector REST APIs
  description: Forex Connector Internal REST APIs (CurrencyCloud integration)
  version: '1'
servers:
- url: 'https://api.plumery.com'
  description: Live Server
tags:
  - name: Internal CurrencyCloud Connector
paths:
  /internal/v1/quotes:generate-quote:
    post:
      tags:
        - Internal CurrencyCloud Connector
      summary: Generate a quote
      description: Generate a quote for a given currency pair
      operationId: generateQuote
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateQuoteRequest'
        required: true
      responses:
        '200':
          $ref: "#/components/responses/GeneratedQuoteResponse"
        '404':
          description: Requested currency not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error occurred
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-internal: true
components:
  responses:
    GeneratedQuoteResponse:
      description: Generated quote for a currency pair
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/GeneratedQuoteResponse"
  schemas:
    GenerateQuoteRequest:
      type: object
      required:
          - debitCurrency
          - creditCurrency
          - amount
          - fixedAmountSide
      properties:
        debitCurrency:
          $ref: '#/components/schemas/CurrencyCode'
        creditCurrency:
          $ref: '#/components/schemas/CurrencyCode'
        amount:
          allOf:
            - $ref: '#/components/schemas/AmountValue'
            - description: The amount to be exchanged
        fixedAmountSide:
          type: string
          description: The side of the conversion that is fixed
          enum:
            - DEBIT
            - CREDIT
    GeneratedQuoteResponse:
      type: object
      required:
        - debitAmount
        - creditAmount
        - rate
        - rateLastUpdated
      properties:
        debitAmount:
          allOf:
            - $ref: '#/components/schemas/Amount'
            - description: The estimated amount to be debited.
        creditAmount:
          allOf:
            - $ref: '#/components/schemas/Amount'
            - description: The estimated amount to be credited.
        feeAmount:
          allOf:
            - $ref: '#/components/schemas/Amount'
            - description: The fee charged for the currency exchange.
        rate:
          type: number
          description: The rate at which the debit currency will be exchanged for the credit currency.
          example: 1.1234
        rateLastUpdated:
          allOf:
            - $ref: '#/components/schemas/DateTime'
            - description: The timestamp indicating when the exchange rate was last updated. Outdated rates may apply during system outages.
    Amount:
      type: object
      required:
        - currency
        - amount
      properties:
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        amount:
          $ref: '#/components/schemas/AmountValue'
    AmountValue:
      description: |
        The amount given with fractional digits, where fractions must be compliant to the currency definition.
        Up to 14 significant figures. Negative amounts are signed by minus.
        The decimal separator is a dot.

        **Example:**
        Valid representations for EUR with up to two decimals are:

          * 1056
          * 5768.2
          * -1.50
          * 5877.78
      type: string
      pattern: '-?[0-9]{1,14}(\.[0-9]{1,3})?'
      example: '5877.78'
    CurrencyCode:
      description: |
        ISO 4217 Alpha 3 currency code.
      type: string
      pattern: '[A-Z]{3}'
      example: EUR
    DateTime:
      format: date-time
      type: string
      example: '2017-07-21T17:32:28Z'
    ErrorCode:
      type: string
      enum:
        - 'urn:plmr-internal:forex:connector:INVALID_INPUT'
        - 'urn:plmr-internal:forex:connector:AMOUNT_IS_TOO_SMALL'
        - 'urn:plmr-internal:forex:connector:CURRENCY_EXCHANGE_TIME_WINDOW_CLOSED'
    ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
        params:
          type: object
          additionalProperties: true