@ariary/ariary 1.0.7 → 2.0.0

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,14 +21,13 @@ const sdk = new AriarySDK({
21
21
 
22
22
  ## Utilisation
23
23
 
24
- ### Paiement
24
+ ### Paiements
25
25
 
26
26
  ```typescript
27
27
  // Créer un paiement
28
- const payment = await sdk.payment.createPayment({
28
+ const payment = await Ariari.payment.create({
29
29
  code: 'PAY-K1X2Y3Z4-ABC123',
30
- amount: 5000,
31
- projectId: 'votre_project_id'
30
+ amount: 5000
32
31
  });
33
32
 
34
33
  console.log(payment);
@@ -41,68 +40,75 @@ console.log(payment);
41
40
  // }
42
41
 
43
42
  // Récupérer tous les paiements
44
- const allPayments = await sdk.payment.getAllPayments();
43
+ const allPayments = await Ariari.payment.getAll();
45
44
 
46
45
  // Récupérer un paiement par ID
47
- const payment = await sdk.payment.getPaymentById(paymentId);
46
+ const payment = await Ariari.payment.getById(paymentId);
48
47
 
49
48
  // Mettre à jour le reste d'un paiement
50
- const updated = await sdk.payment.updatePaymentRest(paymentId, 'TICKET123');
49
+ const updated = await Ariari.payment.updateRest(paymentId, 'TICKET123');
51
50
  ```
52
51
 
53
- ### SMS
52
+ ### Transferts
54
53
 
55
54
  ```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
- ]);
55
+ // Envoyer un transfert
56
+ const transaction = await Ariari.payment.transfert({
57
+ phone: '261345678901',
58
+ amount: 5000
59
+ });
64
60
 
65
- // Récupérer tous les SMS
66
- const allSms = await sdk.sms.getAll();
61
+ // Récupérer tous les transferts
62
+ const allTransferts = await Ariari.payment.getAllTransfert();
67
63
  ```
68
64
 
69
- ### Transfer
65
+ ### SMS
70
66
 
71
67
  ```typescript
72
- // Envoyer une transaction
73
- const transaction = await sdk.transfer.send('261345678901', 5000);
68
+ // Envoyer un SMS
69
+ const result = await Ariari.notification.send({
70
+ phone: '261345678901',
71
+ message: 'Bonjour!'
72
+ });
73
+
74
+ // Envoyer des SMS différents
75
+ const result = await Ariari.notification.sendBulk([
76
+ { phone: '261345678901', message: 'Message 1' },
77
+ { phone: '261345678902', message: 'Message 2' }
78
+ ]);
74
79
 
75
- // Récupérer toutes les transactions
76
- const allTransactions = await sdk.transfer.getAll();
80
+ // Récupérer tous les SMS
81
+ const allSms = await Ariari.notification.getAll();
77
82
  ```
78
83
 
79
- ### NotifTask
84
+ ### Tâches de Notification
80
85
 
81
86
  ```typescript
82
- const allTasks = await sdk.notifTask.findAll('votre_project_id');
87
+ // Récupérer toutes les tâches
88
+ const allTasks = await Ariari.notification.task.findAll('votre_project_id');
83
89
 
84
90
  // Récupérer une tâche par ID
85
- const task = await sdk.notifTask.findOne(taskId);
91
+ const task = await Ariari.notification.task.findOne(taskId);
86
92
 
87
93
  // Mettre à jour une tâche
88
- const updated = await sdk.notifTask.update(taskId, {
89
- // paramètres à mettre à jour...
94
+ const updated = await Ariari.notification.task.update(taskId, {
95
+ message: 'Nouveau message'
90
96
  });
91
97
 
92
98
  // Supprimer une tâche
93
- const deleted = await sdk.notifTask.remove(taskId);
99
+ const deleted = await Ariari.notification.task.delete(taskId);
94
100
 
95
101
  // Récupérer les détails des SMS
96
- const smsDetails = await sdk.notifTask.getSmsDetails(taskId);
102
+ const smsDetails = await Ariari.notification.task.getSmsDetails(taskId);
97
103
 
98
104
  // Réessayer les SMS échoués
99
- const retry = await sdk.notifTask.retryFailedSms(taskId);
105
+ const retry = await Ariari.notification.task.retryFailedSms(taskId);
100
106
  ```
101
107
 
102
108
  ## Imports
103
109
 
104
110
  ```typescript
105
- import { AriarySDK, PaymentService, SmsService, TransferService, NotifTaskService } from '@ariary/ariary';
111
+ import { Ariari } from '@ariary/ariary';
106
112
  ```
107
113
 
108
114
  ## Types
@@ -113,6 +119,8 @@ Tous les types TypeScript sont inclus automatiquement (.d.ts).
113
119
  // Payment
114
120
  - CreatePaymentDto
115
121
  - PaymentResponseDto
122
+ - SendTransactionDto
123
+ - SendTransactionResponse
116
124
 
117
125
  // SMS
118
126
  - SendSmsDto
@@ -122,32 +130,13 @@ Tous les types TypeScript sont inclus automatiquement (.d.ts).
122
130
  - BulkSmsResponseDto
123
131
  - ResponseSmsDto
124
132
 
125
- // Transfer
126
- - SendTransactionDto
127
- - SendTransactionResponse
128
- - TransactionResponseDto
129
-
130
133
  // NotifTask
131
- - CreateNotifTaskDto
132
134
  - ResponseNotifTaskDto
133
135
  - NotifTaskDetailsDto
134
136
  - UpdateNotifTaskDto
135
137
  - RetryFailedSmsResponseDto
136
138
  ```
137
139
 
138
- ## API
139
-
140
- ### AriarySDK
141
-
142
- ```typescript
143
- new AriarySDK(config: ApiConfig)
144
- ```
145
-
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
140
  ## License
152
141
 
153
- ISC
142
+ 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 };