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