monime-package 1.0.4 → 1.0.6

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/dist/index.mjs CHANGED
@@ -1,7 +1,150 @@
1
- // src/modules/financialAccount/financialAccount.ts
1
+ // src/modules/checkout session/checkoutSession.ts
2
2
  import axios from "axios";
3
+ var URL = "https://api.monime.io/v1/checkout-sessions";
4
+ async function createCheckout(client, name, amount, quantity, successUrl, cancelUrl, description, financialAccountId, primaryColor, images) {
5
+ const { monimeSpaceId, accessToken } = client._getConfig();
6
+ const body = {
7
+ name,
8
+ description,
9
+ cancelUrl,
10
+ successUrl,
11
+ callbackState: null,
12
+ reference: null,
13
+ financialAccountId,
14
+ lineItems: [
15
+ {
16
+ type: "custom",
17
+ name,
18
+ price: {
19
+ currency: "SLE",
20
+ value: amount
21
+ },
22
+ quantity,
23
+ reference: null,
24
+ description,
25
+ images
26
+ }
27
+ ],
28
+ paymentOptions: {
29
+ card: {
30
+ disable: false
31
+ },
32
+ bank: {
33
+ disable: false,
34
+ enabledProviders: ["slb001", "slb004", "slb007"]
35
+ // disabledProviders: ["slb001"],
36
+ },
37
+ momo: {
38
+ disable: false,
39
+ enabledProviders: ["m17", "m18"]
40
+ // disabledProviders: ["m17"],
41
+ },
42
+ wallet: {
43
+ disable: false,
44
+ enabledProviders: ["dw001"]
45
+ // disabledProviders: ["dw001"],
46
+ }
47
+ },
48
+ brandingOptions: {
49
+ primaryColor
50
+ },
51
+ metadata: {}
52
+ };
53
+ try {
54
+ const res = await axios.patch(URL, body, {
55
+ headers: {
56
+ "Monime-Space-Id": monimeSpaceId,
57
+ Authorization: `Bearer ${accessToken}`
58
+ }
59
+ });
60
+ const data = res.data;
61
+ return { success: true, data };
62
+ } catch (error) {
63
+ if (axios.isAxiosError(error)) {
64
+ return { error, success: false };
65
+ }
66
+ return { error: new Error("unknown error"), success: false };
67
+ }
68
+ }
69
+ async function getAllCheckout(client) {
70
+ const { accessToken, monimeSpaceId } = client._getConfig();
71
+ try {
72
+ const res = await axios.get(URL, {
73
+ headers: {
74
+ "Monime-Space-Id": monimeSpaceId,
75
+ Authorization: `Bearer ${accessToken}`
76
+ }
77
+ });
78
+ const data = res.data;
79
+ return { success: true, data };
80
+ } catch (error) {
81
+ if (axios.isAxiosError(error)) {
82
+ return { error, success: false };
83
+ }
84
+ return { error: new Error("unknown error"), success: false };
85
+ }
86
+ }
87
+ async function getOnecheckout(client, checkoutId) {
88
+ const { accessToken, monimeSpaceId } = client._getConfig();
89
+ try {
90
+ const res = await axios.get(`${URL}/${checkoutId}`, {
91
+ headers: {
92
+ "Monime-Space-Id": monimeSpaceId,
93
+ Authorization: `Bearer ${accessToken}`
94
+ }
95
+ });
96
+ const data = res.data;
97
+ return { success: true, data };
98
+ } catch (error) {
99
+ if (axios.isAxiosError(error)) {
100
+ return { error, success: false };
101
+ }
102
+ return { error: new Error("unknown error"), success: false };
103
+ }
104
+ }
105
+ async function deleteCheckout(client, checkoutId) {
106
+ const { accessToken, monimeSpaceId } = client._getConfig();
107
+ try {
108
+ await axios.delete(`${URL}/${checkoutId}`, {
109
+ headers: {
110
+ "Monime-Space-Id": monimeSpaceId,
111
+ Authorization: `Bearer ${accessToken}`
112
+ }
113
+ });
114
+ return { success: true };
115
+ } catch (error) {
116
+ if (axios.isAxiosError(error)) {
117
+ return { error, success: false };
118
+ }
119
+ return { error: new Error("unknown error"), success: false };
120
+ }
121
+ }
122
+
123
+ // src/modules/checkout session/index.ts
124
+ function CheckoutSessionAPI(client) {
125
+ return {
126
+ create: (name, amount, quantity, successUrl, cancelUrl, description, financialAccountId, primaryColor, images) => createCheckout(
127
+ client,
128
+ name,
129
+ amount,
130
+ quantity,
131
+ successUrl,
132
+ cancelUrl,
133
+ description,
134
+ financialAccountId,
135
+ primaryColor,
136
+ images
137
+ ),
138
+ get: () => getAllCheckout(client),
139
+ getOne: (checkoutId) => getOnecheckout(client, checkoutId),
140
+ delete: (checkoutId) => deleteCheckout(client, checkoutId)
141
+ };
142
+ }
143
+
144
+ // src/modules/financialAccount/financialAccount.ts
3
145
  import { randomBytes } from "crypto";
4
- var URL = "https://api.monime.io/v1/financial-accounts";
146
+ import axios2 from "axios";
147
+ var URL2 = "https://api.monime.io/v1/financial-accounts";
5
148
  var value = randomBytes(20).toString("hex");
6
149
  async function createFinancialAccount(accountName, client) {
7
150
  if (accountName.trim() === "") {
@@ -15,7 +158,7 @@ async function createFinancialAccount(accountName, client) {
15
158
  };
16
159
  const { accessToken, monimeSpaceId } = client._getConfig();
17
160
  try {
18
- const res = await axios.post(URL, body, {
161
+ const res = await axios2.post(URL2, body, {
19
162
  headers: {
20
163
  "Idempotency-Key": `${value}`,
21
164
  "Monime-Space-Id": `${monimeSpaceId}`,
@@ -26,7 +169,7 @@ async function createFinancialAccount(accountName, client) {
26
169
  const data = res.data;
27
170
  return { success: true, data };
28
171
  } catch (error) {
29
- if (axios.isAxiosError(error)) {
172
+ if (axios2.isAxiosError(error)) {
30
173
  return { error, success: false };
31
174
  }
32
175
  return { error: new Error("unknown error"), success: false };
@@ -34,11 +177,14 @@ async function createFinancialAccount(accountName, client) {
34
177
  }
35
178
  async function getFinancialAccount(financialAccountId, client) {
36
179
  if (financialAccountId.trim() === "") {
37
- return { success: false, error: new Error("financialAccountId is required") };
180
+ return {
181
+ success: false,
182
+ error: new Error("financialAccountId is required")
183
+ };
38
184
  }
39
185
  const { monimeSpaceId, accessToken } = client._getConfig();
40
186
  try {
41
- const res = await axios.get(`${URL}/${financialAccountId}`, {
187
+ const res = await axios2.get(`${URL2}/${financialAccountId}`, {
42
188
  headers: {
43
189
  "Monime-Space-Id": `${monimeSpaceId}`,
44
190
  Authorization: `Bearer ${accessToken}`
@@ -47,29 +193,116 @@ async function getFinancialAccount(financialAccountId, client) {
47
193
  const data = res.data;
48
194
  return { success: true, data };
49
195
  } catch (error) {
50
- if (axios.isAxiosError(error)) {
196
+ if (axios2.isAxiosError(error)) {
197
+ return { error, success: false };
198
+ }
199
+ return { error: new Error("unknown error"), success: false };
200
+ }
201
+ }
202
+ async function getAllFinancialAccount(client) {
203
+ const { monimeSpaceId, accessToken } = client._getConfig();
204
+ try {
205
+ const res = await axios2.get(URL2, {
206
+ headers: {
207
+ "Monime-Space-Id": `${monimeSpaceId}`,
208
+ Authorization: `Bearer ${accessToken}`
209
+ }
210
+ });
211
+ const data = res.data;
212
+ return { success: true, data };
213
+ } catch (error) {
214
+ if (axios2.isAxiosError(error)) {
215
+ return { error, success: false };
216
+ }
217
+ return { error: new Error("unknown error"), success: false };
218
+ }
219
+ }
220
+
221
+ // src/modules/financialAccount/index.ts
222
+ function FinancialAccountAPI(client) {
223
+ return {
224
+ create: (name) => createFinancialAccount(name, client),
225
+ get: (financialAccountId) => getFinancialAccount(financialAccountId, client),
226
+ getAll: () => getAllFinancialAccount(client)
227
+ };
228
+ }
229
+
230
+ // src/modules/financialTransaction/financialTransaction.ts
231
+ import axios3 from "axios";
232
+ var URL3 = "https://api.monime.io/v1/financial-transactions";
233
+ async function getAllTransaction(client) {
234
+ const { monimeSpaceId, accessToken } = client._getConfig();
235
+ try {
236
+ const res = await axios3.get(URL3, {
237
+ headers: {
238
+ Authorization: `Bearer ${accessToken}`,
239
+ "Monime-Space-Id": `${monimeSpaceId}`
240
+ }
241
+ });
242
+ const data = res.data;
243
+ return { success: true, data };
244
+ } catch (error) {
245
+ if (axios3.isAxiosError(error)) {
246
+ return { error, success: false };
247
+ }
248
+ return { error: new Error("unknown error"), success: false };
249
+ }
250
+ }
251
+ async function getTransaction(client, transactionId) {
252
+ const { accessToken, monimeSpaceId } = client._getConfig();
253
+ if (transactionId.trim() === "") {
254
+ return {
255
+ error: new Error("transactionId must not be empty"),
256
+ success: false
257
+ };
258
+ }
259
+ try {
260
+ const res = await axios3.get(`${URL3}/${transactionId}`, {
261
+ headers: {
262
+ Authorization: `Bearer ${accessToken}`,
263
+ "Monime-Space-Id": `${monimeSpaceId}`
264
+ }
265
+ });
266
+ const data = res.data;
267
+ return { success: true, data };
268
+ } catch (error) {
269
+ if (axios3.isAxiosError(error)) {
51
270
  return { error, success: false };
52
271
  }
53
272
  return { error: new Error("unknown error"), success: false };
54
273
  }
55
274
  }
56
275
 
276
+ // src/modules/financialTransaction/index.ts
277
+ function FinancialTransactionAPI(client) {
278
+ return {
279
+ get: (transactionId) => getTransaction(client, transactionId),
280
+ getAll: () => getAllTransaction(client)
281
+ };
282
+ }
283
+
57
284
  // src/modules/internalTransfer/internalTransfer.ts
58
- import axios2 from "axios";
59
285
  import { randomBytes as randomBytes2 } from "crypto";
60
- var URL2 = "https://api.monime.io/v1/internal-transfers";
286
+ import axios4 from "axios";
287
+ var URL4 = "https://api.monime.io/v1/internal-transfers";
61
288
  var value2 = randomBytes2(20).toString("hex");
62
- async function createInternalTransfer(sourceAccount, destinationAccount, client, value5) {
63
- if (value5 <= 0) {
64
- return { success: false, error: new Error("value must be larger that zero") };
289
+ async function createInternalTransfer(sourceAccount, destinationAccount, client, amount) {
290
+ if (amount <= 0) {
291
+ return {
292
+ success: false,
293
+ error: new Error("amount must be larger that zero")
294
+ };
65
295
  }
66
296
  if (sourceAccount.trim() === "" || destinationAccount.trim() === "") {
67
- return { success: false, error: new Error("sourceAccount or destinationAccount is missing") };
297
+ return {
298
+ success: false,
299
+ error: new Error("sourceAccount or destinationAccount is missing")
300
+ };
68
301
  }
69
302
  const body = {
70
303
  amount: {
71
304
  currency: "SLE",
72
- value: value5
305
+ value: amount
73
306
  },
74
307
  sourceFinancialAccount: {
75
308
  id: sourceAccount
@@ -81,9 +314,9 @@ async function createInternalTransfer(sourceAccount, destinationAccount, client,
81
314
  };
82
315
  const { accessToken, monimeSpaceId } = client._getConfig();
83
316
  try {
84
- const res = await axios2.post(URL2, body, {
317
+ const res = await axios4.post(URL4, body, {
85
318
  headers: {
86
- "Idempotency-Key": `${value5}`,
319
+ "Idempotency-Key": `${value2}`,
87
320
  "Monime-Space-Id": `${monimeSpaceId}`,
88
321
  Authorization: `Bearer ${accessToken}`,
89
322
  "Content-Type": "application/json"
@@ -92,28 +325,102 @@ async function createInternalTransfer(sourceAccount, destinationAccount, client,
92
325
  const data = res.data;
93
326
  return { success: true, data };
94
327
  } catch (error) {
95
- if (axios2.isAxiosError(error)) {
328
+ if (axios4.isAxiosError(error)) {
96
329
  return { error, success: false };
97
330
  }
98
331
  return { error: new Error("unkknown error"), success: false };
99
332
  }
100
333
  }
334
+ async function getAllInternalTransfers(client) {
335
+ const { monimeSpaceId, accessToken } = client._getConfig();
336
+ try {
337
+ const res = await axios4.get(URL4, {
338
+ headers: {
339
+ "Monime-Space-Id": `${monimeSpaceId}`,
340
+ Authorization: `Bearer ${accessToken}`
341
+ }
342
+ });
343
+ const data = res.data;
344
+ return { success: true, data };
345
+ } catch (error) {
346
+ if (axios4.isAxiosError(error)) {
347
+ return { success: false, error };
348
+ }
349
+ return { error: new Error("unkknown error"), success: false };
350
+ }
351
+ }
352
+ async function getInternalTransfer(client, internalTransferId) {
353
+ const { accessToken, monimeSpaceId } = client._getConfig();
354
+ try {
355
+ const res = await axios4.get(`${URL4}/${internalTransferId}`, {
356
+ headers: {
357
+ "Monime-Space-Id": `${monimeSpaceId}`,
358
+ Authorization: `Bearer ${accessToken}`
359
+ }
360
+ });
361
+ const data = res.data;
362
+ return { success: true, data };
363
+ } catch (error) {
364
+ if (axios4.isAxiosError(error)) {
365
+ return { success: false, error };
366
+ }
367
+ return { error: new Error("unkknown error"), success: false };
368
+ }
369
+ }
370
+ async function deleteInternalTransfer(client, internalTransferId) {
371
+ const { monimeSpaceId, accessToken } = client._getConfig();
372
+ try {
373
+ await axios4.delete(`${URL4}/${internalTransferId}`, {
374
+ headers: {
375
+ "Monime-Space-Id": `${monimeSpaceId}`,
376
+ Authorization: `Bearer ${accessToken}`
377
+ }
378
+ });
379
+ return { success: true };
380
+ } catch (error) {
381
+ if (axios4.isAxiosError(error)) {
382
+ return { success: false, error };
383
+ }
384
+ return { success: false, error: new Error("unknown error") };
385
+ }
386
+ }
387
+
388
+ // src/modules/internalTransfer/index.ts
389
+ function InternalTransferAPI(client) {
390
+ return {
391
+ create: (sourceAccount, destinationAccount, amount) => createInternalTransfer(
392
+ sourceAccount,
393
+ destinationAccount,
394
+ client,
395
+ amount
396
+ ),
397
+ get: (internalTransferId) => getInternalTransfer(client, internalTransferId),
398
+ getAll: () => getAllInternalTransfers(client),
399
+ delete: (internalTransferId) => deleteInternalTransfer(client, internalTransferId)
400
+ };
401
+ }
101
402
 
102
403
  // src/modules/paymentCode/paymentCode.ts
103
- import axios3 from "axios";
104
404
  import { randomBytes as randomBytes3 } from "crypto";
405
+ import axios5 from "axios";
105
406
  var value3 = randomBytes3(20).toString("hex");
106
- var URL3 = "https://api.monime.io/v1/payment-codes";
407
+ var URL5 = "https://api.monime.io/v1/payment-codes";
107
408
  async function createPaymentCode(paymentName, amount, financialAccountId, name, phoneNumber, client) {
108
409
  let financialAccount = null;
109
410
  if (financialAccountId !== "") {
110
411
  financialAccount = financialAccountId;
111
412
  }
112
413
  if (paymentName.trim() === "" || name.trim() === "" || phoneNumber.trim() === "") {
113
- return { success: false, error: new Error("paymentName, name, or phoneNumber is missing") };
414
+ return {
415
+ success: false,
416
+ error: new Error("paymentName, name, or phoneNumber is missing")
417
+ };
114
418
  }
115
419
  if (amount <= 0) {
116
- return { success: false, error: new Error("amonut number be greater than zero") };
420
+ return {
421
+ success: false,
422
+ error: new Error("amonut number be greater than zero")
423
+ };
117
424
  }
118
425
  const { accessToken, monimeSpaceId } = client._getConfig();
119
426
  const bodyData = {
@@ -142,7 +449,7 @@ async function createPaymentCode(paymentName, amount, financialAccountId, name,
142
449
  metadata: {}
143
450
  };
144
451
  try {
145
- const res = await axios3.post(URL3, bodyData, {
452
+ const res = await axios5.post(URL5, bodyData, {
146
453
  headers: {
147
454
  "Idempotency-Key": `${value3}`,
148
455
  "Monime-Space-Id": `${monimeSpaceId}`,
@@ -153,7 +460,7 @@ async function createPaymentCode(paymentName, amount, financialAccountId, name,
153
460
  const data = res.data;
154
461
  return { data, success: true };
155
462
  } catch (error) {
156
- if (axios3.isAxiosError(error)) {
463
+ if (axios5.isAxiosError(error)) {
157
464
  return { error: error.response?.data, success: false };
158
465
  }
159
466
  return { error: new Error("unknown error"), success: false };
@@ -165,7 +472,7 @@ async function deletePaymentCode(paymentCodeId, client) {
165
472
  return { success: false, error: new Error("paymentCodeId is required") };
166
473
  }
167
474
  try {
168
- const res = await axios3.delete(`${URL3}/${paymentCodeId}`, {
475
+ await axios5.delete(`${URL5}/${paymentCodeId}`, {
169
476
  headers: {
170
477
  "Idempotency-Key": `${value3}`,
171
478
  "Monime-Space-Id": `${monimeSpaceId}`,
@@ -173,38 +480,85 @@ async function deletePaymentCode(paymentCodeId, client) {
173
480
  "Content-Type": "application/json"
174
481
  }
175
482
  });
483
+ return { success: true };
484
+ } catch (error) {
485
+ if (axios5.isAxiosError(error)) {
486
+ return { error, success: false };
487
+ }
488
+ return { error: new Error("unknown error"), success: false };
489
+ }
490
+ }
491
+ async function getAllPaymentCode(client) {
492
+ const { monimeSpaceId, accessToken } = client._getConfig();
493
+ try {
494
+ const res = await axios5.get(URL5, {
495
+ headers: {
496
+ "Monime-Space-Id": `${monimeSpaceId}`,
497
+ Authorization: `Bearer ${accessToken}`
498
+ }
499
+ });
176
500
  const data = res.data;
177
- if (!data.success) {
178
- return { error: new Error("delete failed"), success: false };
501
+ return { success: true, data };
502
+ } catch (error) {
503
+ if (axios5.isAxiosError(error)) {
504
+ return { error, success: false };
179
505
  }
180
- return { success: true };
506
+ return { error: new Error("unknown error"), success: false };
507
+ }
508
+ }
509
+ async function getPaymentCode(paymentCodeId, client) {
510
+ const { monimeSpaceId, accessToken } = client._getConfig();
511
+ try {
512
+ const res = await axios5.get(`${URL5}/${paymentCodeId}`, {
513
+ headers: {
514
+ "Monime-Space-Id": `${monimeSpaceId}`,
515
+ Authorization: `Bearer ${accessToken}`
516
+ }
517
+ });
518
+ const data = res.data;
519
+ return { success: true, data };
181
520
  } catch (error) {
182
- if (axios3.isAxiosError(error)) {
521
+ if (axios5.isAxiosError(error)) {
183
522
  return { error, success: false };
184
523
  }
185
524
  return { error: new Error("unknown error"), success: false };
186
525
  }
187
526
  }
188
527
 
528
+ // src/modules/paymentCode/index.ts
529
+ function PaymentCodeAPI(client) {
530
+ return {
531
+ create: (paymentName, amount, financialAccount, username, phoneNumber) => createPaymentCode(
532
+ paymentName,
533
+ amount,
534
+ financialAccount,
535
+ username,
536
+ phoneNumber,
537
+ client
538
+ ),
539
+ delete: (paymentCodeId) => deletePaymentCode(paymentCodeId, client),
540
+ getAll: () => getAllPaymentCode(client),
541
+ get: (paymentCodeId) => getPaymentCode(paymentCodeId, client)
542
+ };
543
+ }
544
+
189
545
  // src/modules/payout/payout.ts
190
- import axios4 from "axios";
191
546
  import { randomBytes as randomBytes4 } from "crypto";
192
- var URL4 = "https://api.monime.io/v1/payouts";
547
+ import axios6 from "axios";
548
+ var URL6 = "https://api.monime.io/v1/payouts";
193
549
  var value4 = randomBytes4(20).toString("hex");
194
- async function CreatePayoutMobileMoney(amount, phoneNumber, sourceAccount, client) {
195
- if (phoneNumber.trim() === "") {
196
- return { success: false, error: new Error("phoneNumber is required") };
197
- }
198
- let provider = "m17";
199
- const africell = ["077", "033", "088", "080", "090", "030"];
200
- for (let value5 of africell) {
201
- if (phoneNumber.startsWith(value5)) {
202
- provider = "m18";
203
- break;
204
- }
550
+ async function createPayout(amount, sourceAccount, destination, client) {
551
+ if (sourceAccount.trim() === "") {
552
+ return {
553
+ success: false,
554
+ error: new Error("sourceAccount cannot be empty")
555
+ };
205
556
  }
206
557
  if (amount <= 0) {
207
- return { error: new Error("amount must be greater than 0"), success: false };
558
+ return {
559
+ error: new Error("amount must be greater than 0"),
560
+ success: false
561
+ };
208
562
  }
209
563
  const { accessToken, monimeSpaceId } = client._getConfig();
210
564
  const body = {
@@ -215,15 +569,11 @@ async function CreatePayoutMobileMoney(amount, phoneNumber, sourceAccount, clien
215
569
  source: {
216
570
  financialAccountId: sourceAccount
217
571
  },
218
- destination: {
219
- type: "momo",
220
- provider,
221
- phoneNumber
222
- },
572
+ destination,
223
573
  metadata: {}
224
574
  };
225
575
  try {
226
- const res = await axios4.post(URL4, body, {
576
+ const res = await axios6.post(URL6, body, {
227
577
  headers: {
228
578
  "Idempotency-Key": `${value4}`,
229
579
  "Monime-Space-Id": `${monimeSpaceId}`,
@@ -234,37 +584,95 @@ async function CreatePayoutMobileMoney(amount, phoneNumber, sourceAccount, clien
234
584
  const data = res.data;
235
585
  return { success: true, data };
236
586
  } catch (error) {
237
- if (axios4.isAxiosError(error)) {
587
+ if (axios6.isAxiosError(error)) {
238
588
  return { success: false, error };
239
589
  }
240
590
  return { success: false, error: new Error("unknown error") };
241
591
  }
242
592
  }
593
+ async function getAllPayout(client) {
594
+ const { accessToken, monimeSpaceId } = client._getConfig();
595
+ try {
596
+ const res = await axios6.get(URL6, {
597
+ headers: {
598
+ "Monime-Space-Id": `${monimeSpaceId}`,
599
+ Authorization: `Bearer ${accessToken}`
600
+ }
601
+ });
602
+ const data = res.data;
603
+ return { success: true, data };
604
+ } catch (error) {
605
+ if (axios6.isAxiosError(error)) {
606
+ return { success: false, error };
607
+ }
608
+ return { success: false, error: new Error("unknown error") };
609
+ }
610
+ }
611
+ async function getPayout(payoutId, client) {
612
+ const { accessToken, monimeSpaceId } = client._getConfig();
613
+ try {
614
+ const res = await axios6.get(`${URL6}/${payoutId}`, {
615
+ headers: {
616
+ "Monime-Space-Id": `${monimeSpaceId}`,
617
+ Authorization: `Bearer ${accessToken}`
618
+ }
619
+ });
620
+ const data = res.data;
621
+ return { success: true, data };
622
+ } catch (error) {
623
+ if (axios6.isAxiosError(error)) {
624
+ return { success: false, error };
625
+ }
626
+ return { success: false, error: new Error("unknown error") };
627
+ }
628
+ }
629
+ async function deletePayout(payoutId, client) {
630
+ const { accessToken, monimeSpaceId } = client._getConfig();
631
+ try {
632
+ await axios6.delete(`${URL6}/${payoutId}`, {
633
+ headers: {
634
+ "Monime-Space-Id": `${monimeSpaceId}`,
635
+ Authorization: `Bearer ${accessToken}`
636
+ }
637
+ });
638
+ return { success: true };
639
+ } catch (error) {
640
+ if (axios6.isAxiosError(error)) {
641
+ return { success: false, error };
642
+ }
643
+ return { success: false, error: new Error("unknown error") };
644
+ }
645
+ }
646
+
647
+ // src/modules/payout/index.ts
648
+ function PayoutAPI(client) {
649
+ return {
650
+ create: (amount, destination, sourceAccount) => createPayout(amount, sourceAccount, destination, client),
651
+ get: () => getAllPayout(client),
652
+ getOne: (payoutId) => getPayout(payoutId, client),
653
+ delete: (payoutId) => deletePayout(payoutId, client)
654
+ };
655
+ }
243
656
 
244
657
  // src/client.ts
245
658
  var MonimeClient = class {
246
659
  monimeSpaceId;
247
660
  accessToken;
248
- /* Methods */
249
- //method for financial accounts
250
- createFinancialAccount;
251
- getFinancialAccount;
252
- //method for internal transfer
253
- createInternalTransfer;
254
- //method for payment code
255
- createPaymentCode;
256
- deletePaymentCode;
257
- //method for payout
258
- createPayout;
661
+ financialAccount;
662
+ internalTransfer;
663
+ paymentCode;
664
+ payout;
665
+ financialTransaction;
666
+ checkoutSession;
259
667
  constructor(options) {
260
668
  this.accessToken = options.accessToken;
261
- this.monimeSpaceId = options.monimeSpaceeId;
262
- this.createFinancialAccount = (name) => createFinancialAccount(name, this);
263
- this.getFinancialAccount = (financialAccountId) => getFinancialAccount(financialAccountId, this);
264
- this.createInternalTransfer = (sourceAccount, destinationAccount, amount) => createInternalTransfer(sourceAccount, destinationAccount, this, amount);
265
- this.createPaymentCode = (paymentName, amount, financialAccount, username, phoneNumber) => createPaymentCode(paymentName, amount, financialAccount, username, phoneNumber, this);
266
- this.deletePaymentCode = (paymentCodeId) => deletePaymentCode(paymentCodeId, this);
267
- this.createPayout = (amount, phoneNumber, sourceAccount) => CreatePayoutMobileMoney(amount, phoneNumber, sourceAccount, this);
669
+ this.monimeSpaceId = options.monimeSpaceId;
670
+ this.financialAccount = FinancialAccountAPI(this);
671
+ this.internalTransfer = InternalTransferAPI(this);
672
+ this.paymentCode = PaymentCodeAPI(this);
673
+ this.payout = PayoutAPI(this);
674
+ this.financialTransaction = FinancialTransactionAPI(this);
675
+ this.checkoutSession = CheckoutSessionAPI(this);
268
676
  }
269
677
  /** @internal */
270
678
  _getConfig() {