@ariary/notification 1.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 +76 -0
- package/dist/client-BOI4a9h5.d.mts +40 -0
- package/dist/client-BOI4a9h5.d.ts +40 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +260 -0
- package/dist/index.mjs +220 -0
- package/dist/notif-task/index.d.mts +59 -0
- package/dist/notif-task/index.d.ts +59 -0
- package/dist/notif-task/index.js +88 -0
- package/dist/notif-task/index.mjs +61 -0
- package/dist/sms/index.d.mts +62 -0
- package/dist/sms/index.d.ts +62 -0
- package/dist/sms/index.js +64 -0
- package/dist/sms/index.mjs +37 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @ariary/sms
|
|
2
|
+
|
|
3
|
+
SDK SMS et Notification Task pour l'API Ariary
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ariary/sms
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Initialisation
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { SmsSdk } from '@ariary/sms';
|
|
17
|
+
|
|
18
|
+
const sdk = new SmsSdk({
|
|
19
|
+
projectId: 'your-project-id',
|
|
20
|
+
secretId: 'your-secret-id',
|
|
21
|
+
baseUrl: 'https://back.ariari.mg/payment/api-docs'
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### SMS Service
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// Envoyer un SMS unique
|
|
29
|
+
await sdk.sms.notify('Hello World', '261234567890');
|
|
30
|
+
|
|
31
|
+
// Envoyer un SMS à plusieurs destinataires
|
|
32
|
+
await sdk.sms.notify('Hello World', ['261234567890', '261234567891']);
|
|
33
|
+
|
|
34
|
+
// Envoyer des messages différents (bulk)
|
|
35
|
+
await sdk.sms.notifyBulk([
|
|
36
|
+
{ message: 'Message 1', numbers: ['261234567890'] },
|
|
37
|
+
{ message: 'Message 2', numbers: ['261234567891'] }
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
// Récupérer l'historique SMS
|
|
41
|
+
const smsList = await sdk.sms.getAll();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### NotifTask Service
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// Créer une tâche de notification
|
|
48
|
+
const task = await sdk.notifTask.create({
|
|
49
|
+
message: 'Hello World',
|
|
50
|
+
phones: ['261234567890', '261234567891']
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Récupérer toutes les tâches
|
|
54
|
+
const tasks = await sdk.notifTask.findAll('project-id');
|
|
55
|
+
|
|
56
|
+
// Récupérer une tâche
|
|
57
|
+
const task = await sdk.notifTask.findOne('task-id');
|
|
58
|
+
|
|
59
|
+
// Mettre à jour une tâche
|
|
60
|
+
await sdk.notifTask.update('task-id', {
|
|
61
|
+
message: 'Updated message'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Récupérer les détails SMS d'une tâche
|
|
65
|
+
const details = await sdk.notifTask.getSmsDetails('task-id');
|
|
66
|
+
|
|
67
|
+
// Réessayer les SMS échoués
|
|
68
|
+
await sdk.notifTask.retryFailedSms('task-id');
|
|
69
|
+
|
|
70
|
+
// Supprimer une tâche
|
|
71
|
+
await sdk.notifTask.remove('task-id');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
ISC
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration de l'API
|
|
3
|
+
*/
|
|
4
|
+
interface ApiConfig {
|
|
5
|
+
projectId: string;
|
|
6
|
+
secretId: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare class ApiClient {
|
|
11
|
+
private client;
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: ApiConfig, baseUrl?: string);
|
|
14
|
+
/**
|
|
15
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
16
|
+
*/
|
|
17
|
+
post<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
20
|
+
*/
|
|
21
|
+
get<T>(endpoint: string, requiresSecret?: boolean): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
24
|
+
*/
|
|
25
|
+
patch<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
28
|
+
*/
|
|
29
|
+
put<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Effectue une requête DELETE avec les en-têtes d'authentification
|
|
32
|
+
*/
|
|
33
|
+
delete<T>(endpoint: string, requiresSecret?: boolean): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Gère les erreurs API
|
|
36
|
+
*/
|
|
37
|
+
private handleError;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { type ApiConfig as A, ApiClient as a };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration de l'API
|
|
3
|
+
*/
|
|
4
|
+
interface ApiConfig {
|
|
5
|
+
projectId: string;
|
|
6
|
+
secretId: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare class ApiClient {
|
|
11
|
+
private client;
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: ApiConfig, baseUrl?: string);
|
|
14
|
+
/**
|
|
15
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
16
|
+
*/
|
|
17
|
+
post<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
20
|
+
*/
|
|
21
|
+
get<T>(endpoint: string, requiresSecret?: boolean): Promise<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
24
|
+
*/
|
|
25
|
+
patch<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
28
|
+
*/
|
|
29
|
+
put<T>(endpoint: string, data: any, requiresSecret?: boolean): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Effectue une requête DELETE avec les en-têtes d'authentification
|
|
32
|
+
*/
|
|
33
|
+
delete<T>(endpoint: string, requiresSecret?: boolean): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Gère les erreurs API
|
|
36
|
+
*/
|
|
37
|
+
private handleError;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { type ApiConfig as A, ApiClient as a };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SmsService } from './sms/index.mjs';
|
|
2
|
+
export { BulkSmsDto, BulkSmsResponseDto, CreateSmsDto, MultiSmsResponseDto, ResponseSmsDto, SendSmsDto, SendSmsResponseDto } from './sms/index.mjs';
|
|
3
|
+
import { NotifTaskService } from './notif-task/index.mjs';
|
|
4
|
+
export { CreateNotifTaskDto, NotifTaskDetailsDto, ResponseNotifTaskDto, RetryFailedSmsResponseDto, SmsDetail, UpdateNotifTaskDto } from './notif-task/index.mjs';
|
|
5
|
+
import { A as ApiConfig } from './client-BOI4a9h5.mjs';
|
|
6
|
+
export { a as ApiClient } from './client-BOI4a9h5.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SDK pour SMS et Notification Tasks Ariary
|
|
10
|
+
*/
|
|
11
|
+
declare class SmsSdk {
|
|
12
|
+
private client;
|
|
13
|
+
sms: SmsService;
|
|
14
|
+
notifTask: NotifTaskService;
|
|
15
|
+
constructor(config: ApiConfig);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ApiConfig, NotifTaskService, SmsSdk, SmsService };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SmsService } from './sms/index.js';
|
|
2
|
+
export { BulkSmsDto, BulkSmsResponseDto, CreateSmsDto, MultiSmsResponseDto, ResponseSmsDto, SendSmsDto, SendSmsResponseDto } from './sms/index.js';
|
|
3
|
+
import { NotifTaskService } from './notif-task/index.js';
|
|
4
|
+
export { CreateNotifTaskDto, NotifTaskDetailsDto, ResponseNotifTaskDto, RetryFailedSmsResponseDto, SmsDetail, UpdateNotifTaskDto } from './notif-task/index.js';
|
|
5
|
+
import { A as ApiConfig } from './client-BOI4a9h5.js';
|
|
6
|
+
export { a as ApiClient } from './client-BOI4a9h5.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SDK pour SMS et Notification Tasks Ariary
|
|
10
|
+
*/
|
|
11
|
+
declare class SmsSdk {
|
|
12
|
+
private client;
|
|
13
|
+
sms: SmsService;
|
|
14
|
+
notifTask: NotifTaskService;
|
|
15
|
+
constructor(config: ApiConfig);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ApiConfig, NotifTaskService, SmsSdk, SmsService };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
NotifTaskService: () => NotifTaskService,
|
|
35
|
+
SmsSdk: () => SmsSdk,
|
|
36
|
+
SmsService: () => SmsService
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
var import_axios = __toESM(require("axios"));
|
|
42
|
+
var ApiClient = class {
|
|
43
|
+
constructor(config, baseUrl) {
|
|
44
|
+
this.config = config;
|
|
45
|
+
const finalBaseUrl = baseUrl || config.baseUrl || "https://back.ariari.mg/payment/api-docs";
|
|
46
|
+
this.client = import_axios.default.create({
|
|
47
|
+
baseURL: finalBaseUrl,
|
|
48
|
+
headers: {
|
|
49
|
+
"Content-Type": "application/json"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
55
|
+
*/
|
|
56
|
+
async post(endpoint, data, requiresSecret = true) {
|
|
57
|
+
const headers = {
|
|
58
|
+
"x-project-id": this.config.projectId
|
|
59
|
+
};
|
|
60
|
+
if (requiresSecret) {
|
|
61
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const response = await this.client.post(endpoint, data, { headers });
|
|
65
|
+
return response.data;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw this.handleError(error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
72
|
+
*/
|
|
73
|
+
async get(endpoint, requiresSecret = true) {
|
|
74
|
+
const headers = {
|
|
75
|
+
"x-project-id": this.config.projectId
|
|
76
|
+
};
|
|
77
|
+
if (requiresSecret) {
|
|
78
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const response = await this.client.get(endpoint, { headers });
|
|
82
|
+
return response.data;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw this.handleError(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
89
|
+
*/
|
|
90
|
+
async patch(endpoint, data, requiresSecret = true) {
|
|
91
|
+
const headers = {
|
|
92
|
+
"x-project-id": this.config.projectId
|
|
93
|
+
};
|
|
94
|
+
if (requiresSecret) {
|
|
95
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const response = await this.client.patch(endpoint, data, { headers });
|
|
99
|
+
return response.data;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
throw this.handleError(error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
106
|
+
*/
|
|
107
|
+
async put(endpoint, data, requiresSecret = true) {
|
|
108
|
+
const headers = {
|
|
109
|
+
"x-project-id": this.config.projectId
|
|
110
|
+
};
|
|
111
|
+
if (requiresSecret) {
|
|
112
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const response = await this.client.put(endpoint, data, { headers });
|
|
116
|
+
return response.data;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
throw this.handleError(error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Effectue une requête DELETE avec les en-têtes d'authentification
|
|
123
|
+
*/
|
|
124
|
+
async delete(endpoint, requiresSecret = true) {
|
|
125
|
+
const headers = {
|
|
126
|
+
"x-project-id": this.config.projectId
|
|
127
|
+
};
|
|
128
|
+
if (requiresSecret) {
|
|
129
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const response = await this.client.delete(endpoint, { headers });
|
|
133
|
+
return response.data;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
throw this.handleError(error);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Gère les erreurs API
|
|
140
|
+
*/
|
|
141
|
+
handleError(error) {
|
|
142
|
+
if (error.response) {
|
|
143
|
+
const status = error.response.status;
|
|
144
|
+
const message = error.response.data?.message || error.response.statusText;
|
|
145
|
+
return new Error(`[${status}] ${message}`);
|
|
146
|
+
}
|
|
147
|
+
return error;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/sms.ts
|
|
152
|
+
var SmsService = class {
|
|
153
|
+
constructor(client) {
|
|
154
|
+
this.client = client;
|
|
155
|
+
}
|
|
156
|
+
async notify(message, numbers) {
|
|
157
|
+
const phones = Array.isArray(numbers) ? numbers : [numbers];
|
|
158
|
+
const response = await this.client.post(
|
|
159
|
+
"/api/sms/multi",
|
|
160
|
+
{ phones, message },
|
|
161
|
+
true
|
|
162
|
+
);
|
|
163
|
+
return response;
|
|
164
|
+
}
|
|
165
|
+
async notifyBulk(messages) {
|
|
166
|
+
const bulkMessages = messages.map((item) => ({
|
|
167
|
+
message: item.message,
|
|
168
|
+
phones: Array.isArray(item.numbers) ? item.numbers : [item.numbers]
|
|
169
|
+
}));
|
|
170
|
+
const response = await this.client.post(
|
|
171
|
+
"/api/sms/bulk",
|
|
172
|
+
{ messages: bulkMessages },
|
|
173
|
+
true
|
|
174
|
+
);
|
|
175
|
+
return response;
|
|
176
|
+
}
|
|
177
|
+
async getAll() {
|
|
178
|
+
const response = await this.client.get(
|
|
179
|
+
"/api/sms",
|
|
180
|
+
true
|
|
181
|
+
);
|
|
182
|
+
return response;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/notif-task.ts
|
|
187
|
+
var NotifTaskService = class {
|
|
188
|
+
constructor(client) {
|
|
189
|
+
this.client = client;
|
|
190
|
+
}
|
|
191
|
+
async create(createNotifTaskDto) {
|
|
192
|
+
const response = await this.client.post(
|
|
193
|
+
"/api/notif-task",
|
|
194
|
+
createNotifTaskDto,
|
|
195
|
+
true
|
|
196
|
+
);
|
|
197
|
+
return response;
|
|
198
|
+
}
|
|
199
|
+
async findAll(projectId) {
|
|
200
|
+
const response = await this.client.get(
|
|
201
|
+
`/api/notif-task?projectId=${projectId}`,
|
|
202
|
+
true
|
|
203
|
+
);
|
|
204
|
+
return response;
|
|
205
|
+
}
|
|
206
|
+
async findOne(id) {
|
|
207
|
+
const response = await this.client.get(
|
|
208
|
+
`/api/notif-task/${id}`,
|
|
209
|
+
true
|
|
210
|
+
);
|
|
211
|
+
return response;
|
|
212
|
+
}
|
|
213
|
+
async update(id, updateNotifTaskDto) {
|
|
214
|
+
const response = await this.client.patch(
|
|
215
|
+
`/api/notif-task/${id}`,
|
|
216
|
+
updateNotifTaskDto,
|
|
217
|
+
true
|
|
218
|
+
);
|
|
219
|
+
return response;
|
|
220
|
+
}
|
|
221
|
+
async remove(id) {
|
|
222
|
+
const response = await this.client.delete(
|
|
223
|
+
`/api/notif-task/${id}`,
|
|
224
|
+
true
|
|
225
|
+
);
|
|
226
|
+
return response;
|
|
227
|
+
}
|
|
228
|
+
async getSmsDetails(id) {
|
|
229
|
+
const response = await this.client.get(
|
|
230
|
+
`/api/notif-task/${id}/sms-details`,
|
|
231
|
+
true
|
|
232
|
+
);
|
|
233
|
+
return response;
|
|
234
|
+
}
|
|
235
|
+
async retryFailedSms(id) {
|
|
236
|
+
const response = await this.client.post(
|
|
237
|
+
`/api/notif-task/${id}/retry-failed-sms`,
|
|
238
|
+
{},
|
|
239
|
+
true
|
|
240
|
+
);
|
|
241
|
+
return response;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/index.ts
|
|
246
|
+
var SmsSdk = class {
|
|
247
|
+
constructor(config) {
|
|
248
|
+
const finalConfig = { ...config, baseUrl: config.baseUrl || "https://back.ariari.mg/payment/api-docs" };
|
|
249
|
+
this.client = new ApiClient(finalConfig);
|
|
250
|
+
this.sms = new SmsService(this.client);
|
|
251
|
+
this.notifTask = new NotifTaskService(this.client);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
255
|
+
0 && (module.exports = {
|
|
256
|
+
ApiClient,
|
|
257
|
+
NotifTaskService,
|
|
258
|
+
SmsSdk,
|
|
259
|
+
SmsService
|
|
260
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
var ApiClient = class {
|
|
4
|
+
constructor(config, baseUrl) {
|
|
5
|
+
this.config = config;
|
|
6
|
+
const finalBaseUrl = baseUrl || config.baseUrl || "https://back.ariari.mg/payment/api-docs";
|
|
7
|
+
this.client = axios.create({
|
|
8
|
+
baseURL: finalBaseUrl,
|
|
9
|
+
headers: {
|
|
10
|
+
"Content-Type": "application/json"
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Effectue une requête POST avec les en-têtes d'authentification
|
|
16
|
+
*/
|
|
17
|
+
async post(endpoint, data, requiresSecret = true) {
|
|
18
|
+
const headers = {
|
|
19
|
+
"x-project-id": this.config.projectId
|
|
20
|
+
};
|
|
21
|
+
if (requiresSecret) {
|
|
22
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const response = await this.client.post(endpoint, data, { headers });
|
|
26
|
+
return response.data;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw this.handleError(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Effectue une requête GET avec les en-têtes d'authentification
|
|
33
|
+
*/
|
|
34
|
+
async get(endpoint, requiresSecret = true) {
|
|
35
|
+
const headers = {
|
|
36
|
+
"x-project-id": this.config.projectId
|
|
37
|
+
};
|
|
38
|
+
if (requiresSecret) {
|
|
39
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const response = await this.client.get(endpoint, { headers });
|
|
43
|
+
return response.data;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw this.handleError(error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Effectue une requête PATCH avec les en-têtes d'authentification
|
|
50
|
+
*/
|
|
51
|
+
async patch(endpoint, data, requiresSecret = true) {
|
|
52
|
+
const headers = {
|
|
53
|
+
"x-project-id": this.config.projectId
|
|
54
|
+
};
|
|
55
|
+
if (requiresSecret) {
|
|
56
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const response = await this.client.patch(endpoint, data, { headers });
|
|
60
|
+
return response.data;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw this.handleError(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Effectue une requête PUT avec les en-têtes d'authentification
|
|
67
|
+
*/
|
|
68
|
+
async put(endpoint, data, requiresSecret = true) {
|
|
69
|
+
const headers = {
|
|
70
|
+
"x-project-id": this.config.projectId
|
|
71
|
+
};
|
|
72
|
+
if (requiresSecret) {
|
|
73
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const response = await this.client.put(endpoint, data, { headers });
|
|
77
|
+
return response.data;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw this.handleError(error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Effectue une requête DELETE avec les en-têtes d'authentification
|
|
84
|
+
*/
|
|
85
|
+
async delete(endpoint, requiresSecret = true) {
|
|
86
|
+
const headers = {
|
|
87
|
+
"x-project-id": this.config.projectId
|
|
88
|
+
};
|
|
89
|
+
if (requiresSecret) {
|
|
90
|
+
headers["x-secret-id"] = this.config.secretId;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const response = await this.client.delete(endpoint, { headers });
|
|
94
|
+
return response.data;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
throw this.handleError(error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gère les erreurs API
|
|
101
|
+
*/
|
|
102
|
+
handleError(error) {
|
|
103
|
+
if (error.response) {
|
|
104
|
+
const status = error.response.status;
|
|
105
|
+
const message = error.response.data?.message || error.response.statusText;
|
|
106
|
+
return new Error(`[${status}] ${message}`);
|
|
107
|
+
}
|
|
108
|
+
return error;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/sms.ts
|
|
113
|
+
var SmsService = class {
|
|
114
|
+
constructor(client) {
|
|
115
|
+
this.client = client;
|
|
116
|
+
}
|
|
117
|
+
async notify(message, numbers) {
|
|
118
|
+
const phones = Array.isArray(numbers) ? numbers : [numbers];
|
|
119
|
+
const response = await this.client.post(
|
|
120
|
+
"/api/sms/multi",
|
|
121
|
+
{ phones, message },
|
|
122
|
+
true
|
|
123
|
+
);
|
|
124
|
+
return response;
|
|
125
|
+
}
|
|
126
|
+
async notifyBulk(messages) {
|
|
127
|
+
const bulkMessages = messages.map((item) => ({
|
|
128
|
+
message: item.message,
|
|
129
|
+
phones: Array.isArray(item.numbers) ? item.numbers : [item.numbers]
|
|
130
|
+
}));
|
|
131
|
+
const response = await this.client.post(
|
|
132
|
+
"/api/sms/bulk",
|
|
133
|
+
{ messages: bulkMessages },
|
|
134
|
+
true
|
|
135
|
+
);
|
|
136
|
+
return response;
|
|
137
|
+
}
|
|
138
|
+
async getAll() {
|
|
139
|
+
const response = await this.client.get(
|
|
140
|
+
"/api/sms",
|
|
141
|
+
true
|
|
142
|
+
);
|
|
143
|
+
return response;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/notif-task.ts
|
|
148
|
+
var NotifTaskService = class {
|
|
149
|
+
constructor(client) {
|
|
150
|
+
this.client = client;
|
|
151
|
+
}
|
|
152
|
+
async create(createNotifTaskDto) {
|
|
153
|
+
const response = await this.client.post(
|
|
154
|
+
"/api/notif-task",
|
|
155
|
+
createNotifTaskDto,
|
|
156
|
+
true
|
|
157
|
+
);
|
|
158
|
+
return response;
|
|
159
|
+
}
|
|
160
|
+
async findAll(projectId) {
|
|
161
|
+
const response = await this.client.get(
|
|
162
|
+
`/api/notif-task?projectId=${projectId}`,
|
|
163
|
+
true
|
|
164
|
+
);
|
|
165
|
+
return response;
|
|
166
|
+
}
|
|
167
|
+
async findOne(id) {
|
|
168
|
+
const response = await this.client.get(
|
|
169
|
+
`/api/notif-task/${id}`,
|
|
170
|
+
true
|
|
171
|
+
);
|
|
172
|
+
return response;
|
|
173
|
+
}
|
|
174
|
+
async update(id, updateNotifTaskDto) {
|
|
175
|
+
const response = await this.client.patch(
|
|
176
|
+
`/api/notif-task/${id}`,
|
|
177
|
+
updateNotifTaskDto,
|
|
178
|
+
true
|
|
179
|
+
);
|
|
180
|
+
return response;
|
|
181
|
+
}
|
|
182
|
+
async remove(id) {
|
|
183
|
+
const response = await this.client.delete(
|
|
184
|
+
`/api/notif-task/${id}`,
|
|
185
|
+
true
|
|
186
|
+
);
|
|
187
|
+
return response;
|
|
188
|
+
}
|
|
189
|
+
async getSmsDetails(id) {
|
|
190
|
+
const response = await this.client.get(
|
|
191
|
+
`/api/notif-task/${id}/sms-details`,
|
|
192
|
+
true
|
|
193
|
+
);
|
|
194
|
+
return response;
|
|
195
|
+
}
|
|
196
|
+
async retryFailedSms(id) {
|
|
197
|
+
const response = await this.client.post(
|
|
198
|
+
`/api/notif-task/${id}/retry-failed-sms`,
|
|
199
|
+
{},
|
|
200
|
+
true
|
|
201
|
+
);
|
|
202
|
+
return response;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// src/index.ts
|
|
207
|
+
var SmsSdk = class {
|
|
208
|
+
constructor(config) {
|
|
209
|
+
const finalConfig = { ...config, baseUrl: config.baseUrl || "https://back.ariari.mg/payment/api-docs" };
|
|
210
|
+
this.client = new ApiClient(finalConfig);
|
|
211
|
+
this.sms = new SmsService(this.client);
|
|
212
|
+
this.notifTask = new NotifTaskService(this.client);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
export {
|
|
216
|
+
ApiClient,
|
|
217
|
+
NotifTaskService,
|
|
218
|
+
SmsSdk,
|
|
219
|
+
SmsService
|
|
220
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-BOI4a9h5.mjs';
|
|
2
|
+
|
|
3
|
+
interface CreateNotifTaskDto {
|
|
4
|
+
message: string;
|
|
5
|
+
phones: string[];
|
|
6
|
+
}
|
|
7
|
+
interface UpdateNotifTaskDto {
|
|
8
|
+
message?: string;
|
|
9
|
+
phones?: string[];
|
|
10
|
+
}
|
|
11
|
+
interface ResponseNotifTaskDto {
|
|
12
|
+
id: string;
|
|
13
|
+
message: string;
|
|
14
|
+
phones: string[];
|
|
15
|
+
status: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}
|
|
19
|
+
interface SmsDetail {
|
|
20
|
+
id: string;
|
|
21
|
+
phone: string;
|
|
22
|
+
message: string;
|
|
23
|
+
status: string;
|
|
24
|
+
attempts: number;
|
|
25
|
+
lastAttempt?: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
}
|
|
29
|
+
interface NotifTaskDetailsDto {
|
|
30
|
+
id: string;
|
|
31
|
+
message: string;
|
|
32
|
+
status: string;
|
|
33
|
+
totalSms: number;
|
|
34
|
+
successCount: number;
|
|
35
|
+
failedCount: number;
|
|
36
|
+
pendingCount: number;
|
|
37
|
+
smsDetails: SmsDetail[];
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface RetryFailedSmsResponseDto {
|
|
42
|
+
status: string;
|
|
43
|
+
message: string;
|
|
44
|
+
retried?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare class NotifTaskService {
|
|
48
|
+
private client;
|
|
49
|
+
constructor(client: ApiClient);
|
|
50
|
+
create(createNotifTaskDto: CreateNotifTaskDto): Promise<ResponseNotifTaskDto>;
|
|
51
|
+
findAll(projectId: string): Promise<ResponseNotifTaskDto[]>;
|
|
52
|
+
findOne(id: string): Promise<ResponseNotifTaskDto>;
|
|
53
|
+
update(id: string, updateNotifTaskDto: UpdateNotifTaskDto): Promise<ResponseNotifTaskDto>;
|
|
54
|
+
remove(id: string): Promise<ResponseNotifTaskDto>;
|
|
55
|
+
getSmsDetails(id: string): Promise<NotifTaskDetailsDto>;
|
|
56
|
+
retryFailedSms(id: string): Promise<RetryFailedSmsResponseDto>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { type CreateNotifTaskDto, type NotifTaskDetailsDto, NotifTaskService, type ResponseNotifTaskDto, type RetryFailedSmsResponseDto, type SmsDetail, type UpdateNotifTaskDto };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-BOI4a9h5.js';
|
|
2
|
+
|
|
3
|
+
interface CreateNotifTaskDto {
|
|
4
|
+
message: string;
|
|
5
|
+
phones: string[];
|
|
6
|
+
}
|
|
7
|
+
interface UpdateNotifTaskDto {
|
|
8
|
+
message?: string;
|
|
9
|
+
phones?: string[];
|
|
10
|
+
}
|
|
11
|
+
interface ResponseNotifTaskDto {
|
|
12
|
+
id: string;
|
|
13
|
+
message: string;
|
|
14
|
+
phones: string[];
|
|
15
|
+
status: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}
|
|
19
|
+
interface SmsDetail {
|
|
20
|
+
id: string;
|
|
21
|
+
phone: string;
|
|
22
|
+
message: string;
|
|
23
|
+
status: string;
|
|
24
|
+
attempts: number;
|
|
25
|
+
lastAttempt?: string;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
updatedAt: string;
|
|
28
|
+
}
|
|
29
|
+
interface NotifTaskDetailsDto {
|
|
30
|
+
id: string;
|
|
31
|
+
message: string;
|
|
32
|
+
status: string;
|
|
33
|
+
totalSms: number;
|
|
34
|
+
successCount: number;
|
|
35
|
+
failedCount: number;
|
|
36
|
+
pendingCount: number;
|
|
37
|
+
smsDetails: SmsDetail[];
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
}
|
|
41
|
+
interface RetryFailedSmsResponseDto {
|
|
42
|
+
status: string;
|
|
43
|
+
message: string;
|
|
44
|
+
retried?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare class NotifTaskService {
|
|
48
|
+
private client;
|
|
49
|
+
constructor(client: ApiClient);
|
|
50
|
+
create(createNotifTaskDto: CreateNotifTaskDto): Promise<ResponseNotifTaskDto>;
|
|
51
|
+
findAll(projectId: string): Promise<ResponseNotifTaskDto[]>;
|
|
52
|
+
findOne(id: string): Promise<ResponseNotifTaskDto>;
|
|
53
|
+
update(id: string, updateNotifTaskDto: UpdateNotifTaskDto): Promise<ResponseNotifTaskDto>;
|
|
54
|
+
remove(id: string): Promise<ResponseNotifTaskDto>;
|
|
55
|
+
getSmsDetails(id: string): Promise<NotifTaskDetailsDto>;
|
|
56
|
+
retryFailedSms(id: string): Promise<RetryFailedSmsResponseDto>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { type CreateNotifTaskDto, type NotifTaskDetailsDto, NotifTaskService, type ResponseNotifTaskDto, type RetryFailedSmsResponseDto, type SmsDetail, type UpdateNotifTaskDto };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/notif-task/index.ts
|
|
21
|
+
var notif_task_exports = {};
|
|
22
|
+
__export(notif_task_exports, {
|
|
23
|
+
NotifTaskService: () => NotifTaskService
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(notif_task_exports);
|
|
26
|
+
|
|
27
|
+
// src/notif-task.ts
|
|
28
|
+
var NotifTaskService = class {
|
|
29
|
+
constructor(client) {
|
|
30
|
+
this.client = client;
|
|
31
|
+
}
|
|
32
|
+
async create(createNotifTaskDto) {
|
|
33
|
+
const response = await this.client.post(
|
|
34
|
+
"/api/notif-task",
|
|
35
|
+
createNotifTaskDto,
|
|
36
|
+
true
|
|
37
|
+
);
|
|
38
|
+
return response;
|
|
39
|
+
}
|
|
40
|
+
async findAll(projectId) {
|
|
41
|
+
const response = await this.client.get(
|
|
42
|
+
`/api/notif-task?projectId=${projectId}`,
|
|
43
|
+
true
|
|
44
|
+
);
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
async findOne(id) {
|
|
48
|
+
const response = await this.client.get(
|
|
49
|
+
`/api/notif-task/${id}`,
|
|
50
|
+
true
|
|
51
|
+
);
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
async update(id, updateNotifTaskDto) {
|
|
55
|
+
const response = await this.client.patch(
|
|
56
|
+
`/api/notif-task/${id}`,
|
|
57
|
+
updateNotifTaskDto,
|
|
58
|
+
true
|
|
59
|
+
);
|
|
60
|
+
return response;
|
|
61
|
+
}
|
|
62
|
+
async remove(id) {
|
|
63
|
+
const response = await this.client.delete(
|
|
64
|
+
`/api/notif-task/${id}`,
|
|
65
|
+
true
|
|
66
|
+
);
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
async getSmsDetails(id) {
|
|
70
|
+
const response = await this.client.get(
|
|
71
|
+
`/api/notif-task/${id}/sms-details`,
|
|
72
|
+
true
|
|
73
|
+
);
|
|
74
|
+
return response;
|
|
75
|
+
}
|
|
76
|
+
async retryFailedSms(id) {
|
|
77
|
+
const response = await this.client.post(
|
|
78
|
+
`/api/notif-task/${id}/retry-failed-sms`,
|
|
79
|
+
{},
|
|
80
|
+
true
|
|
81
|
+
);
|
|
82
|
+
return response;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
NotifTaskService
|
|
88
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/notif-task.ts
|
|
2
|
+
var NotifTaskService = class {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async create(createNotifTaskDto) {
|
|
7
|
+
const response = await this.client.post(
|
|
8
|
+
"/api/notif-task",
|
|
9
|
+
createNotifTaskDto,
|
|
10
|
+
true
|
|
11
|
+
);
|
|
12
|
+
return response;
|
|
13
|
+
}
|
|
14
|
+
async findAll(projectId) {
|
|
15
|
+
const response = await this.client.get(
|
|
16
|
+
`/api/notif-task?projectId=${projectId}`,
|
|
17
|
+
true
|
|
18
|
+
);
|
|
19
|
+
return response;
|
|
20
|
+
}
|
|
21
|
+
async findOne(id) {
|
|
22
|
+
const response = await this.client.get(
|
|
23
|
+
`/api/notif-task/${id}`,
|
|
24
|
+
true
|
|
25
|
+
);
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
async update(id, updateNotifTaskDto) {
|
|
29
|
+
const response = await this.client.patch(
|
|
30
|
+
`/api/notif-task/${id}`,
|
|
31
|
+
updateNotifTaskDto,
|
|
32
|
+
true
|
|
33
|
+
);
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
async remove(id) {
|
|
37
|
+
const response = await this.client.delete(
|
|
38
|
+
`/api/notif-task/${id}`,
|
|
39
|
+
true
|
|
40
|
+
);
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
async getSmsDetails(id) {
|
|
44
|
+
const response = await this.client.get(
|
|
45
|
+
`/api/notif-task/${id}/sms-details`,
|
|
46
|
+
true
|
|
47
|
+
);
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
async retryFailedSms(id) {
|
|
51
|
+
const response = await this.client.post(
|
|
52
|
+
`/api/notif-task/${id}/retry-failed-sms`,
|
|
53
|
+
{},
|
|
54
|
+
true
|
|
55
|
+
);
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
NotifTaskService
|
|
61
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-BOI4a9h5.mjs';
|
|
2
|
+
|
|
3
|
+
interface CreateSmsDto {
|
|
4
|
+
message: string;
|
|
5
|
+
phone: string;
|
|
6
|
+
}
|
|
7
|
+
interface SendSmsDto {
|
|
8
|
+
message: string;
|
|
9
|
+
phones: string[];
|
|
10
|
+
}
|
|
11
|
+
interface BulkSmsDto {
|
|
12
|
+
messages: {
|
|
13
|
+
phones: string[];
|
|
14
|
+
message: string;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
interface SendSmsResponseDto {
|
|
18
|
+
id: string;
|
|
19
|
+
message: string;
|
|
20
|
+
phone: string;
|
|
21
|
+
status: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
}
|
|
24
|
+
interface ResponseSmsDto {
|
|
25
|
+
id: string;
|
|
26
|
+
message: string;
|
|
27
|
+
phone: string;
|
|
28
|
+
status: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
}
|
|
32
|
+
interface MultiSmsResponseDto {
|
|
33
|
+
status: string;
|
|
34
|
+
data: {
|
|
35
|
+
id: string;
|
|
36
|
+
message: string;
|
|
37
|
+
phone: string;
|
|
38
|
+
status: string;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
interface BulkSmsResponseDto {
|
|
42
|
+
status: string;
|
|
43
|
+
data: {
|
|
44
|
+
id: string;
|
|
45
|
+
message: string;
|
|
46
|
+
phone: string;
|
|
47
|
+
status: string;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class SmsService {
|
|
52
|
+
private client;
|
|
53
|
+
constructor(client: ApiClient);
|
|
54
|
+
notify(message: string, numbers: string | string[]): Promise<MultiSmsResponseDto>;
|
|
55
|
+
notifyBulk(messages: {
|
|
56
|
+
message: string;
|
|
57
|
+
numbers: string | string[];
|
|
58
|
+
}[]): Promise<BulkSmsResponseDto>;
|
|
59
|
+
getAll(): Promise<ResponseSmsDto[]>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { type BulkSmsDto, type BulkSmsResponseDto, type CreateSmsDto, type MultiSmsResponseDto, type ResponseSmsDto, type SendSmsDto, type SendSmsResponseDto, SmsService };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-BOI4a9h5.js';
|
|
2
|
+
|
|
3
|
+
interface CreateSmsDto {
|
|
4
|
+
message: string;
|
|
5
|
+
phone: string;
|
|
6
|
+
}
|
|
7
|
+
interface SendSmsDto {
|
|
8
|
+
message: string;
|
|
9
|
+
phones: string[];
|
|
10
|
+
}
|
|
11
|
+
interface BulkSmsDto {
|
|
12
|
+
messages: {
|
|
13
|
+
phones: string[];
|
|
14
|
+
message: string;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
interface SendSmsResponseDto {
|
|
18
|
+
id: string;
|
|
19
|
+
message: string;
|
|
20
|
+
phone: string;
|
|
21
|
+
status: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
}
|
|
24
|
+
interface ResponseSmsDto {
|
|
25
|
+
id: string;
|
|
26
|
+
message: string;
|
|
27
|
+
phone: string;
|
|
28
|
+
status: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
}
|
|
32
|
+
interface MultiSmsResponseDto {
|
|
33
|
+
status: string;
|
|
34
|
+
data: {
|
|
35
|
+
id: string;
|
|
36
|
+
message: string;
|
|
37
|
+
phone: string;
|
|
38
|
+
status: string;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
interface BulkSmsResponseDto {
|
|
42
|
+
status: string;
|
|
43
|
+
data: {
|
|
44
|
+
id: string;
|
|
45
|
+
message: string;
|
|
46
|
+
phone: string;
|
|
47
|
+
status: string;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class SmsService {
|
|
52
|
+
private client;
|
|
53
|
+
constructor(client: ApiClient);
|
|
54
|
+
notify(message: string, numbers: string | string[]): Promise<MultiSmsResponseDto>;
|
|
55
|
+
notifyBulk(messages: {
|
|
56
|
+
message: string;
|
|
57
|
+
numbers: string | string[];
|
|
58
|
+
}[]): Promise<BulkSmsResponseDto>;
|
|
59
|
+
getAll(): Promise<ResponseSmsDto[]>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { type BulkSmsDto, type BulkSmsResponseDto, type CreateSmsDto, type MultiSmsResponseDto, type ResponseSmsDto, type SendSmsDto, type SendSmsResponseDto, SmsService };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/sms/index.ts
|
|
21
|
+
var sms_exports = {};
|
|
22
|
+
__export(sms_exports, {
|
|
23
|
+
SmsService: () => SmsService
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(sms_exports);
|
|
26
|
+
|
|
27
|
+
// src/sms.ts
|
|
28
|
+
var SmsService = class {
|
|
29
|
+
constructor(client) {
|
|
30
|
+
this.client = client;
|
|
31
|
+
}
|
|
32
|
+
async notify(message, numbers) {
|
|
33
|
+
const phones = Array.isArray(numbers) ? numbers : [numbers];
|
|
34
|
+
const response = await this.client.post(
|
|
35
|
+
"/api/sms/multi",
|
|
36
|
+
{ phones, message },
|
|
37
|
+
true
|
|
38
|
+
);
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
async notifyBulk(messages) {
|
|
42
|
+
const bulkMessages = messages.map((item) => ({
|
|
43
|
+
message: item.message,
|
|
44
|
+
phones: Array.isArray(item.numbers) ? item.numbers : [item.numbers]
|
|
45
|
+
}));
|
|
46
|
+
const response = await this.client.post(
|
|
47
|
+
"/api/sms/bulk",
|
|
48
|
+
{ messages: bulkMessages },
|
|
49
|
+
true
|
|
50
|
+
);
|
|
51
|
+
return response;
|
|
52
|
+
}
|
|
53
|
+
async getAll() {
|
|
54
|
+
const response = await this.client.get(
|
|
55
|
+
"/api/sms",
|
|
56
|
+
true
|
|
57
|
+
);
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
SmsService
|
|
64
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/sms.ts
|
|
2
|
+
var SmsService = class {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
async notify(message, numbers) {
|
|
7
|
+
const phones = Array.isArray(numbers) ? numbers : [numbers];
|
|
8
|
+
const response = await this.client.post(
|
|
9
|
+
"/api/sms/multi",
|
|
10
|
+
{ phones, message },
|
|
11
|
+
true
|
|
12
|
+
);
|
|
13
|
+
return response;
|
|
14
|
+
}
|
|
15
|
+
async notifyBulk(messages) {
|
|
16
|
+
const bulkMessages = messages.map((item) => ({
|
|
17
|
+
message: item.message,
|
|
18
|
+
phones: Array.isArray(item.numbers) ? item.numbers : [item.numbers]
|
|
19
|
+
}));
|
|
20
|
+
const response = await this.client.post(
|
|
21
|
+
"/api/sms/bulk",
|
|
22
|
+
{ messages: bulkMessages },
|
|
23
|
+
true
|
|
24
|
+
);
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
27
|
+
async getAll() {
|
|
28
|
+
const response = await this.client.get(
|
|
29
|
+
"/api/sms",
|
|
30
|
+
true
|
|
31
|
+
);
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
SmsService
|
|
37
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ariary/notification",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SMS et Notification Task SDK pour l'API Ariary",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./sms": {
|
|
15
|
+
"types": "./dist/sms/index.d.ts",
|
|
16
|
+
"import": "./dist/sms/index.mjs",
|
|
17
|
+
"require": "./dist/sms/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./notif-task": {
|
|
20
|
+
"types": "./dist/notif-task/index.d.ts",
|
|
21
|
+
"import": "./dist/notif-task/index.mjs",
|
|
22
|
+
"require": "./dist/notif-task/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"tsup": [
|
|
29
|
+
{
|
|
30
|
+
"entry": {
|
|
31
|
+
"index": "src/index.ts",
|
|
32
|
+
"sms/index": "src/sms/index.ts",
|
|
33
|
+
"notif-task/index": "src/notif-task/index.ts"
|
|
34
|
+
},
|
|
35
|
+
"format": [
|
|
36
|
+
"cjs",
|
|
37
|
+
"esm"
|
|
38
|
+
],
|
|
39
|
+
"outDir": "dist",
|
|
40
|
+
"dts": true,
|
|
41
|
+
"splitting": false,
|
|
42
|
+
"sourcemap": false,
|
|
43
|
+
"clean": true,
|
|
44
|
+
"minify": false
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"ariary",
|
|
52
|
+
"sms",
|
|
53
|
+
"notification",
|
|
54
|
+
"api"
|
|
55
|
+
],
|
|
56
|
+
"author": "Ariary",
|
|
57
|
+
"license": "ISC",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"axios": "^1.13.2"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"tsup": "^8.5.1",
|
|
66
|
+
"typescript": "^5.9.3"
|
|
67
|
+
}
|
|
68
|
+
}
|