monime-package 1.1.3 → 1.1.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
@@ -51,7 +51,7 @@ Package: `monime-package`
51
51
  - **Typed** request/response objects for safer integrations
52
52
  - **Predictable** return shape: `{ success, data?, error? }`
53
53
  - **Client-based** auth: set credentials once per instance
54
- - **Minimal deps** (`axios`) and small surface area
54
+ - **Zero dependencies** (using native `fetch`) for maximum performance and portability
55
55
  - **Full API coverage** for all Monime endpoints
56
56
  - **Tree-shaking support** - only bundle what you use
57
57
  - **Dual module output** - works with both CommonJS and ES modules
@@ -139,14 +139,14 @@ The client exposes namespaced APIs under `client.<module>`. Below is the complet
139
139
  Manage all incoming payments (payins).
140
140
 
141
141
  ```ts
142
- // Get payment details
143
- client.payment.get(paymentId: string): Promise<Result<GetPayment>>
142
+ // Retrieve payment details
143
+ client.payment.retrieve(paymentId: string): Promise<Result<RetrievePaymentResponse>>
144
144
 
145
145
  // List payments
146
- client.payment.getAll(params?: any): Promise<Result<ListPayments>>
146
+ client.payment.list(): Promise<Result<ListPaymentsResponse>>
147
147
 
148
- // Patch payment
149
- client.payment.patch(paymentId: string, body: any): Promise<Result<PatchPayment>>
148
+ // Update payment
149
+ client.payment.update(paymentId: string, body: any): Promise<Result<UpdatePaymentResponse>>
150
150
  ```
151
151
 
152
152
  ### Webhooks (New)
@@ -157,17 +157,17 @@ Manage webhooks for real-time notifications.
157
157
  // Create webhook
158
158
  client.webhook.create(body: CreateWebhookRequest): Promise<Result<CreateWebhookResponse>>
159
159
 
160
- // Get webhook
161
- client.webhook.get(webhookId: string): Promise<Result<GetWebhookResponse>>
160
+ // Retrieve webhook
161
+ client.webhook.retrieve(webhookId: string): Promise<Result<GetWebhookResponse>>
162
162
 
163
163
  // List webhooks
164
- client.webhook.getAll(): Promise<Result<ListWebhooksResponse>>
164
+ client.webhook.list(): Promise<Result<ListWebhooksResponse>>
165
165
 
166
166
  // Update webhook
167
167
  client.webhook.update(webhookId: string, body: UpdateWebhookRequest): Promise<Result<UpdateWebhookResponse>>
168
168
 
169
169
  // Delete webhook
170
- client.webhook.delete(webhookId: string): Promise<{ success: boolean; error?: Error }>
170
+ client.webhook.delete(webhookId: string): Promise<Result<void>>
171
171
  ```
172
172
 
173
173
  ### Receipts (New)
@@ -175,8 +175,8 @@ client.webhook.delete(webhookId: string): Promise<{ success: boolean; error?: Er
175
175
  Manage payment receipts.
176
176
 
177
177
  ```ts
178
- // Get receipt
179
- client.receipt.get(orderNumber: string): Promise<Result<GetReceiptResponse>>
178
+ // Retrieve receipt
179
+ client.receipt.retrieve(orderNumber: string): Promise<Result<GetReceiptResponse>>
180
180
 
181
181
  // Redeem receipt
182
182
  client.receipt.redeem(orderNumber: string, body: any): Promise<Result<RedeemReceiptResponse>>
@@ -196,8 +196,8 @@ client.ussdOtp.create(body: CreateUssdOtpRequest): Promise<Result<CreateUssdOtpR
196
196
  Get provider KYC details.
197
197
 
198
198
  ```ts
199
- // Get provider KYC
200
- client.providerKyc.get(providerId: string): Promise<Result<GetProviderKycResponse>>
199
+ // Retrieve provider KYC
200
+ client.providerKyc.retrieve(providerId: string): Promise<Result<GetProviderKycResponse>>
201
201
  ```
202
202
 
203
203
  ### Financial Accounts
@@ -206,13 +206,13 @@ Manage digital wallets and financial accounts.
206
206
 
207
207
  ```ts
208
208
  // Create a new financial account
209
- client.financialAccount.create(name: string): Promise<Result<CreateFinancialAccount>>
209
+ client.financialAccount.create(name: string, currency: "USD" | "SLE"): Promise<Result<CreateFinancialAccountResponse>>
210
210
 
211
- // Get account details by ID
212
- client.financialAccount.get(financialAccountId: string): Promise<Result<GetFinancialAccount>>
211
+ // Retrieve account details by ID
212
+ client.financialAccount.retrieve(financialAccountId: string): Promise<Result<RetrieveFinancialAccountResponse>>
213
213
 
214
214
  // List all financial accounts
215
- client.financialAccount.getAll(): Promise<Result<AllFinancialAccount>>
215
+ client.financialAccount.list(): Promise<Result<ListFinancialAccountsResponse>>
216
216
  ```
217
217
 
218
218
  **Parameters:**
@@ -222,14 +222,14 @@ client.financialAccount.getAll(): Promise<Result<AllFinancialAccount>>
222
222
  **Example:**
223
223
  ```ts
224
224
  // Create account
225
- const account = await client.financialAccount.create("My Wallet");
225
+ const account = await client.financialAccount.create("My Wallet", "SLE");
226
226
  if (account.success) {
227
- console.log("Account ID:", account.data.result.id);
228
- console.log("Balance:", account.data.result.balance.available.value);
227
+ console.log("Account ID:", account.data.id);
228
+ console.log("Balance:", account.data.balance.available.value);
229
229
  }
230
230
 
231
- // Get account details
232
- const details = await client.financialAccount.get("fa-123456");
231
+ // Retrieve account details
232
+ const details = await client.financialAccount.retrieve("fa-123456");
233
233
  ```
234
234
 
235
235
  ### Internal Transfers
@@ -242,16 +242,16 @@ client.internalTransfer.create(
242
242
  sourceAccount: string,
243
243
  destinationAccount: string,
244
244
  amount: number,
245
- ): Promise<Result<CreateInternalTransfer>>
245
+ ): Promise<Result<CreateInternalTransferResponse>>
246
246
 
247
- // Get transfer details
248
- client.internalTransfer.get(internalTransferId: string): Promise<Result<InternalTransfer>>
247
+ // Retrieve transfer details
248
+ client.internalTransfer.retrieve(internalTransferId: string): Promise<Result<RetrieveInternalTransferResponse>>
249
249
 
250
250
  // List all transfers
251
- client.internalTransfer.getAll(): Promise<Result<AllInternalTransfers>>
251
+ client.internalTransfer.list(): Promise<Result<ListInternalTransfersResponse>>
252
252
 
253
253
  // Cancel/delete a transfer
254
- client.internalTransfer.delete(internalTransferId: string): Promise<{ success: boolean; error?: Error }>
254
+ client.internalTransfer.delete(internalTransferId: string): Promise<Result<void>>
255
255
  ```
256
256
 
257
257
  **Parameters:**
@@ -265,8 +265,8 @@ client.internalTransfer.delete(internalTransferId: string): Promise<{ success: b
265
265
  // Transfer 1000 SLE between accounts
266
266
  const transfer = await client.internalTransfer.create("fa-source", "fa-dest", 1000);
267
267
  if (transfer.success) {
268
- console.log("Transfer ID:", transfer.data.result.id);
269
- console.log("Status:", transfer.data.result.status);
268
+ console.log("Transfer ID:", transfer.data.id);
269
+ console.log("Status:", transfer.data.status);
270
270
  }
271
271
  ```
272
272
 
@@ -279,19 +279,19 @@ Generate USSD payment codes for mobile money transactions.
279
279
  client.paymentCode.create(
280
280
  paymentName: string,
281
281
  amount: number,
282
- financialAccount: string,
282
+ financialAccountId: string,
283
283
  username: string,
284
284
  phoneNumber: string,
285
- ): Promise<Result<CreatePaymentCode>>
285
+ ): Promise<Result<CreatePaymentCodeResponse>>
286
286
 
287
- // Get payment code details
288
- client.paymentCode.get(paymentCodeId: string): Promise<Result<GetOne>>
287
+ // Retrieve payment code details
288
+ client.paymentCode.retrieve(paymentCodeId: string): Promise<Result<RetrievePaymentCodeResponse>>
289
289
 
290
290
  // List all payment codes
291
- client.paymentCode.getAll(): Promise<Result<GetAllPaymentCode>>
291
+ client.paymentCode.list(): Promise<Result<ListPaymentCodesResponse>>
292
292
 
293
293
  // Delete payment code
294
- client.paymentCode.delete(paymentCodeId: string): Promise<{ success: boolean; error?: Error }>
294
+ client.paymentCode.delete(paymentCodeId: string): Promise<Result<void>>
295
295
  ```
296
296
 
297
297
  **Parameters:**
@@ -314,8 +314,8 @@ const paymentCode = await client.paymentCode.create(
314
314
  );
315
315
 
316
316
  if (paymentCode.success) {
317
- console.log("USSD Code:", paymentCode.data.result.ussdCode);
318
- console.log("Expires at:", paymentCode.data.result.expireTime);
317
+ console.log("USSD Code:", paymentCode.data.ussdCode);
318
+ console.log("Expires at:", paymentCode.data.expireTime);
319
319
  }
320
320
  ```
321
321
 
@@ -329,16 +329,16 @@ client.payout.create(
329
329
  amount: number,
330
330
  destination: DestinationOption,
331
331
  sourceAccount: string,
332
- ): Promise<Result<CreatePayout>>
332
+ ): Promise<Result<CreatePayoutResponse>>
333
333
 
334
334
  // List all payouts
335
- client.payout.get(): Promise<Result<GetAll>>
335
+ client.payout.list(): Promise<Result<ListPayoutsResponse>>
336
336
 
337
- // Get specific payout
338
- client.payout.getOne(payoutId: string): Promise<Result<GetOnePayout>>
337
+ // Retrieve specific payout
338
+ client.payout.retrieve(payoutId: string): Promise<Result<RetrievePayoutResponse>>
339
339
 
340
340
  // Cancel payout
341
- client.payout.delete(payoutId: string): Promise<{ success: boolean; error?: Error }>
341
+ client.payout.delete(payoutId: string): Promise<Result<void>>
342
342
  ```
343
343
 
344
344
  **Destination Types:**
@@ -377,11 +377,11 @@ const bankPayout = await client.payout.create(
377
377
  Query transaction history and details.
378
378
 
379
379
  ```ts
380
- // Get transaction details
381
- client.financialTransaction.get(transactionId: string): Promise<Result<GetTransaction>>
380
+ // Retrieve transaction details
381
+ client.financialTransaction.retrieve(transactionId: string): Promise<Result<RetrieveTransactionResponse>>
382
382
 
383
383
  // List all transactions
384
- client.financialTransaction.getAll(): Promise<Result<AllTransaction>>
384
+ client.financialTransaction.list(): Promise<Result<ListTransactionsResponse>>
385
385
  ```
386
386
 
387
387
  **Parameters:**
@@ -389,10 +389,10 @@ client.financialTransaction.getAll(): Promise<Result<AllTransaction>>
389
389
 
390
390
  **Example:**
391
391
  ```ts
392
- // Get all transactions
393
- const transactions = await client.financialTransaction.getAll();
392
+ // List all transactions
393
+ const transactions = await client.financialTransaction.list();
394
394
  if (transactions.success) {
395
- transactions.data.result.forEach(tx => {
395
+ transactions.data.forEach(tx => {
396
396
  console.log(`${tx.type}: ${tx.amount.value} ${tx.amount.currency}`);
397
397
  });
398
398
  }
@@ -410,20 +410,22 @@ client.checkoutSession.create(
410
410
  quantity: number,
411
411
  successUrl: string,
412
412
  cancelUrl: string,
413
- description?: string,
414
- financialAccountId?: string,
415
- primaryColor?: string,
416
- images?: string[],
417
- ): Promise<Result<CreateCheckout>>
413
+ options?: {
414
+ description?: string,
415
+ financialAccountId?: string,
416
+ primaryColor?: string,
417
+ images?: string[],
418
+ }
419
+ ): Promise<Result<CreateCheckoutResponse>>
418
420
 
419
421
  // List all checkout sessions
420
- client.checkoutSession.get(): Promise<Result<AllCheckout>>
422
+ client.checkoutSession.list(): Promise<Result<ListCheckoutsResponse>>
421
423
 
422
- // Get specific checkout session
423
- client.checkoutSession.getOne(checkoutId: string): Promise<Result<OneCheckout>>
424
+ // Retrieve specific checkout session
425
+ client.checkoutSession.retrieve(checkoutId: string): Promise<Result<RetrieveCheckoutResponse>>
424
426
 
425
427
  // Delete checkout session
426
- client.checkoutSession.delete(checkoutId: string): Promise<{ success: boolean; error?: Error }>
428
+ client.checkoutSession.delete(checkoutId: string): Promise<Result<void>>
427
429
  ```
428
430
 
429
431
  **Parameters:**
@@ -455,8 +457,8 @@ const checkout = await client.checkoutSession.create(
455
457
 
456
458
  if (checkout.success) {
457
459
  // Redirect customer to checkout page
458
- console.log("Checkout URL:", checkout.data.result.redirectUrl);
459
- console.log("Order Number:", checkout.data.result.orderNumber);
460
+ console.log("Checkout URL:", checkout.data.redirectUrl);
461
+ console.log("Order Number:", checkout.data.orderNumber);
460
462
  }
461
463
  ```
462
464
 
@@ -500,11 +502,12 @@ pnpm test
500
502
  pnpm lint-format
501
503
  ```
502
504
 
503
- ### Module Structure
504
- The package is organized into modules under `src/modules/`:
505
- - Each module has its own types, implementation, and index file
506
- - All types are exported from `src/modules/types.ts`
507
- - The main client (`MonimeClient`) exposes all modules as properties
505
+ ### Project Structure
506
+ The package is organized for maximum simplicity:
507
+ - **`src/resources/`**: All API resource implementations (e.g., `payment.ts`, `payout.ts`)
508
+ - **`src/types/`**: Consolidated TypeScript interface definitions
509
+ - **`src/client.ts`**: The main `MonimeClient` entry point
510
+ - **`src/http.ts`**: Shared native `fetch` logic and telemetry
508
511
 
509
512
  ---
510
513
 
@@ -524,14 +527,14 @@ const client = createClient({
524
527
  });
525
528
 
526
529
  // Create business account
527
- const businessAccount = await client.financialAccount.create("E-commerce Store");
530
+ const businessAccount = await client.financialAccount.create("E-commerce Store", "SLE");
528
531
  if (!businessAccount.success) {
529
532
  throw new Error(`Failed to create account: ${businessAccount.error?.message}`);
530
533
  }
531
534
 
532
- const accountId = businessAccount.data!.result.id;
535
+ const accountId = businessAccount.data!.id;
533
536
  console.log(`Created account: ${accountId}`);
534
- console.log(`Balance: ${businessAccount.data!.result.balance.available.value} SLE`);
537
+ console.log(`Balance: ${businessAccount.data!.balance.available.value} SLE`);
535
538
 
536
539
  // Create checkout session for customer
537
540
  const checkout = await client.checkoutSession.create(
@@ -540,16 +543,18 @@ const checkout = await client.checkoutSession.create(
540
543
  1,
541
544
  "https://store.com/success",
542
545
  "https://store.com/cancel",
543
- "Professional DSLR Camera with lens kit",
544
- accountId,
545
- "#2563EB", // Brand blue
546
- ["https://store.com/camera.jpg"]
546
+ {
547
+ description: "Professional DSLR Camera with lens kit",
548
+ financialAccountId: accountId,
549
+ primaryColor: "#2563EB", // Brand blue
550
+ images: ["https://store.com/camera.jpg"]
551
+ }
547
552
  );
548
553
 
549
554
  if (checkout.success) {
550
- console.log(`Checkout created: ${checkout.data!.result.id}`);
551
- console.log(`Payment URL: ${checkout.data!.result.redirectUrl}`);
552
- console.log(`Order: ${checkout.data!.result.orderNumber}`);
555
+ console.log(`Checkout created: ${checkout.data!.id}`);
556
+ console.log(`Payment URL: ${checkout.data!.redirectUrl}`);
557
+ console.log(`Order: ${checkout.data!.orderNumber}`);
553
558
  }
554
559
  ```
555
560
 
@@ -566,19 +571,19 @@ const paymentCode = await client.paymentCode.create(
566
571
  );
567
572
 
568
573
  if (paymentCode.success) {
569
- console.log(`USSD Code: ${paymentCode.data!.result.ussdCode}`);
570
- console.log(`Expires: ${paymentCode.data!.result.expireTime}`);
574
+ console.log(`USSD Code: ${paymentCode.data!.ussdCode}`);
575
+ console.log(`Expires: ${paymentCode.data!.expireTime}`);
571
576
 
572
577
  // Send USSD code to customer via SMS/email
573
- await sendToCustomer(paymentCode.data!.result.ussdCode);
578
+ await sendToCustomer(paymentCode.data!.ussdCode);
574
579
  }
575
580
 
576
581
  // 2. Monitor payment status
577
582
  const checkPaymentStatus = async (codeId: string) => {
578
- const status = await client.paymentCode.get(codeId);
583
+ const status = await client.paymentCode.retrieve(codeId);
579
584
  if (status.success) {
580
- console.log(`Payment Status: ${status.data!.result.status}`);
581
- return status.data!.result.status === 'completed';
585
+ console.log(`Payment Status: ${status.data!.status}`);
586
+ return status.data!.status === 'completed';
582
587
  }
583
588
  return false;
584
589
  };
@@ -596,9 +601,9 @@ const paySupplier = async () => {
596
601
  );
597
602
 
598
603
  if (payout.success) {
599
- console.log(`Payout ID: ${payout.data!.result.id}`);
600
- console.log(`Status: ${payout.data!.result.status}`);
601
- console.log(`Fees: ${payout.data!.result.fees.map(f => `${f.code}: ${f.amount.value}`)}`);
604
+ console.log(`Payout ID: ${payout.data!.id}`);
605
+ console.log(`Status: ${payout.data!.status}`);
606
+ console.log(`Fees: ${payout.data!.fees.map(f => `${f.code}: ${f.amount.value}`)}`);
602
607
  }
603
608
  };
604
609
  ```
@@ -608,14 +613,14 @@ const paySupplier = async () => {
608
613
  ```ts
609
614
  // Create multiple accounts for different purposes
610
615
  const accounts = await Promise.all([
611
- client.financialAccount.create("Sales Revenue"),
612
- client.financialAccount.create("Operating Expenses"),
613
- client.financialAccount.create("Tax Reserve"),
616
+ client.financialAccount.create("Sales Revenue", "SLE"),
617
+ client.financialAccount.create("Operating Expenses", "SLE"),
618
+ client.financialAccount.create("Tax Reserve", "SLE"),
614
619
  ]);
615
620
 
616
621
  // Check if all accounts were created successfully
617
622
  if (accounts.every(acc => acc.success)) {
618
- const [salesAccount, expensesAccount, taxAccount] = accounts.map(acc => acc.data!.result.id);
623
+ const [salesAccount, expensesAccount, taxAccount] = accounts.map(acc => acc.data!.id);
619
624
 
620
625
  // Distribute revenue: 70% operations, 30% tax reserve
621
626
  const revenue = 100000; // 1000.00 SLE
@@ -628,7 +633,7 @@ if (accounts.every(acc => acc.success)) {
628
633
  transfers.forEach((transfer, index) => {
629
634
  const purpose = index === 0 ? 'operations' : 'tax reserve';
630
635
  if (transfer.success) {
631
- console.log(`${purpose} transfer: ${transfer.data!.result.id}`);
636
+ console.log(`${purpose} transfer: ${transfer.data!.id}`);
632
637
  }
633
638
  });
634
639
  }
@@ -637,8 +642,8 @@ if (accounts.every(acc => acc.success)) {
637
642
  ### Transaction Monitoring & Reporting
638
643
 
639
644
  ```ts
640
- // Get all transactions for reporting
641
- const transactions = await client.financialTransaction.getAll();
645
+ // List all transactions for reporting
646
+ const transactions = await client.financialTransaction.list();
642
647
 
643
648
  if (transactions.success) {
644
649
  const txs = transactions.data!.result;
@@ -659,9 +664,9 @@ if (transactions.success) {
659
664
  const accountIds = [...new Set(txs.map(tx => tx.financialAccount.id))];
660
665
 
661
666
  for (const accountId of accountIds) {
662
- const account = await client.financialAccount.get(accountId);
667
+ const account = await client.financialAccount.retrieve(accountId);
663
668
  if (account.success) {
664
- console.log(`Account ${accountId}: ${account.data!.result.balance.available.value} SLE`);
669
+ console.log(`Account ${accountId}: ${account.data!.balance.available.value} SLE`);
665
670
  }
666
671
  }
667
672
  }
@@ -704,7 +709,7 @@ const createTransferWithRetry = async (
704
709
  // Usage
705
710
  try {
706
711
  const transfer = await createTransferWithRetry("fa-source", "fa-dest", 10000);
707
- console.log("Transfer successful:", transfer.data!.result.id);
712
+ console.log("Transfer successful:", transfer.data!.id);
708
713
  } catch (error) {
709
714
  console.error("Transfer failed permanently:", error.message);
710
715
  }
@@ -746,8 +751,11 @@ await client.financialAccount.create("name");
746
751
  ## Error Handling
747
752
 
748
753
  - **Standard envelope**: every call returns `{ success, data?, error? }`.
749
- - **Validation**: inputs are validated (e.g. non-empty IDs, positive amounts) and will short-circuit with `success: false` + `Error`.
750
- - **Axios errors**: when available, `axios` errors are propagated. You can check details with `axios.isAxiosError(error)`.
754
+ - **Validation**: inputs are validated (e.g. non-empty IDs, positive amounts) and will short-circuit with `success: false` + `MonimeValidationError`.
755
+ - **MonimeError**: remote errors are returned as `MonimeError` objects, which include:
756
+ - `status`: HTTP status code (e.g. 401, 404)
757
+ - `requestId`: The unique request ID from Monime's servers
758
+ - `details`: Rich error details from the API
751
759
 
752
760
  ---
753
761
 
@@ -779,9 +787,9 @@ import type {
779
787
  ClientOptions,
780
788
 
781
789
  // Payment types
782
- GetPayment,
783
- ListPayments,
784
- PatchPayment,
790
+ RetrievePaymentResponse,
791
+ ListPaymentsResponse,
792
+ UpdatePaymentResponse,
785
793
 
786
794
  // Webhook types
787
795
  CreateWebhookRequest,
@@ -803,34 +811,34 @@ import type {
803
811
  GetProviderKycResponse,
804
812
 
805
813
  // Financial Account types
806
- CreateFinancialAccount,
807
- GetFinancialAccount,
808
- AllFinancialAccount,
814
+ CreateFinancialAccountResponse,
815
+ RetrieveFinancialAccountResponse,
816
+ ListFinancialAccountsResponse,
809
817
 
810
818
  // Internal Transfer types
811
- CreateInternalTransfer,
812
- InternalTransfer,
813
- AllInternalTransfers,
819
+ CreateInternalTransferResponse,
820
+ RetrieveInternalTransferResponse,
821
+ ListInternalTransfersResponse,
814
822
 
815
823
  // Payment Code types
816
- CreatePaymentCode,
817
- GetAllPaymentCode,
818
- GetOne,
824
+ CreatePaymentCodeResponse,
825
+ ListPaymentCodesResponse,
826
+ RetrievePaymentCodeResponse,
819
827
 
820
828
  // Payout types
821
829
  DestinationOption,
822
- CreatePayout,
823
- GetAll,
824
- GetOnePayout,
830
+ CreatePayoutResponse,
831
+ ListPayoutsResponse,
832
+ RetrievePayoutResponse,
825
833
 
826
834
  // Financial Transaction types
827
- GetTransaction,
828
- AllTransaction,
835
+ RetrieveTransactionResponse,
836
+ ListTransactionsResponse,
829
837
 
830
838
  // Checkout Session types
831
- CreateCheckout,
832
- AllCheckout,
833
- OneCheckout,
839
+ CreateCheckoutResponse,
840
+ ListCheckoutsResponse,
841
+ RetrieveCheckoutResponse,
834
842
  } from "monime-package";
835
843
  ```
836
844
 
@@ -842,7 +850,7 @@ All API responses follow this consistent pattern:
842
850
  type Result<T> = {
843
851
  success: boolean;
844
852
  data?: T;
845
- error?: Error;
853
+ error?: Error | MonimeError;
846
854
  };
847
855
  ```
848
856
 
@@ -880,146 +888,130 @@ type DestinationOption =
880
888
  ```ts
881
889
  // Account creation/retrieval response
882
890
  interface CreateFinancialAccount {
883
- success: boolean;
884
- messages: string[];
885
- result: {
886
- id: string; // Unique account ID
887
- uvan: string; // Internal identifier
888
- name: string; // Account name
889
- currency: string; // Always "SLE" (Sierra Leone)
890
- reference: string; // Account reference
891
- description: string; // Account description
892
- balance: {
893
- available: {
894
- currency: string;
895
- value: number; // Balance in cents (SLE)
896
- };
891
+ id: string; // Unique account ID
892
+ uvan: string; // Internal identifier
893
+ name: string; // Account name
894
+ currency: string; // Always "SLE"
895
+ reference: string; // Account reference
896
+ description: string; // Account description
897
+ balance: {
898
+ available: {
899
+ currency: string;
900
+ value: number; // Balance in cents (SLE)
897
901
  };
898
- createTime: string; // ISO timestamp
899
- updateTime: string; // ISO timestamp
900
902
  };
903
+ createTime: string; // ISO timestamp
904
+ updateTime: string; // ISO timestamp
901
905
  }
902
906
  ```
903
907
 
904
908
  #### Internal Transfer Types
905
909
  ```ts
906
- interface CreateInternalTransfer {
907
- success: boolean;
908
- messages: string[];
909
- result: {
910
- id: string; // Transfer ID
911
- status: string; // Transfer status
912
- amount: {
913
- currency: string;
914
- value: number; // Amount in cents
915
- };
916
- sourceFinancialAccount: { id: string };
917
- destinationFinancialAccount: { id: string };
918
- financialTransactionReference: string;
919
- description: string;
920
- failureDetail: {
921
- code: string;
922
- message: string;
923
- };
924
- ownershipGraph: {
910
+ interface CreateInternalTransferResponse {
911
+ id: string; // Transfer ID
912
+ status: string; // Transfer status
913
+ amount: {
914
+ currency: string;
915
+ value: number; // Amount in cents
916
+ };
917
+ sourceFinancialAccount: { id: string };
918
+ destinationFinancialAccount: { id: string };
919
+ financialTransactionReference: string;
920
+ description: string;
921
+ failureDetail: {
922
+ code: string;
923
+ message: string;
924
+ };
925
+ ownershipGraph: {
926
+ owner: {
927
+ id: string;
928
+ type: string;
925
929
  owner: {
926
930
  id: string;
927
931
  type: string;
928
- owner: {
929
- id: string;
930
- type: string;
931
- };
932
932
  };
933
933
  };
934
- createTime: string;
935
- updateTime: string;
936
934
  };
935
+ createTime: string;
936
+ updateTime: string;
937
937
  }
938
938
  ```
939
939
 
940
940
  #### Payment Code Types
941
941
  ```ts
942
- interface CreatePaymentCode {
943
- success: boolean;
944
- messages: string[];
945
- result: {
946
- id: string;
947
- mode: string; // "recurrent"
948
- status: string; // Payment status
949
- name: string; // Payment name
950
- amount: {
942
+ interface CreatePaymentCodeResponse {
943
+ id: string;
944
+ mode: string; // "recurrent"
945
+ status: string; // Payment status
946
+ name: string; // Payment name
947
+ amount: {
948
+ currency: string;
949
+ value: number; // Amount in cents
950
+ };
951
+ enable: boolean;
952
+ expireTime: string; // ISO timestamp
953
+ customer: { name: string };
954
+ ussdCode: string; // USSD code for payment
955
+ reference: string;
956
+ authorizedProviders: string[];
957
+ authorizedPhoneNumber: string;
958
+ recurrentPaymentTarget: {
959
+ expectedPaymentCount: number;
960
+ expectedPaymentTotal: {
951
961
  currency: string;
952
- value: number; // Amount in cents
953
- };
954
- enable: boolean;
955
- expireTime: string; // ISO timestamp
956
- customer: { name: string };
957
- ussdCode: string; // USSD code for payment
958
- reference: string;
959
- authorizedProviders: string[];
960
- authorizedPhoneNumber: string;
961
- recurrentPaymentTarget: {
962
- expectedPaymentCount: number;
963
- expectedPaymentTotal: {
964
- currency: string;
965
- value: number;
966
- };
962
+ value: number;
967
963
  };
968
- financialAccountId: string;
969
- processedPaymentData: {
970
- amount: { currency: string; value: number };
971
- orderId: string;
972
- paymentId: string;
973
- orderNumber: string;
974
- channelData: {
975
- providerId: string;
976
- accountId: string;
977
- reference: string;
978
- };
979
- financialTransactionReference: string;
964
+ };
965
+ financialAccountId: string;
966
+ processedPaymentData: {
967
+ amount: { currency: string; value: number };
968
+ orderId: string;
969
+ paymentId: string;
970
+ orderNumber: string;
971
+ channelData: {
972
+ providerId: string;
973
+ accountId: string;
974
+ reference: string;
980
975
  };
981
- createTime: string;
982
- updateTime: string;
983
- ownershipGraph: OwnershipGraph;
976
+ financialTransactionReference: string;
984
977
  };
978
+ createTime: string;
979
+ updateTime: string;
980
+ ownershipGraph: OwnershipGraph;
985
981
  }
986
982
  ```
987
983
 
988
984
  #### Checkout Session Types
989
985
  ```ts
990
- interface CreateCheckout {
991
- success: boolean;
992
- messages: string[];
993
- result: {
994
- id: string;
995
- status: string;
996
- name: string;
997
- orderNumber: string; // Generated order number
998
- reference: string;
999
- description: string;
1000
- redirectUrl: string; // Checkout page URL
1001
- cancelUrl: string;
1002
- successUrl: string;
1003
- lineItems: {
1004
- data: Array<{
1005
- type: string;
1006
- id: string;
1007
- name: string;
1008
- price: { currency: string; value: number };
1009
- quantity: number;
1010
- reference: string;
1011
- description: string;
1012
- images: string[];
1013
- }>;
1014
- };
1015
- financialAccountId: string;
1016
- brandingOptions: {
1017
- primaryColor: string;
1018
- };
1019
- expireTime: string;
1020
- createTime: string;
1021
- ownershipGraph: OwnershipGraph;
986
+ interface CreateCheckoutResponse {
987
+ id: string;
988
+ status: string;
989
+ name: string;
990
+ orderNumber: string; // Generated order number
991
+ reference: string;
992
+ description: string;
993
+ redirectUrl: string; // Checkout page URL
994
+ cancelUrl: string;
995
+ successUrl: string;
996
+ lineItems: {
997
+ data: Array<{
998
+ type: string;
999
+ id: string;
1000
+ name: string;
1001
+ price: { currency: string; value: number };
1002
+ quantity: number;
1003
+ reference: string;
1004
+ description: string;
1005
+ images: string[];
1006
+ }>;
1007
+ };
1008
+ financialAccountId: string;
1009
+ brandingOptions: {
1010
+ primaryColor: string;
1022
1011
  };
1012
+ expireTime: string;
1013
+ createTime: string;
1014
+ ownershipGraph: OwnershipGraph;
1023
1015
  }
1024
1016
  ```
1025
1017
 
@@ -1054,8 +1046,8 @@ interface Amount {
1054
1046
 
1055
1047
  ```ts
1056
1048
  // Type-safe account creation
1057
- const createAccountTyped = async (name: string): Promise<CreateFinancialAccount | null> => {
1058
- const result = await client.financialAccount.create(name);
1049
+ const createAccountTyped = async (name: string): Promise<CreateFinancialAccountResponse | null> => {
1050
+ const result = await client.financialAccount.create(name, "SLE");
1059
1051
  return result.success ? result.data! : null;
1060
1052
  };
1061
1053
 
@@ -1064,7 +1056,7 @@ const createMobileMoneyPayout = async (
1064
1056
  amount: number,
1065
1057
  phoneNumber: string,
1066
1058
  sourceAccount: string
1067
- ): Promise<CreatePayout | null> => {
1059
+ ): Promise<CreatePayoutResponse | null> => {
1068
1060
  const destination: DestinationOption = {
1069
1061
  type: "momo",
1070
1062
  providerId: "m17",
@@ -1077,12 +1069,12 @@ const createMobileMoneyPayout = async (
1077
1069
 
1078
1070
  // Type-safe transaction processing
1079
1071
  const processTransactions = async (): Promise<void> => {
1080
- const txResult = await client.financialTransaction.getAll();
1072
+ const txResult = await client.financialTransaction.list();
1081
1073
 
1082
1074
  if (txResult.success && txResult.data) {
1083
- const transactions: AllTransaction = txResult.data;
1075
+ const transactions: ListTransactionsResponse = txResult.data;
1084
1076
 
1085
- transactions.result.forEach((tx: GetTransaction['result']) => {
1077
+ transactions.result.forEach((tx: RetrieveTransactionResponse) => {
1086
1078
  console.log(`Transaction ${tx.id}: ${tx.amount.value / 100} ${tx.amount.currency}`);
1087
1079
  });
1088
1080
  }