@ariary/ariary 1.0.8 → 2.0.1

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
@@ -1,6 +1,6 @@
1
- # ariari
1
+ # Ariari SDK
2
2
 
3
- SDK officiel pour l'API de paiement Ariary. Permet d'envoyer des paiements, des SMS et des transferts d'argent.
3
+ SDK officiel pour l'API de paiement Ariari. Permet d'envoyer des paiements, des SMS et des transferts d'argent.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,9 +11,9 @@ npm install @ariary/ariary
11
11
  ## Configuration
12
12
 
13
13
  ```typescript
14
- import { AriarySDK } from '@ariary/ariary';
14
+ import { Ariari } from '@ariary/ariary';
15
15
 
16
- const sdk = new AriarySDK({
16
+ Ariari.config({
17
17
  secretId: 'votre_secret_id',
18
18
  projectId: 'votre_project_id'
19
19
  });
@@ -21,133 +21,36 @@ const sdk = new AriarySDK({
21
21
 
22
22
  ## Utilisation
23
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
24
  ```typescript
56
- // Envoyer un SMS à un ou plusieurs numéros
57
- const result = await sdk.sms.notify('Bonjour!', ['261345678901', '261345678902']);
25
+ // Paie
26
+ await Ariari.payment.create({ code: 'PAY-123', amount: 5000 });
27
+ await Ariari.payment.getAll();
28
+ await Ariari.payment.getById(paymentId);
29
+ await Ariari.payment.updateRest(paymentId, 'TICKET123');
30
+ await Ariari.payment.transfert({ phone: '261345678901', amount: 5000 });
31
+ await Ariari.payment.getAllTransfert();
58
32
 
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' }
33
+ // Notifications
34
+ await Ariari.notification.send({ phone: '261345678901', message: 'Hello' });
35
+ await Ariari.notification.sendBulk([
36
+ { phone: '261345678901', message: 'Message 1' },
37
+ { phone: '261345678902', message: 'Message 2' }
63
38
  ]);
64
-
65
- // Récupérer tous les SMS
66
- const allSms = await sdk.sms.getAll();
67
- ```
68
-
69
- ### Transfer
70
-
71
- ```typescript
72
- // Envoyer une transaction
73
- const transaction = await sdk.transfer.send('261345678901', 5000);
74
-
75
- // Récupérer toutes les transactions
76
- const allTransactions = await sdk.transfer.getAll();
77
- ```
78
-
79
- ### NotifTask
80
-
81
- ```typescript
82
- const allTasks = await sdk.notifTask.findAll('votre_project_id');
83
-
84
- // Récupérer une tâche par ID
85
- const task = await sdk.notifTask.findOne(taskId);
86
-
87
- // Mettre à jour une tâche
88
- const updated = await sdk.notifTask.update(taskId, {
89
- // paramètres à mettre à jour...
90
- });
91
-
92
- // Supprimer une tâche
93
- const deleted = await sdk.notifTask.remove(taskId);
94
-
95
- // Récupérer les détails des SMS
96
- const smsDetails = await sdk.notifTask.getSmsDetails(taskId);
97
-
98
- // Réessayer les SMS échoués
99
- const retry = await sdk.notifTask.retryFailedSms(taskId);
39
+ await Ariari.notification.getAll();
40
+ await Ariari.notification.task.findAll('projectId');
41
+ await Ariari.notification.task.findOne(taskId);
42
+ await Ariari.notification.task.update(taskId, { message: 'New' });
43
+ await Ariari.notification.task.delete(taskId);
44
+ await Ariari.notification.task.getSmsDetails(taskId);
45
+ await Ariari.notification.task.retryFailedSms(taskId);
100
46
  ```
101
47
 
102
48
  ## Imports
103
49
 
104
50
  ```typescript
105
- import { AriarySDK, PaymentService, SmsService, TransferService, NotifTaskService } from '@ariary/ariary';
106
- ```
107
-
108
- ## Types
109
-
110
- Tous les types TypeScript sont inclus automatiquement (.d.ts).
111
-
112
- ```typescript
113
- // Payment
114
- - CreatePaymentDto
115
- - PaymentResponseDto
116
-
117
- // SMS
118
- - SendSmsDto
119
- - BulkSmsDto
120
- - SendSmsResponseDto
121
- - MultiSmsResponseDto
122
- - BulkSmsResponseDto
123
- - ResponseSmsDto
124
-
125
- // Transfer
126
- - SendTransactionDto
127
- - SendTransactionResponse
128
- - TransactionResponseDto
129
-
130
- // NotifTask
131
- - CreateNotifTaskDto
132
- - ResponseNotifTaskDto
133
- - NotifTaskDetailsDto
134
- - UpdateNotifTaskDto
135
- - RetryFailedSmsResponseDto
136
- ```
137
-
138
- ## API
139
-
140
- ### AriarySDK
141
-
142
- ```typescript
143
- new AriarySDK(config: ApiConfig)
51
+ import { Ariari } from '@ariary/ariary';
144
52
  ```
145
53
 
146
- **config:**
147
- - `secretId: string` - Votre ID secret
148
- - `projectId: string` - Votre ID projet
149
- - `baseUrl?: string` - URL de base pour tous les services (optionnel, par défaut: https://back.ariari.mg/payment/api-docs)
150
-
151
54
  ## License
152
55
 
153
- ISC
56
+ ISC
package/dist/index.d.mts CHANGED
@@ -1,26 +1,198 @@
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 { NotifTaskService } from './notif-task/index.mjs';
8
- export { CreateNotifTaskDto, NotifTaskDetailsDto, ResponseNotifTaskDto, RetryFailedSmsResponseDto, SmsDetail, UpdateNotifTaskDto } from './notif-task/index.mjs';
9
- import { A as ApiConfig } from './client-CKv433F4.mjs';
10
- export { a as ApiClient, b as ApiResponse } from './client-CKv433F4.mjs';
1
+ interface CreateSmsDto {
2
+ message: string;
3
+ phone: string;
4
+ }
5
+ interface SendSmsDto {
6
+ message: string;
7
+ phones: string[];
8
+ }
9
+ interface BulkSmsDto {
10
+ messages: {
11
+ phones: string[];
12
+ message: string;
13
+ }[];
14
+ }
15
+ interface SendSmsResponseDto {
16
+ id: string;
17
+ message: string;
18
+ phone: string;
19
+ status: string;
20
+ createdAt: string;
21
+ }
22
+ interface ResponseSmsDto {
23
+ id: string;
24
+ message: string;
25
+ phone: string;
26
+ status: string;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ interface MultiSmsResponseDto {
31
+ status: string;
32
+ data: {
33
+ id: string;
34
+ message: string;
35
+ phone: string;
36
+ status: string;
37
+ }[];
38
+ }
39
+ interface BulkSmsResponseDto {
40
+ status: string;
41
+ data: {
42
+ id: string;
43
+ message: string;
44
+ phone: string;
45
+ status: string;
46
+ }[];
47
+ }
48
+ interface CreateNotifTaskDto {
49
+ message: string;
50
+ phones: string[];
51
+ }
52
+ interface UpdateNotifTaskDto {
53
+ message?: string;
54
+ phones?: string[];
55
+ }
56
+ interface ResponseNotifTaskDto {
57
+ id: string;
58
+ message: string;
59
+ phones: string[];
60
+ status: string;
61
+ createdAt: string;
62
+ updatedAt: string;
63
+ }
64
+ interface SmsDetail {
65
+ id: string;
66
+ phone: string;
67
+ message: string;
68
+ status: string;
69
+ attempts: number;
70
+ lastAttempt?: string;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ }
74
+ interface NotifTaskDetailsDto {
75
+ id: string;
76
+ message: string;
77
+ status: string;
78
+ totalSms: number;
79
+ successCount: number;
80
+ failedCount: number;
81
+ pendingCount: number;
82
+ smsDetails: SmsDetail[];
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ }
86
+ interface RetryFailedSmsResponseDto {
87
+ status: string;
88
+ message: string;
89
+ retried?: number;
90
+ }
11
91
 
12
- /**
13
- * SDK client pour l'API de paiement Ariary
14
- */
15
- declare class AriarySDK {
16
- private paymentClient;
17
- private defaultClient;
92
+ interface SmsApi {
93
+ send(data: {
94
+ phone: string | string[];
95
+ message: string;
96
+ }): Promise<MultiSmsResponseDto>;
97
+ sendBulk(messages: {
98
+ phone: string | string[];
99
+ message: string;
100
+ }[]): Promise<BulkSmsResponseDto>;
101
+ getAll(): Promise<ResponseSmsDto[]>;
102
+ }
103
+ interface NotifTaskApi {
104
+ findAll(projectId: string): Promise<ResponseNotifTaskDto[]>;
105
+ findOne(id: string): Promise<ResponseNotifTaskDto>;
106
+ update(id: string, data: UpdateNotifTaskDto): Promise<ResponseNotifTaskDto>;
107
+ delete(id: string): Promise<ResponseNotifTaskDto>;
108
+ getSmsDetails(id: string): Promise<NotifTaskDetailsDto>;
109
+ retryFailedSms(id: string): Promise<RetryFailedSmsResponseDto>;
110
+ }
111
+ interface NotificationService extends SmsApi {
112
+ task: NotifTaskApi;
113
+ }
114
+
115
+ interface CreatePaymentDto {
116
+ code: string;
117
+ amount: number;
118
+ projectId: string;
119
+ }
120
+ interface PaymentResponseDto {
121
+ id: string;
122
+ transactionId: string;
123
+ amount: number;
124
+ rest: number;
125
+ projectId: string;
126
+ status: string;
127
+ parts: Array<{
128
+ id: string;
129
+ amount: number;
130
+ transactionId: string;
131
+ date: string;
132
+ }>;
133
+ createdAt: string;
134
+ updatedAt: string;
135
+ }
136
+ interface SendTransactionDto {
137
+ phone: string;
138
+ amount: number;
139
+ }
140
+ interface SendTransactionResponse {
141
+ id: string;
142
+ phone: string;
143
+ amount: number;
144
+ status: string;
145
+ message: string;
146
+ requestId: string;
147
+ projectId: string;
148
+ secretId: string;
149
+ createdAt: string;
150
+ }
151
+ interface TransactionResponseDto {
152
+ id: string;
153
+ phone: string;
154
+ amount: number;
155
+ rest?: number;
156
+ status: string;
157
+ ticketCode: string;
158
+ createdAt: string;
159
+ updatedAt: string;
160
+ }
161
+
162
+ interface PaymentService {
163
+ create(data: {
164
+ code: string;
165
+ amount: number;
166
+ }): Promise<PaymentResponseDto>;
167
+ getAll(): Promise<PaymentResponseDto[]>;
168
+ getById(id: string): Promise<PaymentResponseDto>;
169
+ updateRest(paymentId: string, ticketCode: string): Promise<PaymentResponseDto>;
170
+ transfert(data: {
171
+ phone: string;
172
+ amount: number;
173
+ }): Promise<SendTransactionResponse>;
174
+ getAllTransfert(): Promise<SendTransactionResponse[]>;
175
+ }
176
+
177
+ interface AriariConfig {
178
+ secretId: string;
179
+ projectId: string;
180
+ baseUrl?: string;
181
+ }
182
+ declare const Ariari: {
183
+ /**
184
+ * Configure the SDK with your API credentials
185
+ * @param cfg Configuration object with secretId and projectId
186
+ */
187
+ config(cfg: AriariConfig): void;
18
188
  payment: PaymentService;
19
- sms: SmsService;
20
- transfer: TransferService;
21
- notifTask: NotifTaskService;
22
- constructor(config: ApiConfig);
189
+ notification: NotificationService;
190
+ };
191
+
192
+ interface ApiResponse<T> {
193
+ status: string;
194
+ data?: T;
195
+ message?: string;
23
196
  }
24
- declare function sendPayment(code: string, amount: number, projectId: string, secretId: string): Promise<PaymentResponseDto>;
25
197
 
26
- export { ApiConfig, AriarySDK, NotifTaskService, PaymentResponseDto, PaymentService, SmsService, TransferService, sendPayment };
198
+ export { type ApiResponse, Ariari, type BulkSmsDto, type BulkSmsResponseDto, type CreateNotifTaskDto, type CreatePaymentDto, type CreateSmsDto, type MultiSmsResponseDto, type NotifTaskDetailsDto, type PaymentResponseDto, type ResponseNotifTaskDto, type ResponseSmsDto, type RetryFailedSmsResponseDto, type SendSmsDto, type SendSmsResponseDto, type SendTransactionDto, type SendTransactionResponse, type SmsDetail, type TransactionResponseDto, type UpdateNotifTaskDto };
package/dist/index.d.ts CHANGED
@@ -1,26 +1,198 @@
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 { NotifTaskService } from './notif-task/index.js';
8
- export { CreateNotifTaskDto, NotifTaskDetailsDto, ResponseNotifTaskDto, RetryFailedSmsResponseDto, SmsDetail, UpdateNotifTaskDto } from './notif-task/index.js';
9
- import { A as ApiConfig } from './client-CKv433F4.js';
10
- export { a as ApiClient, b as ApiResponse } from './client-CKv433F4.js';
1
+ interface CreateSmsDto {
2
+ message: string;
3
+ phone: string;
4
+ }
5
+ interface SendSmsDto {
6
+ message: string;
7
+ phones: string[];
8
+ }
9
+ interface BulkSmsDto {
10
+ messages: {
11
+ phones: string[];
12
+ message: string;
13
+ }[];
14
+ }
15
+ interface SendSmsResponseDto {
16
+ id: string;
17
+ message: string;
18
+ phone: string;
19
+ status: string;
20
+ createdAt: string;
21
+ }
22
+ interface ResponseSmsDto {
23
+ id: string;
24
+ message: string;
25
+ phone: string;
26
+ status: string;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ interface MultiSmsResponseDto {
31
+ status: string;
32
+ data: {
33
+ id: string;
34
+ message: string;
35
+ phone: string;
36
+ status: string;
37
+ }[];
38
+ }
39
+ interface BulkSmsResponseDto {
40
+ status: string;
41
+ data: {
42
+ id: string;
43
+ message: string;
44
+ phone: string;
45
+ status: string;
46
+ }[];
47
+ }
48
+ interface CreateNotifTaskDto {
49
+ message: string;
50
+ phones: string[];
51
+ }
52
+ interface UpdateNotifTaskDto {
53
+ message?: string;
54
+ phones?: string[];
55
+ }
56
+ interface ResponseNotifTaskDto {
57
+ id: string;
58
+ message: string;
59
+ phones: string[];
60
+ status: string;
61
+ createdAt: string;
62
+ updatedAt: string;
63
+ }
64
+ interface SmsDetail {
65
+ id: string;
66
+ phone: string;
67
+ message: string;
68
+ status: string;
69
+ attempts: number;
70
+ lastAttempt?: string;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ }
74
+ interface NotifTaskDetailsDto {
75
+ id: string;
76
+ message: string;
77
+ status: string;
78
+ totalSms: number;
79
+ successCount: number;
80
+ failedCount: number;
81
+ pendingCount: number;
82
+ smsDetails: SmsDetail[];
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ }
86
+ interface RetryFailedSmsResponseDto {
87
+ status: string;
88
+ message: string;
89
+ retried?: number;
90
+ }
11
91
 
12
- /**
13
- * SDK client pour l'API de paiement Ariary
14
- */
15
- declare class AriarySDK {
16
- private paymentClient;
17
- private defaultClient;
92
+ interface SmsApi {
93
+ send(data: {
94
+ phone: string | string[];
95
+ message: string;
96
+ }): Promise<MultiSmsResponseDto>;
97
+ sendBulk(messages: {
98
+ phone: string | string[];
99
+ message: string;
100
+ }[]): Promise<BulkSmsResponseDto>;
101
+ getAll(): Promise<ResponseSmsDto[]>;
102
+ }
103
+ interface NotifTaskApi {
104
+ findAll(projectId: string): Promise<ResponseNotifTaskDto[]>;
105
+ findOne(id: string): Promise<ResponseNotifTaskDto>;
106
+ update(id: string, data: UpdateNotifTaskDto): Promise<ResponseNotifTaskDto>;
107
+ delete(id: string): Promise<ResponseNotifTaskDto>;
108
+ getSmsDetails(id: string): Promise<NotifTaskDetailsDto>;
109
+ retryFailedSms(id: string): Promise<RetryFailedSmsResponseDto>;
110
+ }
111
+ interface NotificationService extends SmsApi {
112
+ task: NotifTaskApi;
113
+ }
114
+
115
+ interface CreatePaymentDto {
116
+ code: string;
117
+ amount: number;
118
+ projectId: string;
119
+ }
120
+ interface PaymentResponseDto {
121
+ id: string;
122
+ transactionId: string;
123
+ amount: number;
124
+ rest: number;
125
+ projectId: string;
126
+ status: string;
127
+ parts: Array<{
128
+ id: string;
129
+ amount: number;
130
+ transactionId: string;
131
+ date: string;
132
+ }>;
133
+ createdAt: string;
134
+ updatedAt: string;
135
+ }
136
+ interface SendTransactionDto {
137
+ phone: string;
138
+ amount: number;
139
+ }
140
+ interface SendTransactionResponse {
141
+ id: string;
142
+ phone: string;
143
+ amount: number;
144
+ status: string;
145
+ message: string;
146
+ requestId: string;
147
+ projectId: string;
148
+ secretId: string;
149
+ createdAt: string;
150
+ }
151
+ interface TransactionResponseDto {
152
+ id: string;
153
+ phone: string;
154
+ amount: number;
155
+ rest?: number;
156
+ status: string;
157
+ ticketCode: string;
158
+ createdAt: string;
159
+ updatedAt: string;
160
+ }
161
+
162
+ interface PaymentService {
163
+ create(data: {
164
+ code: string;
165
+ amount: number;
166
+ }): Promise<PaymentResponseDto>;
167
+ getAll(): Promise<PaymentResponseDto[]>;
168
+ getById(id: string): Promise<PaymentResponseDto>;
169
+ updateRest(paymentId: string, ticketCode: string): Promise<PaymentResponseDto>;
170
+ transfert(data: {
171
+ phone: string;
172
+ amount: number;
173
+ }): Promise<SendTransactionResponse>;
174
+ getAllTransfert(): Promise<SendTransactionResponse[]>;
175
+ }
176
+
177
+ interface AriariConfig {
178
+ secretId: string;
179
+ projectId: string;
180
+ baseUrl?: string;
181
+ }
182
+ declare const Ariari: {
183
+ /**
184
+ * Configure the SDK with your API credentials
185
+ * @param cfg Configuration object with secretId and projectId
186
+ */
187
+ config(cfg: AriariConfig): void;
18
188
  payment: PaymentService;
19
- sms: SmsService;
20
- transfer: TransferService;
21
- notifTask: NotifTaskService;
22
- constructor(config: ApiConfig);
189
+ notification: NotificationService;
190
+ };
191
+
192
+ interface ApiResponse<T> {
193
+ status: string;
194
+ data?: T;
195
+ message?: string;
23
196
  }
24
- declare function sendPayment(code: string, amount: number, projectId: string, secretId: string): Promise<PaymentResponseDto>;
25
197
 
26
- export { ApiConfig, AriarySDK, NotifTaskService, PaymentResponseDto, PaymentService, SmsService, TransferService, sendPayment };
198
+ export { type ApiResponse, Ariari, type BulkSmsDto, type BulkSmsResponseDto, type CreateNotifTaskDto, type CreatePaymentDto, type CreateSmsDto, type MultiSmsResponseDto, type NotifTaskDetailsDto, type PaymentResponseDto, type ResponseNotifTaskDto, type ResponseSmsDto, type RetryFailedSmsResponseDto, type SendSmsDto, type SendSmsResponseDto, type SendTransactionDto, type SendTransactionResponse, type SmsDetail, type TransactionResponseDto, type UpdateNotifTaskDto };