@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/dist/index.mjs
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
* Gère les erreurs API
|
|
84
|
+
*/
|
|
85
|
+
handleError(error) {
|
|
86
|
+
if (error.response) {
|
|
87
|
+
const status = error.response.status;
|
|
88
|
+
const message = error.response.data?.message || error.response.statusText;
|
|
89
|
+
return new Error(`[${status}] ${message}`);
|
|
90
|
+
}
|
|
91
|
+
return error;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/payment.ts
|
|
96
|
+
var PaymentService = class {
|
|
97
|
+
constructor(client) {
|
|
98
|
+
this.client = client;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Crée un nouveau paiement
|
|
102
|
+
* @param paymentData Les données du paiement
|
|
103
|
+
* @returns La réponse de création du paiement
|
|
104
|
+
*/
|
|
105
|
+
async createPayment(paymentData) {
|
|
106
|
+
const response = await this.client.post(
|
|
107
|
+
"/api/payments",
|
|
108
|
+
paymentData,
|
|
109
|
+
false
|
|
110
|
+
);
|
|
111
|
+
return response;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Récupère tous les paiements de l'application
|
|
115
|
+
* @returns La liste de tous les paiements
|
|
116
|
+
*/
|
|
117
|
+
async getAllPayments() {
|
|
118
|
+
const response = await this.client.get(
|
|
119
|
+
"/api/payments",
|
|
120
|
+
false
|
|
121
|
+
);
|
|
122
|
+
return response;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Récupère un paiement par son ID
|
|
126
|
+
* @param paymentId L'ID du paiement à récupérer
|
|
127
|
+
* @returns Le paiement demandé
|
|
128
|
+
*/
|
|
129
|
+
async getPaymentById(paymentId) {
|
|
130
|
+
const response = await this.client.get(
|
|
131
|
+
`/api/payments/${paymentId}`,
|
|
132
|
+
false
|
|
133
|
+
);
|
|
134
|
+
return response;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Met à jour le reste d'un paiement avec un code de ticket
|
|
138
|
+
* @param paymentId L'ID du paiement à mettre à jour
|
|
139
|
+
* @param ticketCode Le code du ticket à associer
|
|
140
|
+
* @returns Le paiement mis à jour
|
|
141
|
+
*/
|
|
142
|
+
async updatePaymentRest(paymentId, ticketCode) {
|
|
143
|
+
const response = await this.client.put(
|
|
144
|
+
`/api/payments/${paymentId}/rest`,
|
|
145
|
+
{ ticketCode },
|
|
146
|
+
false
|
|
147
|
+
);
|
|
148
|
+
return response;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/sms.ts
|
|
153
|
+
var SmsService = class {
|
|
154
|
+
constructor(client) {
|
|
155
|
+
this.client = client;
|
|
156
|
+
}
|
|
157
|
+
async notify(message, numbers) {
|
|
158
|
+
const phones = Array.isArray(numbers) ? numbers : [numbers];
|
|
159
|
+
const response = await this.client.post(
|
|
160
|
+
"/api/sms/multi",
|
|
161
|
+
{ phones, message },
|
|
162
|
+
true
|
|
163
|
+
);
|
|
164
|
+
return response;
|
|
165
|
+
}
|
|
166
|
+
async notifyBulk(messages) {
|
|
167
|
+
const bulkMessages = messages.map((item) => ({
|
|
168
|
+
message: item.message,
|
|
169
|
+
phones: Array.isArray(item.numbers) ? item.numbers : [item.numbers]
|
|
170
|
+
}));
|
|
171
|
+
const response = await this.client.post(
|
|
172
|
+
"/api/sms/bulk",
|
|
173
|
+
{ messages: bulkMessages },
|
|
174
|
+
true
|
|
175
|
+
);
|
|
176
|
+
return response;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/transfert.ts
|
|
181
|
+
var TransferService = class {
|
|
182
|
+
constructor(client) {
|
|
183
|
+
this.client = client;
|
|
184
|
+
}
|
|
185
|
+
async send(phone, amount) {
|
|
186
|
+
const response = await this.client.post(
|
|
187
|
+
"/api/send-transaction",
|
|
188
|
+
{ phone, amount },
|
|
189
|
+
true
|
|
190
|
+
);
|
|
191
|
+
return response;
|
|
192
|
+
}
|
|
193
|
+
async getAll() {
|
|
194
|
+
const response = await this.client.get(
|
|
195
|
+
"/api/send-transaction",
|
|
196
|
+
true
|
|
197
|
+
);
|
|
198
|
+
return response;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// src/index.ts
|
|
203
|
+
var AriarySDK = class {
|
|
204
|
+
constructor(config) {
|
|
205
|
+
const finalConfig = { ...config, baseUrl: config.baseUrl || "https://back.ariari.mg/payment/api-docs" };
|
|
206
|
+
this.paymentClient = new ApiClient(finalConfig);
|
|
207
|
+
this.defaultClient = new ApiClient(finalConfig);
|
|
208
|
+
this.payment = new PaymentService(this.paymentClient);
|
|
209
|
+
this.sms = new SmsService(this.defaultClient);
|
|
210
|
+
this.transfer = new TransferService(this.defaultClient);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
async function sendPayment(code, amount, projectId, secretId) {
|
|
214
|
+
const sdk = new AriarySDK({ secretId, projectId });
|
|
215
|
+
const paymentData = { code, amount, projectId };
|
|
216
|
+
return sdk.payment.createPayment(paymentData);
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
ApiClient,
|
|
220
|
+
AriarySDK,
|
|
221
|
+
PaymentService,
|
|
222
|
+
SmsService,
|
|
223
|
+
TransferService,
|
|
224
|
+
sendPayment
|
|
225
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-DwMAE1vB.mjs';
|
|
2
|
+
|
|
3
|
+
interface CreatePaymentDto {
|
|
4
|
+
code: string;
|
|
5
|
+
amount: number;
|
|
6
|
+
projectId: string;
|
|
7
|
+
}
|
|
8
|
+
interface PaymentResponseDto {
|
|
9
|
+
id: string;
|
|
10
|
+
transactionId: string;
|
|
11
|
+
amount: number;
|
|
12
|
+
rest: number;
|
|
13
|
+
projectId: string;
|
|
14
|
+
status: string;
|
|
15
|
+
parts: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
amount: number;
|
|
18
|
+
transactionId: string;
|
|
19
|
+
date: string;
|
|
20
|
+
}>;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class PaymentService {
|
|
26
|
+
private client;
|
|
27
|
+
constructor(client: ApiClient);
|
|
28
|
+
/**
|
|
29
|
+
* Crée un nouveau paiement
|
|
30
|
+
* @param paymentData Les données du paiement
|
|
31
|
+
* @returns La réponse de création du paiement
|
|
32
|
+
*/
|
|
33
|
+
createPayment(paymentData: CreatePaymentDto): Promise<PaymentResponseDto>;
|
|
34
|
+
/**
|
|
35
|
+
* Récupère tous les paiements de l'application
|
|
36
|
+
* @returns La liste de tous les paiements
|
|
37
|
+
*/
|
|
38
|
+
getAllPayments(): Promise<PaymentResponseDto[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Récupère un paiement par son ID
|
|
41
|
+
* @param paymentId L'ID du paiement à récupérer
|
|
42
|
+
* @returns Le paiement demandé
|
|
43
|
+
*/
|
|
44
|
+
getPaymentById(paymentId: string): Promise<PaymentResponseDto>;
|
|
45
|
+
/**
|
|
46
|
+
* Met à jour le reste d'un paiement avec un code de ticket
|
|
47
|
+
* @param paymentId L'ID du paiement à mettre à jour
|
|
48
|
+
* @param ticketCode Le code du ticket à associer
|
|
49
|
+
* @returns Le paiement mis à jour
|
|
50
|
+
*/
|
|
51
|
+
updatePaymentRest(paymentId: string, ticketCode: string): Promise<PaymentResponseDto>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { type CreatePaymentDto, type PaymentResponseDto, PaymentService };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-DwMAE1vB.js';
|
|
2
|
+
|
|
3
|
+
interface CreatePaymentDto {
|
|
4
|
+
code: string;
|
|
5
|
+
amount: number;
|
|
6
|
+
projectId: string;
|
|
7
|
+
}
|
|
8
|
+
interface PaymentResponseDto {
|
|
9
|
+
id: string;
|
|
10
|
+
transactionId: string;
|
|
11
|
+
amount: number;
|
|
12
|
+
rest: number;
|
|
13
|
+
projectId: string;
|
|
14
|
+
status: string;
|
|
15
|
+
parts: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
amount: number;
|
|
18
|
+
transactionId: string;
|
|
19
|
+
date: string;
|
|
20
|
+
}>;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class PaymentService {
|
|
26
|
+
private client;
|
|
27
|
+
constructor(client: ApiClient);
|
|
28
|
+
/**
|
|
29
|
+
* Crée un nouveau paiement
|
|
30
|
+
* @param paymentData Les données du paiement
|
|
31
|
+
* @returns La réponse de création du paiement
|
|
32
|
+
*/
|
|
33
|
+
createPayment(paymentData: CreatePaymentDto): Promise<PaymentResponseDto>;
|
|
34
|
+
/**
|
|
35
|
+
* Récupère tous les paiements de l'application
|
|
36
|
+
* @returns La liste de tous les paiements
|
|
37
|
+
*/
|
|
38
|
+
getAllPayments(): Promise<PaymentResponseDto[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Récupère un paiement par son ID
|
|
41
|
+
* @param paymentId L'ID du paiement à récupérer
|
|
42
|
+
* @returns Le paiement demandé
|
|
43
|
+
*/
|
|
44
|
+
getPaymentById(paymentId: string): Promise<PaymentResponseDto>;
|
|
45
|
+
/**
|
|
46
|
+
* Met à jour le reste d'un paiement avec un code de ticket
|
|
47
|
+
* @param paymentId L'ID du paiement à mettre à jour
|
|
48
|
+
* @param ticketCode Le code du ticket à associer
|
|
49
|
+
* @returns Le paiement mis à jour
|
|
50
|
+
*/
|
|
51
|
+
updatePaymentRest(paymentId: string, ticketCode: string): Promise<PaymentResponseDto>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { type CreatePaymentDto, type PaymentResponseDto, PaymentService };
|
|
@@ -0,0 +1,86 @@
|
|
|
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/payment/index.ts
|
|
21
|
+
var payment_exports = {};
|
|
22
|
+
__export(payment_exports, {
|
|
23
|
+
PaymentService: () => PaymentService
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(payment_exports);
|
|
26
|
+
|
|
27
|
+
// src/payment.ts
|
|
28
|
+
var PaymentService = class {
|
|
29
|
+
constructor(client) {
|
|
30
|
+
this.client = client;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Crée un nouveau paiement
|
|
34
|
+
* @param paymentData Les données du paiement
|
|
35
|
+
* @returns La réponse de création du paiement
|
|
36
|
+
*/
|
|
37
|
+
async createPayment(paymentData) {
|
|
38
|
+
const response = await this.client.post(
|
|
39
|
+
"/api/payments",
|
|
40
|
+
paymentData,
|
|
41
|
+
false
|
|
42
|
+
);
|
|
43
|
+
return response;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Récupère tous les paiements de l'application
|
|
47
|
+
* @returns La liste de tous les paiements
|
|
48
|
+
*/
|
|
49
|
+
async getAllPayments() {
|
|
50
|
+
const response = await this.client.get(
|
|
51
|
+
"/api/payments",
|
|
52
|
+
false
|
|
53
|
+
);
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Récupère un paiement par son ID
|
|
58
|
+
* @param paymentId L'ID du paiement à récupérer
|
|
59
|
+
* @returns Le paiement demandé
|
|
60
|
+
*/
|
|
61
|
+
async getPaymentById(paymentId) {
|
|
62
|
+
const response = await this.client.get(
|
|
63
|
+
`/api/payments/${paymentId}`,
|
|
64
|
+
false
|
|
65
|
+
);
|
|
66
|
+
return response;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Met à jour le reste d'un paiement avec un code de ticket
|
|
70
|
+
* @param paymentId L'ID du paiement à mettre à jour
|
|
71
|
+
* @param ticketCode Le code du ticket à associer
|
|
72
|
+
* @returns Le paiement mis à jour
|
|
73
|
+
*/
|
|
74
|
+
async updatePaymentRest(paymentId, ticketCode) {
|
|
75
|
+
const response = await this.client.put(
|
|
76
|
+
`/api/payments/${paymentId}/rest`,
|
|
77
|
+
{ ticketCode },
|
|
78
|
+
false
|
|
79
|
+
);
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
PaymentService
|
|
86
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/payment.ts
|
|
2
|
+
var PaymentService = class {
|
|
3
|
+
constructor(client) {
|
|
4
|
+
this.client = client;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Crée un nouveau paiement
|
|
8
|
+
* @param paymentData Les données du paiement
|
|
9
|
+
* @returns La réponse de création du paiement
|
|
10
|
+
*/
|
|
11
|
+
async createPayment(paymentData) {
|
|
12
|
+
const response = await this.client.post(
|
|
13
|
+
"/api/payments",
|
|
14
|
+
paymentData,
|
|
15
|
+
false
|
|
16
|
+
);
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Récupère tous les paiements de l'application
|
|
21
|
+
* @returns La liste de tous les paiements
|
|
22
|
+
*/
|
|
23
|
+
async getAllPayments() {
|
|
24
|
+
const response = await this.client.get(
|
|
25
|
+
"/api/payments",
|
|
26
|
+
false
|
|
27
|
+
);
|
|
28
|
+
return response;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Récupère un paiement par son ID
|
|
32
|
+
* @param paymentId L'ID du paiement à récupérer
|
|
33
|
+
* @returns Le paiement demandé
|
|
34
|
+
*/
|
|
35
|
+
async getPaymentById(paymentId) {
|
|
36
|
+
const response = await this.client.get(
|
|
37
|
+
`/api/payments/${paymentId}`,
|
|
38
|
+
false
|
|
39
|
+
);
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Met à jour le reste d'un paiement avec un code de ticket
|
|
44
|
+
* @param paymentId L'ID du paiement à mettre à jour
|
|
45
|
+
* @param ticketCode Le code du ticket à associer
|
|
46
|
+
* @returns Le paiement mis à jour
|
|
47
|
+
*/
|
|
48
|
+
async updatePaymentRest(paymentId, ticketCode) {
|
|
49
|
+
const response = await this.client.put(
|
|
50
|
+
`/api/payments/${paymentId}/rest`,
|
|
51
|
+
{ ticketCode },
|
|
52
|
+
false
|
|
53
|
+
);
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
PaymentService
|
|
59
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-DwMAE1vB.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
|
+
}
|
|
60
|
+
|
|
61
|
+
export { type BulkSmsDto, type BulkSmsResponseDto, type CreateSmsDto, type MultiSmsResponseDto, type ResponseSmsDto, type SendSmsDto, type SendSmsResponseDto, SmsService };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { a as ApiClient } from '../client-DwMAE1vB.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
|
+
}
|
|
60
|
+
|
|
61
|
+
export { type BulkSmsDto, type BulkSmsResponseDto, type CreateSmsDto, type MultiSmsResponseDto, type ResponseSmsDto, type SendSmsDto, type SendSmsResponseDto, SmsService };
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
SmsService
|
|
57
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
SmsService
|
|
30
|
+
};
|