-
-
Save svallory/5ae2190282b6ccf9cb8ac57abe65e70f to your computer and use it in GitHub Desktop.
Hyperwallet draft typings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface HwApiError { | |
/** | |
* The field name (if error is caused by a particular field) | |
*/ | |
fieldName: string; | |
/** | |
* The error message | |
*/ | |
message: string; | |
/** | |
* The error code | |
*/ | |
code: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// export type HwTransferMethod = "BANK_ACCOUNT" | "BANK_CARD" | "PAPER_CHECK" | "WIRE_ACCOUNT" | "PAYPAL_ACCOUNT" | |
export type HwTransferMethod = | |
| 'BANK_ACCOUNT' | |
| 'BANK_CARD' | |
| 'PAPER_CHECK' | |
| 'WIRE_ACCOUNT' | |
| 'PAYPAL_ACCOUNT'; | |
export type HwPaymentPurposeCode = | |
// Bonus | |
| 'GP0001' | |
// Commission | |
| 'GP0002' | |
// Expense | |
| 'GP0003' | |
// NonTaxablePayment | |
| 'GP0004' | |
// Income | |
| 'GP0005' | |
// Pension | |
| 'GP0006' | |
// CharityDonation | |
| 'GP0007' | |
// OTHER | |
| 'OTHER'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Response } from 'superagent'; | |
import { HwApiError } from './ApiError'; | |
import { HwUserData } from './user'; | |
import { HwAddTransferMethodPayload } from './payloads'; | |
/** | |
* The callback interface for api calls | |
* | |
* @param errors In case of an error an array with error objects otherwise undefined | |
* @param data The rest response body | |
* @param res The raw superagent response object | |
*/ | |
export type HwApiCallback = ( | |
errors: HwApiError[], | |
data: Record<string, any>, | |
res: Response, | |
) => void; | |
export default class Hyperwallet { | |
username: string; | |
password: string; | |
programToken: string; | |
server: string; | |
constructor(options: { | |
username: string; | |
password: string; | |
programToken: string; | |
server: string; | |
}); | |
/** | |
* Create a bank account | |
*/ | |
public createBankAccount( | |
userToken: string, | |
data: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Create a bank account status transition | |
*/ | |
public createBankAccountStatusTransition( | |
userToken: string, | |
bankAccountToken: string, | |
data: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Create a payment | |
*/ | |
public createPayment(data: Record<string, any>, callback: HwApiCallback): void; | |
/** | |
* Create a prepaid card | |
*/ | |
public createPrepaidCard( | |
userToken: string, | |
data: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Create a prepaid card status transition | |
*/ | |
public createPrepaidCardStatusTransition( | |
userToken: string, | |
prepaidCardToken: string, | |
data: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Create a transfer method | |
*/ | |
public createTransferMethod( | |
userToken: string, | |
jsonCacheToken: string, | |
data: HwAddTransferMethodPayload, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Create a user | |
*/ | |
public createUser(data: HwUserData, callback: HwApiCallback): void; | |
/** | |
* Deactivate a bank account | |
*/ | |
public deactivateBankAccount( | |
userToken: string, | |
bankAccountToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Deactivate a prepaid card | |
*/ | |
public deactivatePrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Get a bank account | |
*/ | |
public getBankAccount(userToken: string, bankAccountToken: string, callback: HwApiCallback): void; | |
/** | |
* Get a payment | |
*/ | |
public getPayment(paymentToken: string, callback: HwApiCallback): void; | |
/** | |
* Get a prepaid card | |
*/ | |
public getPrepaidCard(userToken: string, prepaidCardToken: string, callback: HwApiCallback): void; | |
/** | |
* Get a prepaid card status transition | |
*/ | |
public getPrepaidCardStatusTransition( | |
userToken: string, | |
prepaidCardToken: string, | |
statusTransitionToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Get a program | |
*/ | |
public getProgram(programToken: string, callback: HwApiCallback): void; | |
/** | |
* Get a program account | |
*/ | |
public getProgramAccount( | |
programToken: string, | |
accountToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Get a transfer method configuration | |
*/ | |
public getTransferMethodConfiguration( | |
userToken: string, | |
country: string, | |
currency: string, | |
type: string, | |
profileType: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Load a user | |
*/ | |
public getUser(userToken: string, callback: HwApiCallback): void; | |
/** | |
* Get a single webhook notification | |
*/ | |
public getWebhookNotification(webhookToken: string, callback: HwApiCallback): void; | |
/** | |
* List balances for a program accounts | |
*/ | |
public listBalancesForAccount( | |
programToken: string, | |
accountToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List balances for a prepaid card | |
*/ | |
public listBalancesForPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List balances for a user | |
*/ | |
public listBalancesForUser( | |
userToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all bank account status transitions | |
*/ | |
public listBankAccountStatusTransitions( | |
userToken: string, | |
bankAccountToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all bank accounts | |
*/ | |
public listBankAccounts( | |
userToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all bank cards | |
* | |
* @param {string} userToken - The user token | |
* @param {Object} options - The query parameters to send | |
* @param {api-callback} callback - The callback for this call | |
* @throws Will throw an error if userToken is not provided | |
*/ | |
public listBankCards( | |
userToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all payments | |
*/ | |
public listPayments(options: Record<string, any>, callback: HwApiCallback): void; | |
/** | |
* List all prepaid card status transitions | |
*/ | |
public listPrepaidCardStatusTransitions( | |
userToken: string, | |
prepaidCardToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all prepaid cards | |
*/ | |
public listPrepaidCards( | |
userToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all prepaid card receipts | |
*/ | |
public listReceiptsForPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all program account receipts | |
*/ | |
public listReceiptsForProgramAccount( | |
programToken: string, | |
accountToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all user receipts | |
*/ | |
public listReceiptsForUser( | |
userToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all transfer method configurations | |
*/ | |
public listTransferMethodConfigurations( | |
userToken: string, | |
options: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* List all users | |
*/ | |
public listUsers(options: Record<string, any>, callback: HwApiCallback): void; | |
/** | |
* List webhook notifications | |
*/ | |
public listWebhookNotifications(options: Record<string, any>, callback: HwApiCallback): void; | |
/** | |
* Lock a prepaid card | |
*/ | |
public lockPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Mark a prepaid card as lost or stolen | |
*/ | |
public lostOrStolenPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Suspend a prepaid card | |
*/ | |
public suspendPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Unlock a prepaid card | |
*/ | |
public unlockPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Unsuspend a prepaid card | |
*/ | |
public unsuspendPrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Update a bank account | |
*/ | |
public updateBankAccount( | |
userToken: string, | |
bankAccountToken: string, | |
data: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Update a prepaid card | |
*/ | |
public updatePrepaidCard( | |
userToken: string, | |
prepaidCardToken: string, | |
data: Record<string, any>, | |
callback: HwApiCallback, | |
): void; | |
/** | |
* Update a user | |
*/ | |
public updateUser(userToken: string, data: Record<string, any>, callback: HwApiCallback): void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HwTransferMethod } from './enums'; | |
export interface HwAddTransferMethodPayload { | |
/** | |
* Two-letter code | |
*/ | |
transferMethodCountry: string; | |
/** | |
* Three-letter code | |
*/ | |
transferMethodCurrency: string; | |
type: HwTransferMethod; | |
cardNumber: string; | |
/** | |
* Format: YYYY-MM | |
*/ | |
dateOfExpiry: string; | |
cvv: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HwTransferMethod, HwPaymentPurposeCode } from './enums'; | |
export interface HwResourceLink { | |
params: { rel: 'self' | string }; | |
href: string; | |
} | |
export interface HwCreateUserResponse { | |
token: string; | |
status: 'CREATED' | 'ACTIVATED' | 'LOCKED' | 'FROZEN' | 'PRE_ACTIVATED' | 'DE_ACTIVATED'; | |
verificationStatus: 'NOT_REQUIRED' | 'REQUIRED' | 'FAILED' | 'UNDER_REVIEW' | 'VERIFIED'; | |
createdOn: string; | |
clientUserId: string; | |
gender?: 'MALE' | 'FEMALE'; | |
governmentId: string; | |
governmentIdType?: 'PASSPORT' | 'NATIONAL_ID_CARD'; | |
profileType: 'INDIVIDUAL' | 'BUSINESS'; | |
firstName: string; | |
lastName: string; | |
dateOfBirth: string; | |
email: string; | |
addressLine1: string; | |
city: string; | |
stateProvince: string; | |
country: string; | |
postalCode: string; | |
language: string; | |
timeZone: string; | |
programToken: string; | |
links: HwResourceLink[]; | |
} | |
interface HwAddTransferMethodResponseBase { | |
token: string; | |
type: HwTransferMethod; | |
status: 'ACTIVATED' | 'VERIFIED' | 'INVALID' | 'DE_ACTIVATED'; | |
/** | |
* Format: '2019-09-11T13:43:21' | |
*/ | |
createdOn: string; | |
/** | |
* Two-letter country code | |
*/ | |
transferMethodCountry: string; | |
transferMethodCurrency: string; | |
bankName: string; | |
} | |
export interface HwAddTransferMethodResponse<T extends 'BANK_CARD'> | |
extends HwAddTransferMethodResponseBase { | |
type: T; | |
cardType: 'DEBIT'; | |
/** | |
* Format: ************9999 | |
*/ | |
cardNumber: string; | |
cardBrand: 'VISA' | 'MASTERCARD'; | |
/** | |
* Format: YYYY-MM | |
*/ | |
dateOfExpiry: string; | |
processingTime: string; | |
} | |
export interface HwListBankCardsResponseCard { | |
token: string; | |
type: 'BANK_CARD'; | |
status: string; | |
createdOn: string; | |
transferMethodCountry: string; | |
transferMethodCurrency: string; | |
cardType: 'DEBIT'; | |
cardNumber: string; | |
cardBrand: string; | |
/** | |
* Format: YYYY-MM | |
*/ | |
dateOfExpiry: string; | |
processingTime: string; | |
links: HwResourceLink[]; | |
} | |
export interface HwListBankCardsResponse { | |
count: number; | |
offset: number; | |
limit: number; | |
data: HwListBankCardsResponseCard[]; | |
links: HwResourceLink[]; | |
} | |
export interface HwCreatePaymentResponse { | |
token: string; | |
status: 'COMPLETED'; | |
purpose: HwPaymentPurposeCode; | |
createdOn: string; | |
amount: string; | |
currency: string; | |
clientPaymentId: 'DyClk0VG'; | |
expiresOn: ISODateString; | |
destinationToken: string; | |
programToken: string; | |
links: HwResourceLink[]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface HwBaseUserData { | |
/** | |
* A client-defined identifier for the user. This is the unique ID assigned to the user on your system. Max 75 characters. Allows letters, numbers, and + , - . / _ ~ | | |
*/ | |
clientUserId: string; | |
/** | |
* The user's profile type. | |
* Possible types are: INDIVIDUAL, BUSINESS | |
*/ | |
profileType: 'INDIVIDUAL' | 'BUSINESS'; | |
/** | |
* The contact email address for the user account. | |
* | |
* This must be unique for your program, so you cannot have two users belonging to the same program with the same email address. | |
* Max 200 characters; must be a valid email address. | |
*/ | |
email: string; | |
/** | |
* The user's street address. Max 100 characters. Allows letters, numbers, space and # ' ( ) , - . / : ; ° | |
*/ | |
addressLine1: string; | |
/** | |
* The user's address, second line. Max 100 characters. Allows letters, numbers, space and # ' ( ) , - . / : ; ° | |
*/ | |
addressLine2?: string; | |
/** | |
* The user's city. Max 50 characters. Allows letters, space and & ' ( ) - . | |
*/ | |
city: string; | |
/** | |
* The user's state, province or region. Max 50 characters. Allows letters, space and & ' ( ) - . | |
*/ | |
stateProvince: string; | |
/** | |
* Two-letter code for the user's country | |
*/ | |
country: string; | |
/** | |
* Two-letter code for the user's birth country | |
*/ | |
countryOfBirth?: string; | |
/** | |
* The user's postal code. Max 16 characters. Allows numbers, letters, space and - | |
*/ | |
postalCode: string; | |
/** | |
* The unique identifier for the program to which the user will belong. | |
*/ | |
programToken: string; | |
} | |
export interface HwIndividualUser extends HwBaseUserData { | |
/** | |
* The user's profile type | |
*/ | |
profileType: 'INDIVIDUAL'; | |
/** | |
* The user's first name. Max 50 characters. Allows letters space and ' , - . | |
*/ | |
firstName: string; | |
/** | |
* The user's last name. Max 50 characters. Allows letters space and ' , - . | |
*/ | |
lastName: string; | |
dateOfBirth: string; | |
// @todo: add missing optional types | |
} | |
export interface HwBusinessUser extends HwBaseUserData { | |
/** | |
* The user's profile type | |
*/ | |
profileType: 'BUSINESS'; | |
/** | |
* The business name. Max 100 characters. Allows letters, numbers, space and ! & ' ( ) + , - . / : ; | |
*/ | |
businessName: string; | |
// @todo: Add missing business fields | |
} | |
export type HwUserData = HwIndividualUser | HwBusinessUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export * from './hyperwallet-sdk-ApiError'; | |
export * from './hyperwallet-sdk-enums'; | |
export * from './hyperwallet-sdk-hyperwallet'; | |
export * from './hyperwallet-sdk-responses'; | |
export * from './hyperwallet-sdk-User'; | |
export * from './hyperwallet-sdk-payloads'; | |
import Hyperwallet from './hyperwallet-sdk-hyperwallet'; | |
export default Hyperwallet; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment