import { CountryISO, CurrencyISO, VirtualAccountOwner, VirtualAccountPurpose, VirtualAccountStatus } from "../types";
import { entityBase } from "./entityBase";

export namespace virtualAccount {

    interface VirtualAccountData extends entityBase.EntityBaseData {
        /**
         * The wallet ID
         */
        WalletId: string;

        /**
         * The credited user ID
         */
        CreditedUserId: string;

        /**
         * The type of the virtual account
         * Allowed values: `COLLECTION`, `USER_OWNED`
         */
        VirtualAccountPurpose: VirtualAccountPurpose;

        /**
         * The country of the IBAN. The country must correspond to the currency of the wallet
         */
        Country: CountryISO;

        /**
         * The status of the virtual account creation
         */
        Status: VirtualAccountStatus;

        /**
         * Whether the virtual account is active and can receive pay-ins. `Active` is only `true`
         * when the `Status` is `ACTIVE`.
         */
        Active: boolean;

        /**
         * Owner of the virtual account.
         */
        AccountOwner: VirtualAccountOwner;

        /**
         * Details of the account in local account identifier format
         */
        LocalAccountsDetails: LocalAccountsDetails;

        /**
         * Details of the account in IBAN format.
         * The `InternationalAccountDetails` are not returned if the country doesn’t use IBAN (e.g. AU -
         * Australia)
         */
        InternationalAccountDetails: InternationalAccountDetails;

        /**
         * Information about the account’s payment capabilities
         */
        Capabilities: VirtualAccountCapabilities;

        /**
         * Result code
         */
        ResultCode: string;

        /**
         * Result message
         */
        ResultMessage: string;
    }

    interface CreateVirtualAccount {
        /**
         * The country of the IBAN. The country must correspond to the currency of the wallet
         */
        Country: CountryISO;

        /**
         * The type of the virtual account
         * Allowed values: `COLLECTION`, `USER_OWNED`
         */
        VirtualAccountPurpose: VirtualAccountPurpose;

        /**
         * Tag
         */
        Tag?: string;
    }

    interface VirtualAccountAvailabilitiesData {
        Collection: VirtualAccountAvailability[];
        UserOwned: VirtualAccountAvailability[];
    }

    interface VirtualAccountAvailability {
        Country: CountryISO;
        Available: boolean;
        Currencies: CurrencyISO[];
    }

    interface InternationalAccountDetails {
        /**
         * Information about the address associated with the international IBAN account.
         */
        Address: VirtualAccountAddress;

        /**
         * The IBAN and BIC of the account.
         */
        Account: InternationalAccount;

        BankName: string;
    }

    interface LocalAccountsDetails {
        /**
         * Information about the address associated with the local IBAN account.
         */
        Address: VirtualAccountAddress;

        /**
         * Details of the account in the local account identifier format
         */
        Account: LocalAccount;

        /**
         * The name of the bank
         */
        BankName: string;
    }

    interface VirtualAccountAddress {
        StreetName: string;
        PostCode: string;
        TownName: string;
        CountrySubDivision: string;
        Country: CountryISO;
    }

    interface LocalAccount {
        /**
         * The account number of the account
         */
        AccountNumber: string;

        /**
         * The sort code of the account.
         */
        SortCode: string;

        /**
         * The international bank account number (IBAN) of the account.
         */
        Iban: string;

        /**
         * The bank identifier code (BIC) of the account.
         */
        Bic: string;

        /**
         * The 9-digit ACH routing number of the account.
         */
        AchNumber: string;

        /**
         * The 9-digit Fedwire (ABA) number of the account.
         */
        FedWireNumber: string;

        /**
         * The account type of the account
         */
        AccountType: string;

        /**
         * The 5-digit branch code or transit number of the account.
         */
        BranchCode: string;

        /**
         * The 3-digit institution number of the account.
         */
        InstitutionNumber: string;

        /**
         * The 4-digit bank code of the account
         */
        BankCode: string;

        /**
         * The 6-digit bank state branch (BSB) code of the account.
         */
        BSBCode: string;

        /**
         * The 5-digit bank clearing number of the account
         */
        BCNumber: string;
    }

    interface InternationalAccount {
        /**
         * IBAN
         */
        Iban: string;

        /**
         * BIC
         */
        Bic: string;
    }

    interface VirtualAccountCapabilities {
        /**
         * Whether or not local bank wires can be made to this account.
         */
        LocalPayinAvailable: boolean;

        /**
         * Whether or not international bank wires can be made to this account
         */
        InternationalPayinAvailable: boolean;

        /**
         * List of currencies supported by the account
         */
        Currencies: CurrencyISO[];
    }
}
