{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/BankFeedMapping",
  "title": "Bank feed mapping",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "sourceAccountId": {
      "type": "string",
      "description": "Unique ID for the source account."
    },
    "sourceAccountName": {
      "type": "string",
      "description": "Name for the source account."
    },
    "sourceAccountNumber": {
      "type": "string",
      "description": "Account number for the source account."
    },
    "sourceBalance": {
      "type": "number",
      "format": "decimal",
      "description": "Balance for the source account."
    },
    "sourceCurrency": {
      "$ref": "#/components/schemas/SourceAccount/properties/currency"
    },
    "targetAccountId": {
      "type": "string",
      "nullable": true,
      "description": "Unique ID for the target account in the accounting software."
    },
    "targetAccountName": {
      "type": "string",
      "description": "Name for the target account in the accounting software."
    },
    "status": {
      "type": "string",
      "description": "The status."
    },
    "targetAccountOptions": {
      "type": "array",
      "nullable": true,
      "description": "An array of potential target accounts.",
      "items": {
        "$ref": "#/components/schemas/BankFeedMapping/definitions/targetAccountOption"
      }
    },
    "feedStartDate": {
      "$ref": "#/components/schemas/DateTime",
      "nullable": true,
      "description": "The date from which bank transactions can be provided to the platform."
    }
  },
  "description": "A bank feed connection between a source account and a target account, including potential target accounts.",
  "definitions": {
    "targetAccountOption": {
      "title": "Target Account Option",
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Id of the target account."
        },
        "name": {
          "type": "string",
          "nullable": true,
          "description": "Name of the target account."
        },
        "balance": {
          "type": "number",
          "format": "decimal",
          "nullable": true,
          "description": "The balance of the account."
        },
        "sortCode": {
          "type": "string",
          "nullable": true,
          "description": "The sort code of the account."
        },
        "accountNumber": {
          "type": "string",
          "nullable": true,
          "description": "The account number of the account."
        }
      }
    },
    "bankFeedMappings": {
      "title": "Bank feed mappings",
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/BankFeedMapping"
      },
      "additionalProperties": false
    }
  },
  "examples": [
    {
      "sourceAccountId": "acc-002",
      "targetAccountId": "account-081",
      "sourceCurrency": "USD",
      "status": "Success",
      "feedStartDate": "2023-01-09T14:14:14.1057478Z",
      "sourceAccountName": "ACME Bank",
      "sourceAccountNumber": "1234-5678",
      "sourceBalance": 500,
      "targetAccountName": "ACME Bank"
    },
    {
      "sourceAccountId": "c53fd75a-dddb-4493-839a-5090b008f625",
      "status": "pending",
      "targetAccountOptions": [
        {
          "name": "account-081",
          "id": "044096a7-1478-4554-8820-f478caad1b00",
          "balance": 100.99,
          "sortCode": "602336",
          "accountNumber": "23203"
        }
      ],
      "sourceAccountName": "bank name here",
      "sourceAccountNumber": "5670",
      "sourceBalance": 1550,
      "sourceCurrency": "GBP"
    }
  ]
}