type BlindpayApiResponse<T> = BlindpayErrorResponse | BlindpaySuccessResponse<T>

type ErrorResponse = {
    message: string;
}

type BlindpayErrorResponse = {
    data: null
    error: ErrorResponse;
}

type BlindpaySuccessResponse<T> = {
    data: T;
    error: null;
}

type CurrencyType = "sender" | "receiver";

type Network = "base" | "sepolia" | "arbitrum_sepolia" | "base_sepolia" | "arbitrum" | "polygon" | "polygon_amoy" | "ethereum" | "stellar" | "stellar_testnet" | "tron" | "solana" | "solana_devnet";

type StablecoinToken = "USDC" | "USDT" | "USDB"  

type TransactionDocumentType = "invoice" | "purchase_order" | "delivery_slip" | "contract" | "customs_declaration" | "bill_of_lading" | "others";

type BankAccountType = "checking" | "saving";

type Currency = "USDC" | "USDT" | "USDB" | "BRL" | "USD" | "MXN" | "COP" | "ARS";

type Rail = "wire" | "ach" | "pix" | "pix_safe" | "spei_bitso" | "transfers_bitso" | "ach_cop_bitso" | "international_swift" | "rtp";
    
type AccountClass = "individual" | "business";
    
type TransactionStatus = "refunded" | "processing" | "completed" | "failed" | "on_hold";

type Country = 
        | "AF"
        | "AL"
        | "DZ"
        | "AS"
        | "AD"
        | "AO"
        | "AI"
        | "AQ"
        | "AG"
        | "AR"
        | "AM"
        | "AW"
        | "AU"
        | "AT"
        | "AZ"
        | "BS"
        | "BH"
        | "BD"
        | "BB"
        | "BY"
        | "BE"
        | "BZ"
        | "BJ"
        | "BM"
        | "BT"
        | "BO"
        | "BQ"
        | "BA"
        | "BW"
        | "BV"
        | "BR"
        | "IO"
        | "BN"
        | "BG"
        | "BF"
        | "BI"
        | "CV"
        | "KH"
        | "CM"
        | "CA"
        | "KY"
        | "CF"
        | "TD"
        | "CL"
        | "CN"
        | "CX"
        | "CC"
        | "CO"
        | "KM"
        | "CD"
        | "CG"
        | "CK"
        | "CR"
        | "HR"
        | "CU"
        | "CW"
        | "CY"
        | "CZ"
        | "CI"
        | "DK"
        | "DJ"
        | "DM"
        | "DO"
        | "EC"
        | "EG"
        | "SV"
        | "GQ"
        | "ER"
        | "EE"
        | "SZ"
        | "ET"
        | "FK"
        | "FO"
        | "FJ"
        | "FI"
        | "FR"
        | "GF"
        | "PF"
        | "TF"
        | "GA"
        | "GM"
        | "GE"
        | "DE"
        | "GH"
        | "GI"
        | "GR"
        | "GL"
        | "GD"
        | "GP"
        | "GU"
        | "GT"
        | "GG"
        | "GN"
        | "GW"
        | "GY"
        | "HT"
        | "HM"
        | "VA"
        | "HN"
        | "HK"
        | "HU"
        | "IS"
        | "IN"
        | "ID"
        | "IR"
        | "IQ"
        | "IE"
        | "IM"
        | "IL"
        | "IT"
        | "JM"
        | "JP"
        | "JE"
        | "JO"
        | "KZ"
        | "KE"
        | "KI"
        | "KP"
        | "KR"
        | "KW"
        | "KG"
        | "LA"
        | "LV"
        | "LB"
        | "LS"
        | "LR"
        | "LY"
        | "LI"
        | "LT"
        | "LU"
        | "MO"
        | "MG"
        | "MW"
        | "MY"
        | "MV"
        | "ML"
        | "MT"
        | "MH"
        | "MQ"
        | "MR"
        | "MU"
        | "YT"
        | "MX"
        | "FM"
        | "MD"
        | "MC"
        | "MN"
        | "ME"
        | "MS"
        | "MA"
        | "MZ"
        | "MM"
        | "NA"
        | "NR"
        | "NP"
        | "NL"
        | "NC"
        | "NZ"
        | "NI"
        | "NE"
        | "NG"
        | "NU"
        | "NF"
        | "MP"
        | "NO"
        | "OM"
        | "PK"
        | "PW"
        | "PS"
        | "PA"
        | "PG"
        | "PY"
        | "PE"
        | "PH"
        | "PN"
        | "PL"
        | "PT"
        | "PR"
        | "QA"
        | "MK"
        | "RO"
        | "RU"
        | "RW"
        | "RE"
        | "BL"
        | "SH"
        | "KN"
        | "LC"
        | "MF"
        | "PM"
        | "VC"
        | "WS"
        | "SM"
        | "ST"
        | "SA"
        | "SN"
        | "RS"
        | "SC"
        | "SL"
        | "SG"
        | "SX"
        | "SK"
        | "SI"
        | "SB"
        | "SO"
        | "ZA"
        | "GS"
        | "SS"
        | "ES"
        | "LK"
        | "SD"
        | "SR"
        | "SJ"
        | "SE"
        | "CH"
        | "SY"
        | "TW"
        | "TJ"
        | "TZ"
        | "TH"
        | "TL"
        | "TG"
        | "TK"
        | "TO"
        | "TT"
        | "TN"
        | "TR"
        | "TM"
        | "TC"
        | "TV"
        | "UG"
        | "UA"
        | "AE"
        | "GB"
        | "UM"
        | "US"
        | "UY"
        | "UZ"
        | "VU"
        | "VE"
        | "VN"
        | "VG"
        | "VI"
        | "WF"
        | "EH"
        | "YE"
        | "ZM"
        | "ZW"
        | "AX";

type PaginationParams = {
    limit?: '10' | '50' | '100' | '200' | '500' | '1000';
    offset?: '0' | '10' | '50' | '100' | '200' | '500' | '1000';
    starting_after?: string;
    ending_before?: string;
}

type PaginationMetadata = {
    has_more: boolean;
    next_page: string;
    prev_page: string;
}

type ArgentinaTransfers = "CVU" | "CBU" | "ALIAS";

type AchCopDocument = "CC" | "CE" | "NIT" | "PASS" | "PEP";

type PayinTrackingTransaction = {
    step: TrackingStatus
    status?: 'failed' | 'completed' | null;
    external_id: string | null;
    completed_at?: string | null;
    sender_name?: string | null;
    sender_tax_id?: string | null;
    sender_bank_code?: string | null;
    sender_account_number?: string | null;
    trace_number?: string | null;
    transaction_reference?: string | null;
    description?: string | null;
    pse_instruction?: {
      payment_link: string;
      fid: string;
      full_name: string;
      tax_id: string;
      document_type: Extract<AchCopDocument, 'CC' | 'NIT'>;
      phone: string;
      email: string;
      bank_code?: string | null;
    } | null
    transfers_instruction?: {
      account: string;
      type: ArgentinaTransfers;
      tax_id?: string | null;
    } | null
  };
  
type PayinTrackingPayment = {
    step: TrackingStatus
    provider_name?: string | null
    completed_at?: string | null
  };
  
type PayinTrackingComplete = {
    step: TrackingStatus
    transaction_hash?: string | null;
    completed_at?: string | null;
  };
  
type PayinTrackingPartnerFee = {
    step: TrackingStatus
    transaction_hash?: string | null
    completed_at?: string | null
  } 

type PayinPaymentMethod = "ach" | "wire" | "pix" | "spei" | "transfers" | "pse" | "international_swift"

type PayerRules = {
    pix_allowed_tax_ids?: string[] | null;
    transfers_allowed_tax_id?: string | null;
    pse_allowed_tax_ids?: string[] | null;
    pse_full_name?: string | null;
    pse_document_type?: Extract<AchCopDocument, 'CC' | 'NIT'> | null;
    pse_document_number?: string | null;
    pse_email?: string | null;
    pse_phone?: string | null;
    pse_bank_code?: string | null;
}

type TrackingStatus = 'processing' | 'on_hold' | 'completed' | 'pending_review';

type EstimatedTimeOfArrival = '5_min' | '30_min' | '2_hours' | '1_business_day' | '2_business_days' | '5_business_days';

type PayoutTrackingTransaction = {
    step: TrackingStatus
    status: 'failed' | 'found';
    transaction_hash: string | null
    completed_at: string | null
  };
  
type PayoutTrackingPayment = {
    step: TrackingStatus
    provider_name: string | null ;
    provider_transaction_id: string | null ;
    provider_status: 'canceled' | 'failed' | 'returned' | 'sent' | null
    recipient_name: string | null ;
    recipient_tax_id: string | null ;
    recipient_bank_code: string | null ;
    recipient_branch_code: string | null ;
    recipient_account_number: string | null ;
    recipient_account_type: string | null ;
    estimated_time_of_arrival: EstimatedTimeOfArrival | null ;
    completed_at: string | null ;
  };
  
type PayoutTrackingLiquidity = {
    step: TrackingStatus
    provider_transaction_id: string | null ;
    provider_status: 'deposited' | 'converted' | 'withdrawn' | null;
    estimated_time_of_arrival: EstimatedTimeOfArrival | null;
    completed_at: string | null ;
  }
  
type PayoutTrackingComplete = {
    step: TrackingStatus
    status: 'tokens_refunded' | 'paid' | null;
    transaction_hash: string | null;
    completed_at: string | null;
  };

type PayoutTrackingPartnerFee = {
    step: TrackingStatus
    transaction_hash: string | null;
    completed_at: string | null;
  }

export type { AccountClass as A, BlindpayApiResponse as B, Country as C, Network as N, PaginationParams as P, Rail as R, StablecoinToken as S, TransactionStatus as T, BankAccountType as a, AchCopDocument as b, ArgentinaTransfers as c, PayinTrackingTransaction as d, PayinTrackingPayment as e, PayinTrackingComplete as f, PayinTrackingPartnerFee as g, PayinPaymentMethod as h, Currency as i, PayerRules as j, PaginationMetadata as k, CurrencyType as l, PayoutTrackingTransaction as m, PayoutTrackingPayment as n, PayoutTrackingLiquidity as o, PayoutTrackingComplete as p, PayoutTrackingPartnerFee as q, TransactionDocumentType as r, TrackingStatus as s };
