@ariary/notification 4.1.0 → 4.2.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/dist/index.d.mts +334 -37
- package/dist/index.d.ts +334 -37
- package/dist/index.js +774 -77
- package/dist/index.mjs +774 -77
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25,41 +25,6 @@ __export(src_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
27
|
|
|
28
|
-
// ../common/http.ts
|
|
29
|
-
async function request(verb, endpoint, options, config) {
|
|
30
|
-
if (!config) throw new Error("Ariari package not configured.");
|
|
31
|
-
const url = `${config.baseUrl || "https://api.ariari.mg"}${endpoint}`;
|
|
32
|
-
const headers = { "Content-Type": "application/json" };
|
|
33
|
-
if (!options.public) {
|
|
34
|
-
headers["x-secret"] = config.secret;
|
|
35
|
-
}
|
|
36
|
-
const fetchOptions = { method: verb, headers };
|
|
37
|
-
if ("body" in options && options.body) {
|
|
38
|
-
fetchOptions.body = JSON.stringify(options.body);
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
const response = await fetch(url, fetchOptions);
|
|
42
|
-
const data = await response.json();
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
const message = data?.message || "Unknown error";
|
|
45
|
-
throw new Error(`[${response.status}] ${message}`);
|
|
46
|
-
}
|
|
47
|
-
return data;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (error instanceof Error) {
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
throw new Error("Network error");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
var createRequester = (config) => ({
|
|
56
|
-
get: (url, data = {}) => request("GET", url, data, config),
|
|
57
|
-
post: (url, data = {}) => request("POST", url, data, config),
|
|
58
|
-
patch: (url, data = {}) => request("PATCH", url, data, config),
|
|
59
|
-
put: (url, data = {}) => request("PUT", url, data, config),
|
|
60
|
-
delete: (url, data = {}) => request("DELETE", url, data, config)
|
|
61
|
-
});
|
|
62
|
-
|
|
63
28
|
// ../common/phone.ts
|
|
64
29
|
var normalizePhoneNumber = (phone) => {
|
|
65
30
|
let normalized = phone.replace(/\D/g, "");
|
|
@@ -67,6 +32,317 @@ var normalizePhoneNumber = (phone) => {
|
|
|
67
32
|
return normalized;
|
|
68
33
|
};
|
|
69
34
|
|
|
35
|
+
// ../common/gen/runtime.ts
|
|
36
|
+
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
37
|
+
var Configuration = class {
|
|
38
|
+
constructor(configuration = {}) {
|
|
39
|
+
this.configuration = configuration;
|
|
40
|
+
}
|
|
41
|
+
set config(configuration) {
|
|
42
|
+
this.configuration = configuration;
|
|
43
|
+
}
|
|
44
|
+
get basePath() {
|
|
45
|
+
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
|
|
46
|
+
}
|
|
47
|
+
get fetchApi() {
|
|
48
|
+
return this.configuration.fetchApi;
|
|
49
|
+
}
|
|
50
|
+
get middleware() {
|
|
51
|
+
return this.configuration.middleware || [];
|
|
52
|
+
}
|
|
53
|
+
get queryParamsStringify() {
|
|
54
|
+
return this.configuration.queryParamsStringify || querystring;
|
|
55
|
+
}
|
|
56
|
+
get username() {
|
|
57
|
+
return this.configuration.username;
|
|
58
|
+
}
|
|
59
|
+
get password() {
|
|
60
|
+
return this.configuration.password;
|
|
61
|
+
}
|
|
62
|
+
get apiKey() {
|
|
63
|
+
const apiKey = this.configuration.apiKey;
|
|
64
|
+
if (apiKey) {
|
|
65
|
+
return typeof apiKey === "function" ? apiKey : () => apiKey;
|
|
66
|
+
}
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
get accessToken() {
|
|
70
|
+
const accessToken = this.configuration.accessToken;
|
|
71
|
+
if (accessToken) {
|
|
72
|
+
return typeof accessToken === "function" ? accessToken : async () => accessToken;
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
get headers() {
|
|
77
|
+
return this.configuration.headers;
|
|
78
|
+
}
|
|
79
|
+
get credentials() {
|
|
80
|
+
return this.configuration.credentials;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
var DefaultConfig = new Configuration();
|
|
84
|
+
var _BaseAPI = class _BaseAPI {
|
|
85
|
+
constructor(configuration = DefaultConfig) {
|
|
86
|
+
this.configuration = configuration;
|
|
87
|
+
this.fetchApi = async (url, init) => {
|
|
88
|
+
let fetchParams = { url, init };
|
|
89
|
+
for (const middleware of this.middleware) {
|
|
90
|
+
if (middleware.pre) {
|
|
91
|
+
fetchParams = await middleware.pre({
|
|
92
|
+
fetch: this.fetchApi,
|
|
93
|
+
...fetchParams
|
|
94
|
+
}) || fetchParams;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
let response = void 0;
|
|
98
|
+
try {
|
|
99
|
+
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
for (const middleware of this.middleware) {
|
|
102
|
+
if (middleware.onError) {
|
|
103
|
+
response = await middleware.onError({
|
|
104
|
+
fetch: this.fetchApi,
|
|
105
|
+
url: fetchParams.url,
|
|
106
|
+
init: fetchParams.init,
|
|
107
|
+
error: e,
|
|
108
|
+
response: response ? response.clone() : void 0
|
|
109
|
+
}) || response;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (response === void 0) {
|
|
113
|
+
if (e instanceof Error) {
|
|
114
|
+
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
|
|
115
|
+
} else {
|
|
116
|
+
throw e;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const middleware of this.middleware) {
|
|
121
|
+
if (middleware.post) {
|
|
122
|
+
response = await middleware.post({
|
|
123
|
+
fetch: this.fetchApi,
|
|
124
|
+
url: fetchParams.url,
|
|
125
|
+
init: fetchParams.init,
|
|
126
|
+
response: response.clone()
|
|
127
|
+
}) || response;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return response;
|
|
131
|
+
};
|
|
132
|
+
this.middleware = configuration.middleware;
|
|
133
|
+
}
|
|
134
|
+
withMiddleware(...middlewares) {
|
|
135
|
+
const next = this.clone();
|
|
136
|
+
next.middleware = next.middleware.concat(...middlewares);
|
|
137
|
+
return next;
|
|
138
|
+
}
|
|
139
|
+
withPreMiddleware(...preMiddlewares) {
|
|
140
|
+
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
141
|
+
return this.withMiddleware(...middlewares);
|
|
142
|
+
}
|
|
143
|
+
withPostMiddleware(...postMiddlewares) {
|
|
144
|
+
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
145
|
+
return this.withMiddleware(...middlewares);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if the given MIME is a JSON MIME.
|
|
149
|
+
* JSON MIME examples:
|
|
150
|
+
* application/json
|
|
151
|
+
* application/json; charset=UTF8
|
|
152
|
+
* APPLICATION/JSON
|
|
153
|
+
* application/vnd.company+json
|
|
154
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
155
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
156
|
+
*/
|
|
157
|
+
isJsonMime(mime) {
|
|
158
|
+
if (!mime) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return _BaseAPI.jsonRegex.test(mime);
|
|
162
|
+
}
|
|
163
|
+
async request(context, initOverrides) {
|
|
164
|
+
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
165
|
+
const response = await this.fetchApi(url, init);
|
|
166
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
167
|
+
return response;
|
|
168
|
+
}
|
|
169
|
+
throw new ResponseError(response, "Response returned an error code");
|
|
170
|
+
}
|
|
171
|
+
async createFetchParams(context, initOverrides) {
|
|
172
|
+
let url = this.configuration.basePath + context.path;
|
|
173
|
+
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
|
|
174
|
+
url += "?" + this.configuration.queryParamsStringify(context.query);
|
|
175
|
+
}
|
|
176
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
177
|
+
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
|
|
178
|
+
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
|
|
179
|
+
const initParams = {
|
|
180
|
+
method: context.method,
|
|
181
|
+
headers,
|
|
182
|
+
body: context.body,
|
|
183
|
+
credentials: this.configuration.credentials
|
|
184
|
+
};
|
|
185
|
+
const overriddenInit = {
|
|
186
|
+
...initParams,
|
|
187
|
+
...await initOverrideFn({
|
|
188
|
+
init: initParams,
|
|
189
|
+
context
|
|
190
|
+
})
|
|
191
|
+
};
|
|
192
|
+
let body;
|
|
193
|
+
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
|
|
194
|
+
body = overriddenInit.body;
|
|
195
|
+
} else if (this.isJsonMime(headers["Content-Type"])) {
|
|
196
|
+
body = JSON.stringify(overriddenInit.body);
|
|
197
|
+
} else {
|
|
198
|
+
body = overriddenInit.body;
|
|
199
|
+
}
|
|
200
|
+
const init = {
|
|
201
|
+
...overriddenInit,
|
|
202
|
+
body
|
|
203
|
+
};
|
|
204
|
+
return { url, init };
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Create a shallow clone of `this` by constructing a new instance
|
|
208
|
+
* and then shallow cloning data members.
|
|
209
|
+
*/
|
|
210
|
+
clone() {
|
|
211
|
+
const constructor = this.constructor;
|
|
212
|
+
const next = new constructor(this.configuration);
|
|
213
|
+
next.middleware = this.middleware.slice();
|
|
214
|
+
return next;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
_BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
|
|
218
|
+
var BaseAPI = _BaseAPI;
|
|
219
|
+
function isBlob(value) {
|
|
220
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
221
|
+
}
|
|
222
|
+
function isFormData(value) {
|
|
223
|
+
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
224
|
+
}
|
|
225
|
+
var ResponseError = class extends Error {
|
|
226
|
+
constructor(response, msg) {
|
|
227
|
+
super(msg);
|
|
228
|
+
this.response = response;
|
|
229
|
+
this.name = "ResponseError";
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
var FetchError = class extends Error {
|
|
233
|
+
constructor(cause, msg) {
|
|
234
|
+
super(msg);
|
|
235
|
+
this.cause = cause;
|
|
236
|
+
this.name = "FetchError";
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
var RequiredError = class extends Error {
|
|
240
|
+
constructor(field, msg) {
|
|
241
|
+
super(msg);
|
|
242
|
+
this.field = field;
|
|
243
|
+
this.name = "RequiredError";
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
function querystring(params, prefix = "") {
|
|
247
|
+
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
|
|
248
|
+
}
|
|
249
|
+
function querystringSingleKey(key, value, keyPrefix = "") {
|
|
250
|
+
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
251
|
+
if (value instanceof Array) {
|
|
252
|
+
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
|
|
253
|
+
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
254
|
+
}
|
|
255
|
+
if (value instanceof Set) {
|
|
256
|
+
const valueAsArray = Array.from(value);
|
|
257
|
+
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
|
258
|
+
}
|
|
259
|
+
if (value instanceof Date) {
|
|
260
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
261
|
+
}
|
|
262
|
+
if (value instanceof Object) {
|
|
263
|
+
return querystring(value, fullKey);
|
|
264
|
+
}
|
|
265
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
266
|
+
}
|
|
267
|
+
var JSONApiResponse = class {
|
|
268
|
+
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
269
|
+
this.raw = raw;
|
|
270
|
+
this.transformer = transformer;
|
|
271
|
+
}
|
|
272
|
+
async value() {
|
|
273
|
+
return this.transformer(await this.raw.json());
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// ../common/gen/models/SmsMessage.ts
|
|
278
|
+
function SmsMessageToJSON(json) {
|
|
279
|
+
return SmsMessageToJSONTyped(json, false);
|
|
280
|
+
}
|
|
281
|
+
function SmsMessageToJSONTyped(value, ignoreDiscriminator = false) {
|
|
282
|
+
if (value == null) {
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
"phones": value["phones"],
|
|
287
|
+
"message": value["message"]
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ../common/gen/models/BulkSms.ts
|
|
292
|
+
function BulkSmsToJSON(json) {
|
|
293
|
+
return BulkSmsToJSONTyped(json, false);
|
|
294
|
+
}
|
|
295
|
+
function BulkSmsToJSONTyped(value, ignoreDiscriminator = false) {
|
|
296
|
+
if (value == null) {
|
|
297
|
+
return value;
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
"messages": value["messages"].map(SmsMessageToJSON),
|
|
301
|
+
"scheduledAt": value["scheduledAt"]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// ../common/gen/models/EstimateMessage.ts
|
|
306
|
+
function EstimateMessageToJSON(json) {
|
|
307
|
+
return EstimateMessageToJSONTyped(json, false);
|
|
308
|
+
}
|
|
309
|
+
function EstimateMessageToJSONTyped(value, ignoreDiscriminator = false) {
|
|
310
|
+
if (value == null) {
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
"text": value["text"],
|
|
315
|
+
"repeat": value["repeat"]
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ../common/gen/models/EstimateSms.ts
|
|
320
|
+
function EstimateSmsToJSON(json) {
|
|
321
|
+
return EstimateSmsToJSONTyped(json, false);
|
|
322
|
+
}
|
|
323
|
+
function EstimateSmsToJSONTyped(value, ignoreDiscriminator = false) {
|
|
324
|
+
if (value == null) {
|
|
325
|
+
return value;
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
"messages": value["messages"].map(EstimateMessageToJSON)
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// ../common/gen/models/EstimateSmsResponse.ts
|
|
333
|
+
function EstimateSmsResponseFromJSON(json) {
|
|
334
|
+
return EstimateSmsResponseFromJSONTyped(json, false);
|
|
335
|
+
}
|
|
336
|
+
function EstimateSmsResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
337
|
+
if (json == null) {
|
|
338
|
+
return json;
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
"sms": json["sms"],
|
|
342
|
+
"credit": json["credit"]
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
70
346
|
// ../common/gen/models/NotifTaskStatus.ts
|
|
71
347
|
function NotifTaskStatusFromJSON(json) {
|
|
72
348
|
return NotifTaskStatusFromJSONTyped(json, false);
|
|
@@ -83,6 +359,64 @@ function NotifTaskStatusFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
83
359
|
};
|
|
84
360
|
}
|
|
85
361
|
|
|
362
|
+
// ../common/gen/models/SmsStatus.ts
|
|
363
|
+
function SmsStatusFromJSON(json) {
|
|
364
|
+
return SmsStatusFromJSONTyped(json, false);
|
|
365
|
+
}
|
|
366
|
+
function SmsStatusFromJSONTyped(json, ignoreDiscriminator) {
|
|
367
|
+
return json;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// ../common/gen/models/SmsDetail.ts
|
|
371
|
+
function SmsDetailFromJSON(json) {
|
|
372
|
+
return SmsDetailFromJSONTyped(json, false);
|
|
373
|
+
}
|
|
374
|
+
function SmsDetailFromJSONTyped(json, ignoreDiscriminator) {
|
|
375
|
+
if (json == null) {
|
|
376
|
+
return json;
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
"smsId": json["smsId"],
|
|
380
|
+
"phone": json["phone"],
|
|
381
|
+
"message": json["message"],
|
|
382
|
+
"status": SmsStatusFromJSON(json["status"]),
|
|
383
|
+
"retryCount": json["retryCount"]
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// ../common/gen/models/NotifTaskWithSms.ts
|
|
388
|
+
function NotifTaskWithSmsFromJSON(json) {
|
|
389
|
+
return NotifTaskWithSmsFromJSONTyped(json, false);
|
|
390
|
+
}
|
|
391
|
+
function NotifTaskWithSmsFromJSONTyped(json, ignoreDiscriminator) {
|
|
392
|
+
if (json == null) {
|
|
393
|
+
return json;
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
"taskId": json["taskId"],
|
|
397
|
+
"status": NotifTaskStatusFromJSON(json["status"]),
|
|
398
|
+
"statusPage": NotifTaskStatusFromJSON(json["statusPage"]),
|
|
399
|
+
"createdAt": new Date(json["createdAt"]),
|
|
400
|
+
"scheduledAt": json["scheduledAt"] == null ? void 0 : new Date(json["scheduledAt"]),
|
|
401
|
+
"sms": json["sms"].map(SmsDetailFromJSON)
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ../common/gen/models/PaginationParams.ts
|
|
406
|
+
function PaginationParamsFromJSON(json) {
|
|
407
|
+
return PaginationParamsFromJSONTyped(json, false);
|
|
408
|
+
}
|
|
409
|
+
function PaginationParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
410
|
+
if (json == null) {
|
|
411
|
+
return json;
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
"from": json["from"] == null ? void 0 : json["from"],
|
|
415
|
+
"count": json["count"] == null ? void 0 : json["count"],
|
|
416
|
+
"order": json["order"] == null ? void 0 : json["order"]
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
86
420
|
// ../common/gen/models/ResponseNotifTask.ts
|
|
87
421
|
function ResponseNotifTaskFromJSON(json) {
|
|
88
422
|
return ResponseNotifTaskFromJSONTyped(json, false);
|
|
@@ -100,31 +434,401 @@ function ResponseNotifTaskFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
100
434
|
};
|
|
101
435
|
}
|
|
102
436
|
|
|
103
|
-
// ../common/gen/models/
|
|
104
|
-
function
|
|
105
|
-
return
|
|
437
|
+
// ../common/gen/models/PaginatedNotifTaskResponse.ts
|
|
438
|
+
function PaginatedNotifTaskResponseFromJSON(json) {
|
|
439
|
+
return PaginatedNotifTaskResponseFromJSONTyped(json, false);
|
|
106
440
|
}
|
|
107
|
-
function
|
|
108
|
-
|
|
441
|
+
function PaginatedNotifTaskResponseFromJSONTyped(json, ignoreDiscriminator) {
|
|
442
|
+
if (json == null) {
|
|
443
|
+
return json;
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
"tasks": json["tasks"].map(ResponseNotifTaskFromJSON),
|
|
447
|
+
"next": PaginationParamsFromJSON(json["next"]),
|
|
448
|
+
"prev": json["prev"] == null ? void 0 : PaginationParamsFromJSON(json["prev"])
|
|
449
|
+
};
|
|
109
450
|
}
|
|
110
451
|
|
|
111
|
-
// ../common/gen/models/
|
|
112
|
-
function
|
|
113
|
-
return
|
|
452
|
+
// ../common/gen/models/ResponseSms.ts
|
|
453
|
+
function ResponseSmsFromJSON(json) {
|
|
454
|
+
return ResponseSmsFromJSONTyped(json, false);
|
|
114
455
|
}
|
|
115
|
-
function
|
|
456
|
+
function ResponseSmsFromJSONTyped(json, ignoreDiscriminator) {
|
|
116
457
|
if (json == null) {
|
|
117
458
|
return json;
|
|
118
459
|
}
|
|
119
460
|
return {
|
|
120
|
-
"
|
|
461
|
+
"id": json["_id"],
|
|
121
462
|
"phone": json["phone"],
|
|
122
|
-
"message": json["message"],
|
|
123
463
|
"status": SmsStatusFromJSON(json["status"]),
|
|
124
|
-
"
|
|
464
|
+
"createdAt": new Date(json["createdAt"]),
|
|
465
|
+
"simItem": json["simItem"] == null ? void 0 : json["simItem"]
|
|
125
466
|
};
|
|
126
467
|
}
|
|
127
468
|
|
|
469
|
+
// ../common/gen/apis/NotifTaskApi.ts
|
|
470
|
+
var NotifTaskApi = class extends BaseAPI {
|
|
471
|
+
/**
|
|
472
|
+
* Creates request options for notifTaskFindAll without sending the request
|
|
473
|
+
*/
|
|
474
|
+
async notifTaskFindAllRequestOpts(requestParameters) {
|
|
475
|
+
if (requestParameters["xSecret"] == null) {
|
|
476
|
+
throw new RequiredError(
|
|
477
|
+
"xSecret",
|
|
478
|
+
'Required parameter "xSecret" was null or undefined when calling notifTaskFindAll().'
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
if (requestParameters["from"] == null) {
|
|
482
|
+
throw new RequiredError(
|
|
483
|
+
"from",
|
|
484
|
+
'Required parameter "from" was null or undefined when calling notifTaskFindAll().'
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
if (requestParameters["count"] == null) {
|
|
488
|
+
throw new RequiredError(
|
|
489
|
+
"count",
|
|
490
|
+
'Required parameter "count" was null or undefined when calling notifTaskFindAll().'
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
if (requestParameters["order"] == null) {
|
|
494
|
+
throw new RequiredError(
|
|
495
|
+
"order",
|
|
496
|
+
'Required parameter "order" was null or undefined when calling notifTaskFindAll().'
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
if (requestParameters["projectId"] == null) {
|
|
500
|
+
throw new RequiredError(
|
|
501
|
+
"projectId",
|
|
502
|
+
'Required parameter "projectId" was null or undefined when calling notifTaskFindAll().'
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
const queryParameters = {};
|
|
506
|
+
if (requestParameters["from"] != null) {
|
|
507
|
+
queryParameters["from"] = requestParameters["from"];
|
|
508
|
+
}
|
|
509
|
+
if (requestParameters["count"] != null) {
|
|
510
|
+
queryParameters["count"] = requestParameters["count"];
|
|
511
|
+
}
|
|
512
|
+
if (requestParameters["order"] != null) {
|
|
513
|
+
queryParameters["order"] = requestParameters["order"];
|
|
514
|
+
}
|
|
515
|
+
if (requestParameters["projectId"] != null) {
|
|
516
|
+
queryParameters["projectId"] = requestParameters["projectId"];
|
|
517
|
+
}
|
|
518
|
+
const headerParameters = {};
|
|
519
|
+
if (requestParameters["xSecret"] != null) {
|
|
520
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
521
|
+
}
|
|
522
|
+
let urlPath = `/api/notif-task`;
|
|
523
|
+
return {
|
|
524
|
+
path: urlPath,
|
|
525
|
+
method: "GET",
|
|
526
|
+
headers: headerParameters,
|
|
527
|
+
query: queryParameters
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Récupérer les tâches avec pagination
|
|
532
|
+
*/
|
|
533
|
+
async notifTaskFindAllRaw(requestParameters, initOverrides) {
|
|
534
|
+
const requestOptions = await this.notifTaskFindAllRequestOpts(requestParameters);
|
|
535
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
536
|
+
return new JSONApiResponse(response, (jsonValue) => PaginatedNotifTaskResponseFromJSON(jsonValue));
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Récupérer les tâches avec pagination
|
|
540
|
+
*/
|
|
541
|
+
async notifTaskFindAll(requestParameters, initOverrides) {
|
|
542
|
+
const response = await this.notifTaskFindAllRaw(requestParameters, initOverrides);
|
|
543
|
+
return await response.value();
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Creates request options for notifTaskFindAllWithSms without sending the request
|
|
547
|
+
*/
|
|
548
|
+
async notifTaskFindAllWithSmsRequestOpts(requestParameters) {
|
|
549
|
+
if (requestParameters["xSecret"] == null) {
|
|
550
|
+
throw new RequiredError(
|
|
551
|
+
"xSecret",
|
|
552
|
+
'Required parameter "xSecret" was null or undefined when calling notifTaskFindAllWithSms().'
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
if (requestParameters["projectId"] == null) {
|
|
556
|
+
throw new RequiredError(
|
|
557
|
+
"projectId",
|
|
558
|
+
'Required parameter "projectId" was null or undefined when calling notifTaskFindAllWithSms().'
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
if (requestParameters["days"] == null) {
|
|
562
|
+
throw new RequiredError(
|
|
563
|
+
"days",
|
|
564
|
+
'Required parameter "days" was null or undefined when calling notifTaskFindAllWithSms().'
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
const queryParameters = {};
|
|
568
|
+
const headerParameters = {};
|
|
569
|
+
if (requestParameters["xSecret"] != null) {
|
|
570
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
571
|
+
}
|
|
572
|
+
let urlPath = `/api/notif-task/history/{projectId}/{days}`;
|
|
573
|
+
urlPath = urlPath.replace(`{${"projectId"}}`, encodeURIComponent(String(requestParameters["projectId"])));
|
|
574
|
+
urlPath = urlPath.replace(`{${"days"}}`, encodeURIComponent(String(requestParameters["days"])));
|
|
575
|
+
return {
|
|
576
|
+
path: urlPath,
|
|
577
|
+
method: "GET",
|
|
578
|
+
headers: headerParameters,
|
|
579
|
+
query: queryParameters
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Récupérer toutes les tâches avec SMS détaillés sur N jours pour un projet
|
|
584
|
+
*/
|
|
585
|
+
async notifTaskFindAllWithSmsRaw(requestParameters, initOverrides) {
|
|
586
|
+
const requestOptions = await this.notifTaskFindAllWithSmsRequestOpts(requestParameters);
|
|
587
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
588
|
+
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(NotifTaskWithSmsFromJSON));
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Récupérer toutes les tâches avec SMS détaillés sur N jours pour un projet
|
|
592
|
+
*/
|
|
593
|
+
async notifTaskFindAllWithSms(requestParameters, initOverrides) {
|
|
594
|
+
const response = await this.notifTaskFindAllWithSmsRaw(requestParameters, initOverrides);
|
|
595
|
+
return await response.value();
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Creates request options for notifTaskFindOne without sending the request
|
|
599
|
+
*/
|
|
600
|
+
async notifTaskFindOneRequestOpts(requestParameters) {
|
|
601
|
+
if (requestParameters["xSecret"] == null) {
|
|
602
|
+
throw new RequiredError(
|
|
603
|
+
"xSecret",
|
|
604
|
+
'Required parameter "xSecret" was null or undefined when calling notifTaskFindOne().'
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
if (requestParameters["id"] == null) {
|
|
608
|
+
throw new RequiredError(
|
|
609
|
+
"id",
|
|
610
|
+
'Required parameter "id" was null or undefined when calling notifTaskFindOne().'
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
if (requestParameters["details"] == null) {
|
|
614
|
+
throw new RequiredError(
|
|
615
|
+
"details",
|
|
616
|
+
'Required parameter "details" was null or undefined when calling notifTaskFindOne().'
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
const queryParameters = {};
|
|
620
|
+
if (requestParameters["details"] != null) {
|
|
621
|
+
queryParameters["details"] = requestParameters["details"];
|
|
622
|
+
}
|
|
623
|
+
const headerParameters = {};
|
|
624
|
+
if (requestParameters["xSecret"] != null) {
|
|
625
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
626
|
+
}
|
|
627
|
+
let urlPath = `/api/notif-task/{id}`;
|
|
628
|
+
urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));
|
|
629
|
+
return {
|
|
630
|
+
path: urlPath,
|
|
631
|
+
method: "GET",
|
|
632
|
+
headers: headerParameters,
|
|
633
|
+
query: queryParameters
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Récupérer une tâche par ID, avec SMS optionnels via ?details=limit,page
|
|
638
|
+
*/
|
|
639
|
+
async notifTaskFindOneRaw(requestParameters, initOverrides) {
|
|
640
|
+
const requestOptions = await this.notifTaskFindOneRequestOpts(requestParameters);
|
|
641
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
642
|
+
return new JSONApiResponse(response, (jsonValue) => NotifTaskWithSmsFromJSON(jsonValue));
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Récupérer une tâche par ID, avec SMS optionnels via ?details=limit,page
|
|
646
|
+
*/
|
|
647
|
+
async notifTaskFindOne(requestParameters, initOverrides) {
|
|
648
|
+
const response = await this.notifTaskFindOneRaw(requestParameters, initOverrides);
|
|
649
|
+
return await response.value();
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
// ../common/gen/apis/SmsApi.ts
|
|
654
|
+
var SmsApi = class extends BaseAPI {
|
|
655
|
+
/**
|
|
656
|
+
* Creates request options for smsEstimate without sending the request
|
|
657
|
+
*/
|
|
658
|
+
async smsEstimateRequestOpts(requestParameters) {
|
|
659
|
+
if (requestParameters["xSecret"] == null) {
|
|
660
|
+
throw new RequiredError(
|
|
661
|
+
"xSecret",
|
|
662
|
+
'Required parameter "xSecret" was null or undefined when calling smsEstimate().'
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
if (requestParameters["estimateSms"] == null) {
|
|
666
|
+
throw new RequiredError(
|
|
667
|
+
"estimateSms",
|
|
668
|
+
'Required parameter "estimateSms" was null or undefined when calling smsEstimate().'
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
const queryParameters = {};
|
|
672
|
+
const headerParameters = {};
|
|
673
|
+
headerParameters["Content-Type"] = "application/json";
|
|
674
|
+
if (requestParameters["xSecret"] != null) {
|
|
675
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
676
|
+
}
|
|
677
|
+
let urlPath = `/api/sms/estimate`;
|
|
678
|
+
return {
|
|
679
|
+
path: urlPath,
|
|
680
|
+
method: "POST",
|
|
681
|
+
headers: headerParameters,
|
|
682
|
+
query: queryParameters,
|
|
683
|
+
body: EstimateSmsToJSON(requestParameters["estimateSms"])
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Estimate SMS credit consumption for a list of messages
|
|
688
|
+
*/
|
|
689
|
+
async smsEstimateRaw(requestParameters, initOverrides) {
|
|
690
|
+
const requestOptions = await this.smsEstimateRequestOpts(requestParameters);
|
|
691
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
692
|
+
return new JSONApiResponse(response, (jsonValue) => EstimateSmsResponseFromJSON(jsonValue));
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Estimate SMS credit consumption for a list of messages
|
|
696
|
+
*/
|
|
697
|
+
async smsEstimate(requestParameters, initOverrides) {
|
|
698
|
+
const response = await this.smsEstimateRaw(requestParameters, initOverrides);
|
|
699
|
+
return await response.value();
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Creates request options for smsFindAll without sending the request
|
|
703
|
+
*/
|
|
704
|
+
async smsFindAllRequestOpts(requestParameters) {
|
|
705
|
+
if (requestParameters["xSecret"] == null) {
|
|
706
|
+
throw new RequiredError(
|
|
707
|
+
"xSecret",
|
|
708
|
+
'Required parameter "xSecret" was null or undefined when calling smsFindAll().'
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
const queryParameters = {};
|
|
712
|
+
const headerParameters = {};
|
|
713
|
+
if (requestParameters["xSecret"] != null) {
|
|
714
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
715
|
+
}
|
|
716
|
+
let urlPath = `/api/sms`;
|
|
717
|
+
return {
|
|
718
|
+
path: urlPath,
|
|
719
|
+
method: "GET",
|
|
720
|
+
headers: headerParameters,
|
|
721
|
+
query: queryParameters
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Récupérer l\'historique des SMS de l\'application
|
|
726
|
+
*/
|
|
727
|
+
async smsFindAllRaw(requestParameters, initOverrides) {
|
|
728
|
+
const requestOptions = await this.smsFindAllRequestOpts(requestParameters);
|
|
729
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
730
|
+
return new JSONApiResponse(response, (jsonValue) => jsonValue.map(ResponseSmsFromJSON));
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Récupérer l\'historique des SMS de l\'application
|
|
734
|
+
*/
|
|
735
|
+
async smsFindAll(requestParameters, initOverrides) {
|
|
736
|
+
const response = await this.smsFindAllRaw(requestParameters, initOverrides);
|
|
737
|
+
return await response.value();
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Creates request options for smsFindOne without sending the request
|
|
741
|
+
*/
|
|
742
|
+
async smsFindOneRequestOpts(requestParameters) {
|
|
743
|
+
if (requestParameters["xSecret"] == null) {
|
|
744
|
+
throw new RequiredError(
|
|
745
|
+
"xSecret",
|
|
746
|
+
'Required parameter "xSecret" was null or undefined when calling smsFindOne().'
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
if (requestParameters["id"] == null) {
|
|
750
|
+
throw new RequiredError(
|
|
751
|
+
"id",
|
|
752
|
+
'Required parameter "id" was null or undefined when calling smsFindOne().'
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
const queryParameters = {};
|
|
756
|
+
const headerParameters = {};
|
|
757
|
+
if (requestParameters["xSecret"] != null) {
|
|
758
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
759
|
+
}
|
|
760
|
+
let urlPath = `/api/sms/{id}`;
|
|
761
|
+
urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters["id"])));
|
|
762
|
+
return {
|
|
763
|
+
path: urlPath,
|
|
764
|
+
method: "GET",
|
|
765
|
+
headers: headerParameters,
|
|
766
|
+
query: queryParameters
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Récupérer un SMS par ID pour l\'application
|
|
771
|
+
*/
|
|
772
|
+
async smsFindOneRaw(requestParameters, initOverrides) {
|
|
773
|
+
const requestOptions = await this.smsFindOneRequestOpts(requestParameters);
|
|
774
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
775
|
+
return new JSONApiResponse(response, (jsonValue) => ResponseSmsFromJSON(jsonValue));
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Récupérer un SMS par ID pour l\'application
|
|
779
|
+
*/
|
|
780
|
+
async smsFindOne(requestParameters, initOverrides) {
|
|
781
|
+
const response = await this.smsFindOneRaw(requestParameters, initOverrides);
|
|
782
|
+
return await response.value();
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Creates request options for smsSendBulkSms without sending the request
|
|
786
|
+
*/
|
|
787
|
+
async smsSendBulkSmsRequestOpts(requestParameters) {
|
|
788
|
+
if (requestParameters["xSecret"] == null) {
|
|
789
|
+
throw new RequiredError(
|
|
790
|
+
"xSecret",
|
|
791
|
+
'Required parameter "xSecret" was null or undefined when calling smsSendBulkSms().'
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
if (requestParameters["bulkSms"] == null) {
|
|
795
|
+
throw new RequiredError(
|
|
796
|
+
"bulkSms",
|
|
797
|
+
'Required parameter "bulkSms" was null or undefined when calling smsSendBulkSms().'
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
const queryParameters = {};
|
|
801
|
+
const headerParameters = {};
|
|
802
|
+
headerParameters["Content-Type"] = "application/json";
|
|
803
|
+
if (requestParameters["xSecret"] != null) {
|
|
804
|
+
headerParameters["x-secret"] = String(requestParameters["xSecret"]);
|
|
805
|
+
}
|
|
806
|
+
let urlPath = `/api/sms/bulk`;
|
|
807
|
+
return {
|
|
808
|
+
path: urlPath,
|
|
809
|
+
method: "POST",
|
|
810
|
+
headers: headerParameters,
|
|
811
|
+
query: queryParameters,
|
|
812
|
+
body: BulkSmsToJSON(requestParameters["bulkSms"])
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Envoyer des messages différents à différents groupes de destinataires
|
|
817
|
+
*/
|
|
818
|
+
async smsSendBulkSmsRaw(requestParameters, initOverrides) {
|
|
819
|
+
const requestOptions = await this.smsSendBulkSmsRequestOpts(requestParameters);
|
|
820
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
821
|
+
return new JSONApiResponse(response, (jsonValue) => ResponseNotifTaskFromJSON(jsonValue));
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* Envoyer des messages différents à différents groupes de destinataires
|
|
825
|
+
*/
|
|
826
|
+
async smsSendBulkSms(requestParameters, initOverrides) {
|
|
827
|
+
const response = await this.smsSendBulkSmsRaw(requestParameters, initOverrides);
|
|
828
|
+
return await response.value();
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
|
|
128
832
|
// src/types/index.ts
|
|
129
833
|
var SmsStatus = /* @__PURE__ */ ((SmsStatus2) => {
|
|
130
834
|
SmsStatus2["SCHEDULED"] = "SCHEDULED";
|
|
@@ -147,61 +851,54 @@ var parseSchedule = (input) => {
|
|
|
147
851
|
}
|
|
148
852
|
return input;
|
|
149
853
|
};
|
|
150
|
-
var
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
...raw.task.scheduledAt != null && { scheduledAt: new Date(raw.task.scheduledAt) }
|
|
154
|
-
};
|
|
155
|
-
return {
|
|
156
|
-
task,
|
|
157
|
-
sms: Array.isArray(raw.sms) ? raw.sms.map(SmsDetailFromJSON) : [],
|
|
158
|
-
total: raw.total ?? 0
|
|
159
|
-
};
|
|
854
|
+
var normalizeTaskResponse = (json) => {
|
|
855
|
+
const t = json.task ?? json;
|
|
856
|
+
return { taskId: t._id ?? t.taskId, status: t.status, statusPage: t.statusPage, createdAt: t.createdAt, scheduledAt: t.scheduledAt, sms: json.sms ?? [] };
|
|
160
857
|
};
|
|
161
858
|
var instances = {};
|
|
162
859
|
var Task = class {
|
|
163
|
-
constructor(id,
|
|
860
|
+
constructor(id, api, secret) {
|
|
164
861
|
this.id = id;
|
|
165
|
-
this.
|
|
862
|
+
this._api = api;
|
|
863
|
+
this._secret = secret;
|
|
166
864
|
}
|
|
167
865
|
async status(count, page) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const details = `${count},${page || 1}`;
|
|
173
|
-
const res = await this._requester.get(`/api/notif-task/${this.id}?details=${details}`);
|
|
174
|
-
return parseTaskResponse(res);
|
|
866
|
+
const details = count !== void 0 ? `${count},${page || 1}` : "";
|
|
867
|
+
const raw = await this._api.notifTaskFindOneRaw({ xSecret: this._secret, id: this.id, details });
|
|
868
|
+
const json = await raw.raw.json();
|
|
869
|
+
return NotifTaskWithSmsFromJSON(normalizeTaskResponse(json));
|
|
175
870
|
}
|
|
176
871
|
// All SMS at once
|
|
177
872
|
async fullStatus() {
|
|
178
|
-
const
|
|
179
|
-
|
|
873
|
+
const raw = await this._api.notifTaskFindOneRaw({ xSecret: this._secret, id: this.id, details: "-1" });
|
|
874
|
+
const json = await raw.raw.json();
|
|
875
|
+
return NotifTaskWithSmsFromJSON(normalizeTaskResponse(json));
|
|
180
876
|
}
|
|
181
877
|
};
|
|
182
878
|
var _Ariari = class _Ariari {
|
|
183
|
-
constructor({ name = "main",
|
|
879
|
+
constructor({ name = "main", secret, baseUrl }) {
|
|
184
880
|
this.send = async (...args) => {
|
|
185
881
|
const hasSchedule = typeof args[0] === "string";
|
|
186
882
|
const scheduledAt = hasSchedule ? parseSchedule(args[0]) : void 0;
|
|
187
883
|
const data = hasSchedule ? args.slice(1) : args;
|
|
188
|
-
const
|
|
884
|
+
const bulkSms = {
|
|
189
885
|
messages: data.map((item) => ({
|
|
190
886
|
phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
|
|
191
887
|
message: item.message
|
|
192
888
|
})),
|
|
193
889
|
...scheduledAt && { scheduledAt }
|
|
194
890
|
};
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
return new Task(task.id, this._requester);
|
|
891
|
+
const task = await this._smsApi.smsSendBulkSms({ xSecret: this._secret, bulkSms });
|
|
892
|
+
return new Task(task.id, this._notifTaskApi, this._secret);
|
|
198
893
|
};
|
|
199
|
-
this.getTask = (taskId) => new Task(taskId, this.
|
|
894
|
+
this.getTask = (taskId) => new Task(taskId, this._notifTaskApi, this._secret);
|
|
200
895
|
this.estimate = async (...messages) => {
|
|
201
|
-
return this.
|
|
896
|
+
return this._smsApi.smsEstimate({ xSecret: this._secret, estimateSms: { messages } });
|
|
202
897
|
};
|
|
203
|
-
this.
|
|
204
|
-
|
|
898
|
+
this._secret = secret;
|
|
899
|
+
const configuration = new Configuration({ basePath: baseUrl || "https://api.ariari.mg" });
|
|
900
|
+
this._smsApi = new SmsApi(configuration);
|
|
901
|
+
this._notifTaskApi = new NotifTaskApi(configuration);
|
|
205
902
|
instances[name] = this;
|
|
206
903
|
}
|
|
207
904
|
};
|