@spritz-finance/api-client 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,6 +26,7 @@ A Typescript library for interacting with the Spritz Finance API
26
26
  - [Usage](#usage)
27
27
  - [Creating a user](#creating-a-user-1)
28
28
  - [Setting the User API Key](#setting-the-user-api-key)
29
+ - [Reauthorizing a user](#reauthorizing-a-user)
29
30
  - [Basic User Data](#basic-user-data)
30
31
  - [User Verification](#user-verification)
31
32
  - [Overview](#overview)
@@ -40,6 +41,7 @@ A Typescript library for interacting with the Spritz Finance API
40
41
  - [Bank Accounts](#bank-accounts)
41
42
  - [List user bank accounts](#list-user-bank-accounts)
42
43
  - [Add US bank account](#add-us-bank-account)
44
+ - [Add Canadian bank account](#add-canadian-bank-account)
43
45
  - [Bills](#bills)
44
46
  - [List user bills](#list-user-bills)
45
47
  - [Add US bill account](#add-us-bill-account)
@@ -136,6 +138,19 @@ client.setApiKey(user.apiKey)
136
138
 
137
139
  Now you're ready to issue requests on behalf of the user.
138
140
 
141
+ ## Reauthorizing a user
142
+
143
+ There is a scenrio where you may need to get access to a users API key again. This can happen if you are trying to sign in a user that already has a Spritz account, or if you have lost access to their API key. In this case, you can reauthorize the user by providing their email. The process is that we will send the user an OTP code to their email, and then the user must pass that code on to you to confirm that they are allowing you to interact with their account on their behalf.
144
+
145
+ ```typescript
146
+ const { success } = await client.user.requestApiKey('bilbo@shiremail.net')
147
+
148
+ const { apiKey, userId, email } = await client.user.authorizeApiKeyWithOTP({
149
+ email: 'bilbo@shiremail.net',
150
+ otp: '123456',
151
+ })
152
+ ```
153
+
139
154
  ## Basic User Data
140
155
 
141
156
  Use this to fetch the user's basic data
@@ -286,6 +301,7 @@ const bankAccounts = [{
286
301
  },
287
302
  ownedByUser: true,
288
303
  createdAt: "2023-05-03T11:25:02.401Z",
304
+ deliveryMethods: ['STANDARD', 'INSTANT']
289
305
  }]
290
306
  ```
291
307
 
@@ -314,7 +330,40 @@ import { BankAccountType, BankAccountSubType } from '@spritz-finance/api-client'
314
330
  const bankAccounts = await client.bankAccount.create(BankAccountType.USBankAccount, {
315
331
  accountNumber: '123456789',
316
332
  routingNumber: '987654321',
317
- email: 'bilbo@shiremail.net',
333
+ holder: 'Bilbo Baggins',
334
+ name: 'Precious Savings',
335
+ ownedByUser: true,
336
+ subType: BankAccountSubType.Savings,
337
+ })
338
+ ```
339
+
340
+ #### Add Canadian bank account
341
+
342
+ Currently, Spritz supports the addition of Canadian bank accounts:
343
+
344
+ The input structure for adding a Canadian bank account is defined as:
345
+
346
+ ```typescript
347
+ // Input arguments for creating a Canadian bank account
348
+ export interface CABankAccountInput {
349
+ accountNumber: string
350
+ email?: string
351
+ holder: string
352
+ name: string
353
+ ownedByUser?: boolean | null
354
+ transitNumber: string
355
+ institutionNumber: string
356
+ subType: BankAccountSubType
357
+ }
358
+ ```
359
+
360
+ ```typescript
361
+ import { BankAccountType, BankAccountSubType } from '@spritz-finance/api-client'
362
+
363
+ const bankAccounts = await client.bankAccount.create(BankAccountType.CABankAccount, {
364
+ accountNumber: '123456789',
365
+ transitNumber: '12345',
366
+ institutionNumber: '123',
318
367
  holder: 'Bilbo Baggins',
319
368
  name: 'Precious Savings',
320
369
  ownedByUser: true,
@@ -371,6 +420,7 @@ const bills = [
371
420
  logo: 'https://tinyurl.com/shire-bank-logo',
372
421
  },
373
422
  createdAt: '2023-05-03T11:25:02.401Z',
423
+ deliveryMethods: ['STANDARD']
374
424
  },
375
425
  ]
376
426
  ```
@@ -523,6 +573,7 @@ const paymentRequest = await client.paymentRequest.create({
523
573
  amount: 100,
524
574
  accountId: account.id,
525
575
  network: PaymentNetwork.Ethereum,
576
+ deliveryMethod: 'INSTANT'
526
577
  });
527
578
 
528
579
  // Example response
@@ -63,6 +63,10 @@ declare enum PayableAccountType {
63
63
  Bill = "Bill",
64
64
  VirtualCard = "VirtualCard"
65
65
  }
66
+ declare enum PaymentDeliveryMethod {
67
+ INSTANT = "INSTANT",
68
+ STANDARD = "STANDARD"
69
+ }
66
70
  declare enum PaymentStatus {
67
71
  CANCELLED = "CANCELLED",
68
72
  COMPLETED = "COMPLETED",
@@ -91,6 +95,7 @@ interface BankAccountInput {
91
95
  interface CreateDirectPaymentInput {
92
96
  accountId: string;
93
97
  amount: number;
98
+ deliveryMethod?: PaymentDeliveryMethod | null;
94
99
  network?: string | null;
95
100
  provider?: AccountProvider | null;
96
101
  rewardsAmount?: number | null;
@@ -133,7 +138,7 @@ interface CreateBankAccount_createBankAccount {
133
138
  bankAccountType: BankAccountType;
134
139
  bankAccountSubType: BankAccountSubType;
135
140
  holder: string;
136
- email: string;
141
+ email: string | null;
137
142
  ownedByUser: boolean;
138
143
  bankAccountDetails: CreateBankAccount_createBankAccount_bankAccountDetails;
139
144
  dataSync: CreateBankAccount_createBankAccount_dataSync | null;
@@ -149,6 +154,8 @@ interface AccountPayments_paymentsForAccount {
149
154
  amount: number | null;
150
155
  feeAmount: number | null;
151
156
  createdAt: any;
157
+ deliveryMethod: PaymentDeliveryMethod | null;
158
+ paymentRequestId: string | null;
152
159
  }
153
160
  interface AccountPayments {
154
161
  paymentsForAccount: AccountPayments_paymentsForAccount[];
@@ -186,9 +193,10 @@ interface BankAccountFragment {
186
193
  bankAccountType: BankAccountType;
187
194
  bankAccountSubType: BankAccountSubType;
188
195
  holder: string;
189
- email: string;
196
+ email: string | null;
190
197
  ownedByUser: boolean;
191
198
  bankAccountDetails: BankAccountFragment_bankAccountDetails;
199
+ deliveryMethods: PaymentDeliveryMethod[];
192
200
  institution: BankAccountFragment_institution | null;
193
201
  }
194
202
 
@@ -301,7 +309,7 @@ interface PayableAccountFragment_BankAccount {
301
309
  bankAccountType: BankAccountType;
302
310
  bankAccountSubType: BankAccountSubType;
303
311
  holder: string;
304
- email: string;
312
+ email: string | null;
305
313
  ownedByUser: boolean;
306
314
  bankAccountDetails: PayableAccountFragment_BankAccount_bankAccountDetails;
307
315
  dataSync: PayableAccountFragment_BankAccount_dataSync | null;
@@ -413,6 +421,8 @@ interface PaymentFragment {
413
421
  amount: number | null;
414
422
  feeAmount: number | null;
415
423
  createdAt: any;
424
+ deliveryMethod: PaymentDeliveryMethod | null;
425
+ paymentRequestId: string | null;
416
426
  }
417
427
 
418
428
  interface PaymentRequestFragment {
@@ -426,6 +436,7 @@ interface PaymentRequestFragment {
426
436
  amountDue: number;
427
437
  network: string;
428
438
  createdAt: any;
439
+ deliveryMethod: string | null;
429
440
  }
430
441
 
431
442
  interface PaymentRequestPayment_paymentForPaymentRequest {
@@ -437,6 +448,8 @@ interface PaymentRequestPayment_paymentForPaymentRequest {
437
448
  amount: number | null;
438
449
  feeAmount: number | null;
439
450
  createdAt: any;
451
+ deliveryMethod: PaymentDeliveryMethod | null;
452
+ paymentRequestId: string | null;
440
453
  }
441
454
  interface PaymentRequestPayment {
442
455
  paymentForPaymentRequest: PaymentRequestPayment_paymentForPaymentRequest | null;
@@ -535,9 +548,10 @@ interface UserBankAccounts_bankAccounts {
535
548
  bankAccountType: BankAccountType;
536
549
  bankAccountSubType: BankAccountSubType;
537
550
  holder: string;
538
- email: string;
551
+ email: string | null;
539
552
  ownedByUser: boolean;
540
553
  bankAccountDetails: UserBankAccounts_bankAccounts_bankAccountDetails;
554
+ deliveryMethods: PaymentDeliveryMethod[];
541
555
  institution: UserBankAccounts_bankAccounts_institution | null;
542
556
  }
543
557
  interface UserBankAccounts {
@@ -636,7 +650,7 @@ interface UserPayableAccounts_payableAccounts_BankAccount {
636
650
  bankAccountType: BankAccountType;
637
651
  bankAccountSubType: BankAccountSubType;
638
652
  holder: string;
639
- email: string;
653
+ email: string | null;
640
654
  ownedByUser: boolean;
641
655
  bankAccountDetails: UserPayableAccounts_payableAccounts_BankAccount_bankAccountDetails;
642
656
  }
@@ -887,7 +901,7 @@ interface DeletePayableAccount_deletePayableAccount_BankAccount {
887
901
  bankAccountType: BankAccountType;
888
902
  bankAccountSubType: BankAccountSubType;
889
903
  holder: string;
890
- email: string;
904
+ email: string | null;
891
905
  ownedByUser: boolean;
892
906
  bankAccountDetails: DeletePayableAccount_deletePayableAccount_BankAccount_bankAccountDetails;
893
907
  }
@@ -964,9 +978,10 @@ interface RenameBankAccount_renamePayableAccount_BankAccount {
964
978
  bankAccountType: BankAccountType;
965
979
  bankAccountSubType: BankAccountSubType;
966
980
  holder: string;
967
- email: string;
981
+ email: string | null;
968
982
  ownedByUser: boolean;
969
983
  bankAccountDetails: RenameBankAccount_renamePayableAccount_BankAccount_bankAccountDetails;
984
+ deliveryMethods: PaymentDeliveryMethod[];
970
985
  institution: RenameBankAccount_renamePayableAccount_BankAccount_institution | null;
971
986
  }
972
987
 
@@ -1122,6 +1137,7 @@ interface CreatePaymentRequest_createDirectPayment {
1122
1137
  amountDue: number;
1123
1138
  network: string;
1124
1139
  createdAt: any;
1140
+ deliveryMethod: string | null;
1125
1141
  }
1126
1142
 
1127
1143
  declare enum PaymentNetwork {
@@ -1159,14 +1175,28 @@ interface CreateUserResponse {
1159
1175
  email: string;
1160
1176
  apiKey: string;
1161
1177
  }
1178
+ interface RequestApiKeyResponse {
1179
+ success: boolean;
1180
+ }
1162
1181
  interface CreateUserParams {
1163
1182
  email: string;
1164
1183
  }
1184
+ interface AuthorizeApiKeyResponse {
1185
+ apiKey: string;
1186
+ userId: any;
1187
+ email: string;
1188
+ }
1189
+ interface AuthorizeApiKeyParams {
1190
+ otp: any;
1191
+ email: string;
1192
+ }
1165
1193
  declare class UserService {
1166
1194
  private client;
1167
1195
  constructor(client: SpritzClient);
1168
1196
  createUser(args: CreateUserParams): Promise<CreateUserResponse>;
1169
1197
  create(args: CreateUserParams): Promise<CreateUserResponse>;
1198
+ requestApiKey(email: string): Promise<RequestApiKeyResponse>;
1199
+ authorizeApiKeyWithOTP(args: AuthorizeApiKeyParams): Promise<AuthorizeApiKeyResponse>;
1170
1200
  getCurrentUser(): Promise<CurrentUser_me>;
1171
1201
  getUserVerification(): Promise<UserVerification_verification | null>;
1172
1202
  }