@ariary/ariary 1.0.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 +120 -0
- package/dist/client-DwMAE1vB.d.mts +38 -0
- package/dist/client-DwMAE1vB.d.ts +38 -0
- package/dist/index.d.mts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +267 -0
- package/dist/index.mjs +225 -0
- package/dist/payment/index.d.mts +54 -0
- package/dist/payment/index.d.ts +54 -0
- package/dist/payment/index.js +86 -0
- package/dist/payment/index.mjs +59 -0
- package/dist/sms/index.d.mts +61 -0
- package/dist/sms/index.d.ts +61 -0
- package/dist/sms/index.js +57 -0
- package/dist/sms/index.mjs +30 -0
- package/dist/transfert/index.d.mts +36 -0
- package/dist/transfert/index.d.ts +36 -0
- package/dist/transfert/index.js +51 -0
- package/dist/transfert/index.mjs +24 -0
- package/package.json +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# ariari
|
|
2
|
+
|
|
3
|
+
SDK officiel pour l'API de paiement Ariary. Permet d'envoyer des paiements, des SMS et des transferts d'argent.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ariary/ariary
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { AriarySDK } from '@ariary/ariary';
|
|
15
|
+
|
|
16
|
+
const sdk = new AriarySDK({
|
|
17
|
+
secretId: 'votre_secret_id',
|
|
18
|
+
projectId: 'votre_project_id'
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Utilisation
|
|
23
|
+
|
|
24
|
+
### Paiement
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Créer un paiement
|
|
28
|
+
const payment = await sdk.payment.createPayment({
|
|
29
|
+
code: 'PAY-K1X2Y3Z4-ABC123',
|
|
30
|
+
amount: 5000,
|
|
31
|
+
projectId: 'votre_project_id'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
console.log(payment);
|
|
35
|
+
// {
|
|
36
|
+
// id: "...",
|
|
37
|
+
// amount: 5000,
|
|
38
|
+
// rest: 0,
|
|
39
|
+
// status: "payé",
|
|
40
|
+
// ...
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
// Récupérer tous les paiements
|
|
44
|
+
const allPayments = await sdk.payment.getAllPayments();
|
|
45
|
+
|
|
46
|
+
// Récupérer un paiement par ID
|
|
47
|
+
const payment = await sdk.payment.getPaymentById(paymentId);
|
|
48
|
+
|
|
49
|
+
// Mettre à jour le reste d'un paiement
|
|
50
|
+
const updated = await sdk.payment.updatePaymentRest(paymentId, 'TICKET123');
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### SMS
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// Envoyer un SMS à un ou plusieurs numéros
|
|
57
|
+
const result = await sdk.sms.notify('Bonjour!', ['261345678901', '261345678902']);
|
|
58
|
+
|
|
59
|
+
// Envoyer des SMS différents
|
|
60
|
+
const result = await sdk.sms.notifyBulk([
|
|
61
|
+
{ message: 'Message 1', numbers: '261345678901' },
|
|
62
|
+
{ message: 'Message 2', numbers: '261345678902' }
|
|
63
|
+
]);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Transfer
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// Envoyer une transaction
|
|
70
|
+
const transaction = await sdk.transfer.send('261345678901', 5000);
|
|
71
|
+
|
|
72
|
+
// Récupérer toutes les transactions
|
|
73
|
+
const allTransactions = await sdk.transfer.getAll();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Imports
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { AriarySDK, PaymentService, SmsService, TransferService } from '@ariary/ariary';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Types
|
|
83
|
+
|
|
84
|
+
Tous les types TypeScript sont inclus automatiquement (.d.ts).
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// Payment
|
|
88
|
+
- CreatePaymentDto
|
|
89
|
+
- PaymentResponseDto
|
|
90
|
+
|
|
91
|
+
// SMS
|
|
92
|
+
- SendSmsDto
|
|
93
|
+
- BulkSmsDto
|
|
94
|
+
- SendSmsResponseDto
|
|
95
|
+
- MultiSmsResponseDto
|
|
96
|
+
- BulkSmsResponseDto
|
|
97
|
+
- ResponseSmsDto
|
|
98
|
+
|
|
99
|
+
// Transfer
|
|
100
|
+
- SendTransactionDto
|
|
101
|
+
- SendTransactionResponse
|
|
102
|
+
- TransactionResponseDto
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## API
|
|
106
|
+
|
|
107
|
+
### AriarySDK
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
new AriarySDK(config: ApiConfig)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**config:**
|
|
114
|
+
- `secretId: string` - Votre ID secret
|
|
115
|
+
- `projectId: string` - Votre ID projet
|
|
116
|
+
- `baseUrl?: string` - URL de base pour tous les services (optionnel, par défaut: https://back.ariari.mg/payment/api-docs)
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
ISC
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface ApiResponse<T> {
|
|
2
|
+
status: string;
|
|
3
|
+
data?: T;
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
interface ApiConfig {
|
|
7
|
+
secretId: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare class ApiClient {
|
|
13
|
+
private client;
|
|
14
|
+
private config;
|
|
15
|
+
constructor(config: ApiConfig, baseUrl?: string);
|
|
16
|
+
/**
|
|
17
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
18
|
+
*/
|
|
19
|
+
post<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
22
|
+
*/
|
|
23
|
+
get<T>(endpoint: string, requiresSecret?: boolean): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
26
|
+
*/
|
|
27
|
+
patch<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
30
|
+
*/
|
|
31
|
+
put<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Gère les erreurs API
|
|
34
|
+
*/
|
|
35
|
+
private handleError;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { type ApiConfig as A, ApiClient as a, type ApiResponse as b };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface ApiResponse<T> {
|
|
2
|
+
status: string;
|
|
3
|
+
data?: T;
|
|
4
|
+
message?: string;
|
|
5
|
+
}
|
|
6
|
+
interface ApiConfig {
|
|
7
|
+
secretId: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare class ApiClient {
|
|
13
|
+
private client;
|
|
14
|
+
private config;
|
|
15
|
+
constructor(config: ApiConfig, baseUrl?: string);
|
|
16
|
+
/**
|
|
17
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
18
|
+
*/
|
|
19
|
+
post<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
22
|
+
*/
|
|
23
|
+
get<T>(endpoint: string, requiresSecret?: boolean): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
26
|
+
*/
|
|
27
|
+
patch<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
30
|
+
*/
|
|
31
|
+
put<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Gère les erreurs API
|
|
34
|
+
*/
|
|
35
|
+
private handleError;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { type ApiConfig as A, ApiClient as a, type ApiResponse as b };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PaymentService, PaymentResponseDto } from './payment/index.mjs';
|
|
2
|
+
export { CreatePaymentDto } from './payment/index.mjs';
|
|
3
|
+
import { SmsService } from './sms/index.mjs';
|
|
4
|
+
export { BulkSmsDto, BulkSmsResponseDto, CreateSmsDto, MultiSmsResponseDto, ResponseSmsDto, SendSmsDto, SendSmsResponseDto } from './sms/index.mjs';
|
|
5
|
+
import { TransferService } from './transfert/index.mjs';
|
|
6
|
+
export { SendTransactionDto, SendTransactionResponse, TransactionResponseDto } from './transfert/index.mjs';
|
|
7
|
+
import { A as ApiConfig } from './client-DwMAE1vB.mjs';
|
|
8
|
+
export { a as ApiClient, b as ApiResponse } from './client-DwMAE1vB.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SDK client pour l'API de paiement Ariary
|
|
12
|
+
*/
|
|
13
|
+
declare class AriarySDK {
|
|
14
|
+
private paymentClient;
|
|
15
|
+
private defaultClient;
|
|
16
|
+
payment: PaymentService;
|
|
17
|
+
sms: SmsService;
|
|
18
|
+
transfer: TransferService;
|
|
19
|
+
constructor(config: ApiConfig);
|
|
20
|
+
}
|
|
21
|
+
declare function sendPayment(code: string, amount: number, projectId: string, secretId: string): Promise<PaymentResponseDto>;
|
|
22
|
+
|
|
23
|
+
export { ApiConfig, AriarySDK, PaymentResponseDto, PaymentService, SmsService, TransferService, sendPayment };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PaymentService, PaymentResponseDto } from './payment/index.js';
|
|
2
|
+
export { CreatePaymentDto } from './payment/index.js';
|
|
3
|
+
import { SmsService } from './sms/index.js';
|
|
4
|
+
export { BulkSmsDto, BulkSmsResponseDto, CreateSmsDto, MultiSmsResponseDto, ResponseSmsDto, SendSmsDto, SendSmsResponseDto } from './sms/index.js';
|
|
5
|
+
import { TransferService } from './transfert/index.js';
|
|
6
|
+
export { SendTransactionDto, SendTransactionResponse, TransactionResponseDto } from './transfert/index.js';
|
|
7
|
+
import { A as ApiConfig } from './client-DwMAE1vB.js';
|
|
8
|
+
export { a as ApiClient, b as ApiResponse } from './client-DwMAE1vB.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SDK client pour l'API de paiement Ariary
|
|
12
|
+
*/
|
|
13
|
+
declare class AriarySDK {
|
|
14
|
+
private paymentClient;
|
|
15
|
+
private defaultClient;
|
|
16
|
+
payment: PaymentService;
|
|
17
|
+
sms: SmsService;
|
|
18
|
+
transfer: TransferService;
|
|
19
|
+
constructor(config: ApiConfig);
|
|
20
|
+
}
|
|
21
|
+
declare function sendPayment(code: string, amount: number, projectId: string, secretId: string): Promise<PaymentResponseDto>;
|
|
22
|
+
|
|
23
|
+
export { ApiConfig, AriarySDK, PaymentResponseDto, PaymentService, SmsService, TransferService, sendPayment };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
ApiClient: () => ApiClient,
|
|
34
|
+
AriarySDK: () => AriarySDK,
|
|
35
|
+
PaymentService: () => PaymentService,
|
|
36
|
+
SmsService: () => SmsService,
|
|
37
|
+
TransferService: () => TransferService,
|
|
38
|
+
sendPayment: () => sendPayment
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(src_exports);
|
|
41
|
+
|
|
42
|
+
// src/client.ts
|
|
43
|
+
var import_axios = __toESM(require("axios"));
|
|
44
|
+
var ApiClient = class {
|
|
45
|
+
constructor(config, baseUrl) {
|
|
46
|
+
this.config = config;
|
|
47
|
+
const finalBaseUrl = baseUrl || config.baseUrl || "https://back.ariari.mg/payment/api-docs";
|
|
48
|
+
this.client = import_axios.default.create({
|
|
49
|
+
baseURL: finalBaseUrl,
|
|
50
|
+
headers: {
|
|
51
|
+
"Content-Type": "application/json"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
57
|
+
*/
|
|
58
|
+
async post(endpoint, data, requiresSecret = true) {
|
|
59
|
+
const headers = {
|
|
60
|
+
"x-project-id": this.config.projectId
|
|
61
|
+
};
|
|
62
|
+
if (requiresSecret) {
|
|
63
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const response = await this.client.post(endpoint, data, { headers });
|
|
67
|
+
return response.data;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
throw this.handleError(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
74
|
+
*/
|
|
75
|
+
async get(endpoint, requiresSecret = true) {
|
|
76
|
+
const headers = {
|
|
77
|
+
"x-project-id": this.config.projectId
|
|
78
|
+
};
|
|
79
|
+
if (requiresSecret) {
|
|
80
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const response = await this.client.get(endpoint, { headers });
|
|
84
|
+
return response.data;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw this.handleError(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
91
|
+
*/
|
|
92
|
+
async patch(endpoint, data, requiresSecret = true) {
|
|
93
|
+
const headers = {
|
|
94
|
+
"x-project-id": this.config.projectId
|
|
95
|
+
};
|
|
96
|
+
if (requiresSecret) {
|
|
97
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const response = await this.client.patch(endpoint, data, { headers });
|
|
101
|
+
return response.data;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw this.handleError(error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
108
|
+
*/
|
|
109
|
+
async put(endpoint, data, requiresSecret = true) {
|
|
110
|
+
const headers = {
|
|
111
|
+
"x-project-id": this.config.projectId
|
|
112
|
+
};
|
|
113
|
+
if (requiresSecret) {
|
|
114
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const response = await this.client.put(endpoint, data, { headers });
|
|
118
|
+
return response.data;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
throw this.handleError(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Gère les erreurs API
|
|
125
|
+
*/
|
|
126
|
+
handleError(error) {
|
|
127
|
+
if (error.response) {
|
|
128
|
+
const status = error.response.status;
|
|
129
|
+
const message = error.response.data?.message || error.response.statusText;
|
|
130
|
+
return new Error(`[${status}] ${message}`);
|
|
131
|
+
}
|
|
132
|
+
return error;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// src/payment.ts
|
|
137
|
+
var PaymentService = class {
|
|
138
|
+
constructor(client) {
|
|
139
|
+
this.client = client;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Crée un nouveau paiement
|
|
143
|
+
* @param paymentData Les données du paiement
|
|
144
|
+
* @returns La réponse de création du paiement
|
|
145
|
+
*/
|
|
146
|
+
async createPayment(paymentData) {
|
|
147
|
+
const response = await this.client.post(
|
|
148
|
+
"/api/payments",
|
|
149
|
+
paymentData,
|
|
150
|
+
false
|
|
151
|
+
);
|
|
152
|
+
return response;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Récupère tous les paiements de l'application
|
|
156
|
+
* @returns La liste de tous les paiements
|
|
157
|
+
*/
|
|
158
|
+
async getAllPayments() {
|
|
159
|
+
const response = await this.client.get(
|
|
160
|
+
"/api/payments",
|
|
161
|
+
false
|
|
162
|
+
);
|
|
163
|
+
return response;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Récupère un paiement par son ID
|
|
167
|
+
* @param paymentId L'ID du paiement à récupérer
|
|
168
|
+
* @returns Le paiement demandé
|
|
169
|
+
*/
|
|
170
|
+
async getPaymentById(paymentId) {
|
|
171
|
+
const response = await this.client.get(
|
|
172
|
+
`/api/payments/${paymentId}`,
|
|
173
|
+
false
|
|
174
|
+
);
|
|
175
|
+
return response;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Met à jour le reste d'un paiement avec un code de ticket
|
|
179
|
+
* @param paymentId L'ID du paiement à mettre à jour
|
|
180
|
+
* @param ticketCode Le code du ticket à associer
|
|
181
|
+
* @returns Le paiement mis à jour
|
|
182
|
+
*/
|
|
183
|
+
async updatePaymentRest(paymentId, ticketCode) {
|
|
184
|
+
const response = await this.client.put(
|
|
185
|
+
`/api/payments/${paymentId}/rest`,
|
|
186
|
+
{ ticketCode },
|
|
187
|
+
false
|
|
188
|
+
);
|
|
189
|
+
return response;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/sms.ts
|
|
194
|
+
var SmsService = class {
|
|
195
|
+
constructor(client) {
|
|
196
|
+
this.client = client;
|
|
197
|
+
}
|
|
198
|
+
async notify(message, numbers) {
|
|
199
|
+
const phones = Array.isArray(numbers) ? numbers : [numbers];
|
|
200
|
+
const response = await this.client.post(
|
|
201
|
+
"/api/sms/multi",
|
|
202
|
+
{ phones, message },
|
|
203
|
+
true
|
|
204
|
+
);
|
|
205
|
+
return response;
|
|
206
|
+
}
|
|
207
|
+
async notifyBulk(messages) {
|
|
208
|
+
const bulkMessages = messages.map((item) => ({
|
|
209
|
+
message: item.message,
|
|
210
|
+
phones: Array.isArray(item.numbers) ? item.numbers : [item.numbers]
|
|
211
|
+
}));
|
|
212
|
+
const response = await this.client.post(
|
|
213
|
+
"/api/sms/bulk",
|
|
214
|
+
{ messages: bulkMessages },
|
|
215
|
+
true
|
|
216
|
+
);
|
|
217
|
+
return response;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/transfert.ts
|
|
222
|
+
var TransferService = class {
|
|
223
|
+
constructor(client) {
|
|
224
|
+
this.client = client;
|
|
225
|
+
}
|
|
226
|
+
async send(phone, amount) {
|
|
227
|
+
const response = await this.client.post(
|
|
228
|
+
"/api/send-transaction",
|
|
229
|
+
{ phone, amount },
|
|
230
|
+
true
|
|
231
|
+
);
|
|
232
|
+
return response;
|
|
233
|
+
}
|
|
234
|
+
async getAll() {
|
|
235
|
+
const response = await this.client.get(
|
|
236
|
+
"/api/send-transaction",
|
|
237
|
+
true
|
|
238
|
+
);
|
|
239
|
+
return response;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// src/index.ts
|
|
244
|
+
var AriarySDK = class {
|
|
245
|
+
constructor(config) {
|
|
246
|
+
const finalConfig = { ...config, baseUrl: config.baseUrl || "https://back.ariari.mg/payment/api-docs" };
|
|
247
|
+
this.paymentClient = new ApiClient(finalConfig);
|
|
248
|
+
this.defaultClient = new ApiClient(finalConfig);
|
|
249
|
+
this.payment = new PaymentService(this.paymentClient);
|
|
250
|
+
this.sms = new SmsService(this.defaultClient);
|
|
251
|
+
this.transfer = new TransferService(this.defaultClient);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
async function sendPayment(code, amount, projectId, secretId) {
|
|
255
|
+
const sdk = new AriarySDK({ secretId, projectId });
|
|
256
|
+
const paymentData = { code, amount, projectId };
|
|
257
|
+
return sdk.payment.createPayment(paymentData);
|
|
258
|
+
}
|
|
259
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
260
|
+
0 && (module.exports = {
|
|
261
|
+
ApiClient,
|
|
262
|
+
AriarySDK,
|
|
263
|
+
PaymentService,
|
|
264
|
+
SmsService,
|
|
265
|
+
TransferService,
|
|
266
|
+
sendPayment
|
|
267
|
+
});
|