### Transfer Attributes

| Attribute                 | Type       | Definition                                                                           | Example                                     |
|---------------------------|------------|--------------------------------------------------------------------------------------|---------------------------------------------|
| id                        | UUID       | unique id of the transfer                                                            |                                             |
| state                     | String     | see above for states and definitions                                                 | processing                                   |
| user                      | UserAccount| user object                                                                          | `{ ... }`                                   |
| beneficiary               | Beneficiary| beneficiary object                                                                    | `{ ... }`                                   |
| entity                    | Entity     | entity object                                                                         | `{ ... }`                                   |
| fee                       | String     | fee of transfer in source currency                                                   | 1.50                                        |
| source_amount             | String     | numerical amount of the currency funding the payment                                   | 100.00                                      |
| source_currency           | String     | 3 character code of currency funding the payment                                      | USD                                         |
| destination_amount        | String     | numerical amount of currency sent to beneficiary                                       | 2000.00                                     |
| destination_currency      | String     | 3 character code of currency sent to beneficiary                                       | MXN                                         |
| purpose_of_payment        | String     | free form text describing purpose of the payment                                       | Contractor services                          |
| rate                      | String     | the forward rate of the trade used to convert funds                                   | 20.00000                                    |
| reference                 | String     | free form text memo on payment which can be read by beneficiary                       | Invoice-001                                 |
| created_date              | DateTime   | date & time the record was created                                                   | 2021-04-02 00:00:00                        |
| expected_delivery_date    | DateTime   | date the receiving bank is expected to receive the funds                              | 2021-04-04 00:00:00                        |
| error                     | String     | if the transfer was returned or failed, this might show a returning/failing reason      | The transaction is rejected as the beneficiary is blacklisted. |

### GraphQL

enum TransferStates {
  accepted
  finalized
  initiated
  processing
  sent
  completed
  failed
  returned
  canceled
  scheduled
  in_review
}

enum IncomingTransferPurposeOfPayment {
  corporate_payment
  marketplace
  professional_services
  payroll
  expenses_reimbursement
  representation_expenses
  hired_personnel
  trainees_scholarships
  productivity_or_quality_prizes
  lay_off_payment
  family_support
  education
  gift_and_other_donations
  medical_treatment
  maintenance_or_other_expenses
  car_driver
  software_license
  hotel_accommodation
  advertising_and_or_public_relations_related_expenses
  fees_for_advisory_or_consulting_service
  business_related_insurance_payment
  insurance_claims_payment
  delivery_fees
  payments_for_exported_goods
  payment_of_loans
  residential_property_purchase
  property_rental_payment
  royalty_trademark_patent_and_copyright_fees
  investment_in_shares
  fund_investment
  tuition_fees
  transportation_fees
  utility_bills
  personal_transfer
  payment_of_salary
  other_purposes
  remittances
  freelancer_payment
}

type Transfer {
  id: UUID!
  state: TransferStates! # see States section for values and descriptions
  user: UserAccount!
  creator: UserAccount!
  beneficiary: Beneficiary!
  entity: Entity!
  fee: String
  source_amount: String
  source_currency: ISO4217!
  destination_amount: String
  destination_currency: ISO4217!
  purpose_of_payment: String!
  rate: String
  reference: String
  created_date: DateTime
  expected_delivery_date: DateTime
  funding_instructions: FundingInstructions
  wallet: Wallet
  is_scheduled: Boolean
  scheduled_delivery_date: DateTime
  error: String
}

type TransferQuote {
  rate: String!
  inverted_rate: String!
  source_amount: String
  destination_amount: String
  source_currency: ISO4217!
  destination_currency: ISO4217!
  fee: String
}

type TransferReceipt {
  transfer_id: UUID!
  link: String
  link_expiration: DateTime
  includes_tracking: Boolean
}

type IncomingTransferAccount {
  id: UUID!
  organization_id: UUID
  entity: Entity
  wallet: Wallet
  currency: ISO4217
  account_number: BankAccountNumber
  name_on_bank_account: String
  nicename_on_bank_account: String
  bank_name: String
  state: IncomingTransferState
  tax_id: TaxNumber
  purpose_of_payment: IncomingTransferPurposeOfPayment
  updated_date: DateTime
  country_code: String
  tax_code: String
  remittance_info: String
  reference: String
}

type IncomingTransfer {
  id: UUID
  uuid: UUID
  organization_id: UUID
  entity_id: UUID
  wallet_id: UUID
  currency: ISO4217
  credit: Boolean
  debit: Boolean
  amount: String!
  transaction_date: DateTime
  remittance_info: String
  reference: String
  counterparty_name: String
  account_number: BankAccountNumber
  name_on_bank_account: String
  nicename_on_bank_account: String
  state: IncomingTransferState
  tax_id: TaxNumber
  purpose_of_payment: IncomingTransferPurposeOfPayment
  updated_date: DateTime
  incoming_transfer_account: IncomingTransferAccount
  virtual_account_name: String
  created_date: DateTime
  incoming_transfer_account_id: UUID
  incoming_transfer_account_name_on_bank_account: String
  incoming_transfer_account_bank_name: String
}

type SubAccount {
  id: UUID
  created_date: DateTime
  organization_id: UUID
  entity: Entity
  currency: ISO4217
  balance: String
  available_balance: String
  account_name: String
  client_friendly_name: String
  account_number: String
  master_account_number: String
  updated_date: DateTime
  state: String
  funding_instructions: FundingInstructions
}

enum IncomingTransferState {
  accepted
  awaiting_funds
  complete
  canceled
  declined
}

type Query {
  transfer(
    transfer_id: UUID!
  ): Transfer

transfers(
    search_terms: String # optional
    listFilter: ListFilter
  ): [Transfer]

transferReceipt(
    transfer_id: UUID!
  ): TransferReceipt

subAccount(
    sub_account_id: UUID!
  ): SubAccount
}

type Mutation {
  createTransfer(
    user_id: UUID!
    entity_id: UUID!
    source_amount: String
    wallet_id: UUID
    destination_amount: String
    beneficiary_id: UUID!
    purpose_of_payment: String!
    reference: String
  ): UUID

createScheduledTransfer(
    user_id: UUID
    entity_id: UUID!
    source_amount: String
    wallet_id: UUID
    destination_amount: String
    beneficiary_id: UUID!
    purpose_of_payment: String!
    reference: String
    scheduled_delivery_date: DateTime
  ): UUID

updateTransfer(
    transfer_id: UUID!
    user_id: UUID!
    entity_id: UUID
    source_currency: ISO4217
    wallet_id: UUID
    beneficiary_id: UUID
    purpose_of_payment: String
    reference: String
  ): UUID @verified

getTransferQuote(
    transfer_id: UUID!
    source_amount: String
    destination_amount: String
  ): TransferQuote

finalizeTransfer(transfer_id: UUID!): UUID

createIncomingTransferAccount(
    entity_id: UUID!
    wallet_id: UUID!
    currency: ISO4217!
    account_number: BankAccountNumber!
    account_type: String
    name_on_bank_account: String!
    nicename_on_bank_account: String
    bank_name: String!
    bank_code: String!
    state: IncomingTransferState
    tax_id: TaxNumber!
    purpose_of_payment: IncomingTransferPurposeOfPayment
    remittance_info: String
    reference: String
    account_number_type: String
    email: String!
  ): UUID

createIncomingTransfer(
    amount: String!
    incoming_transfer_account_id: UUID!
    purpose_of_payment: IncomingTransferPurposeOfPayment
    remittance_info: String
    reference: String
  ): UUID
}
