react-native-unit-components
Version:
Unit React Native components
187 lines (166 loc) • 3.98 kB
text/typescript
import { UNAccountType } from './account.types';
import { UNCustomerType } from './customer.types';
import { UNAddress, UNBusinessContact, UNFullName, UNPhone } from './types';
export enum UNCreateCardType {
Virtual = 'virtual',
Physical = 'physical',
}
export type UNCreateCardComponentResources = {
type: 'createCardComponentResources'
attributes: {
accounts: UNCreateCardComponentAccount[]
customer: UNCreateCardCustomer
possibleCardholders: UNCardholder[]
resourceDiscovery: UNResourceDiscovery
bin?: UNBin[]
}
}
export type UNCreateCardCustomer = UNCreateCardComponentIndividualCustomer | UNCreateCardComponentBusinessCustomer
export type UNCreateCardComponentIndividualCustomer = {
type: UNCustomerType.IndividualCustomer
attributes: {
fullName: UNFullName
address: UNAddress
dateOfBirth: Date
email: string
phone: UNPhone
}
}
export type UNCreateCardComponentBusinessCustomer = {
type: UNCustomerType.BusinessCustomer
attributes: {
name: UNFullName
address: UNAddress
phone: UNPhone
contact: UNBusinessContact
}
}
export type UNCreateCardComponentAccount = UNCreateCardComponentDepositAccount | UNCreateCardComponentCreditAccount
export type UNCreateCardComponentDepositAccount = {
type: UNAccountType.DepositAccount
id: string
attributes: {
name: string
tags: { [key: string]: string }
routingNumber: string
accountNumber: string
}
}
export type UNCreateCardComponentCreditAccount = {
type: UNAccountType.CreditAccount
id: string
attributes: {
name: string
tags: { [key: string]: string }
}
}
export type UNCardholderAttributes = {
fullName: UNFullName
address?: UNAddress
dateOfBirth?: Date
email?: string
phone?: UNPhone
}
export type UNCardholder = {
type: 'possibleCardholder'
attributes: UNCardholderAttributes
}
export interface UNResourceDiscovery {
type: 'resourceDiscovery'
attributes: {
featureSettings?: UNFeatureSettings
accountManifest?: UNAccountManifest[]
legalLinks?: UNLegalLinks
brandName?: string
supportComponent?: UNSupportComponent
}
relationships: {
customer: {
data: {
type: 'customer'
id: string
}
}
accounts: {
data: UNRelationship[]
}
cards: {
data: UNRelationship[]
}
}
}
export interface UNFeatureSettings {
wirePayment?: {
enabled: boolean
}
achDebitPayment?: {
enabled: boolean
}
quickbooks?: {
enabled: boolean
}
sameDayAch?: {
enabled: boolean
}
appUsers?: {
enabled: boolean
}
}
export interface UNAccountManifest {
type: 'depositAccountManifest'
attributes: {
accountId: string
bankName: string
maxNumberOfPhysicalCards?: number
maxNumberOfVirtualCards?: number
dailyCardWithdrawalLimit: number
dailyCardDepositLimit: number
dailyCardPurchaseLimit: number
outgoingWireFee: number
outgoingAchFee: number
sameDayAchFee: number
}
}
export interface UNLegalLinks {
privacyPolicyUrl?: string
electronicDisclosuresUrl?: string
depositTermsUrl?: string
clientTermsUrl?: string
cardholderTermsUrl?: string
cashAdvancedTermsUrl?: string
debitCardDisclosureUrl?: string
additionalDisclosures?: UNAdditionalDisclosure[]
}
export type UNAdditionalDisclosure = {
title: string
url: string
}
export type UNSupportComponent = {
attributes: {
provider?: UNSupportType
widgetId?: string
widgetToken?: string
}
}
export enum UNSupportType {
Zendesk = 'zendesk',
}
type UNRelationship = {
type: string
id: string
}
export type UNBin = {
attributes: {
bin: string
institutionId: string
product: string
}
type: 'whiteLabelBinDto'
}
export function parseUNCreateCardTypes(input?: string | null): UNCreateCardType[] {
if (!input) return [];
return input
.split(',')
.map(s => s.trim())
.filter((s): s is UNCreateCardType => s in UNCreateCardType);
}