@smsmode/rcs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +923 -0
- package/dist/index.cjs +416 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +577 -0
- package/dist/index.d.ts +577 -0
- package/dist/index.mjs +380 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +73 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
interface SmsmodeClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
/** @internal */
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
/** Timeout in milliseconds. @default 10000 */
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
9
|
+
interface RequestOptions {
|
|
10
|
+
method?: HttpMethod;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
13
|
+
}
|
|
14
|
+
interface PaginatedResponse<T> {
|
|
15
|
+
startDate?: string;
|
|
16
|
+
endDate?: string;
|
|
17
|
+
page: number;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
count: number;
|
|
20
|
+
totalCount: number;
|
|
21
|
+
links: {
|
|
22
|
+
first?: string;
|
|
23
|
+
last?: string;
|
|
24
|
+
previous?: string;
|
|
25
|
+
next?: string;
|
|
26
|
+
};
|
|
27
|
+
items: T[];
|
|
28
|
+
}
|
|
29
|
+
/** Route the request through a specific Channel and/or Campaign */
|
|
30
|
+
interface MessagePathOptions {
|
|
31
|
+
channelId?: string;
|
|
32
|
+
campaignId?: string;
|
|
33
|
+
}
|
|
34
|
+
interface CampaignPathOptions {
|
|
35
|
+
channelId?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Direction of a message. MT = Mobile Terminated (sent), MO = Mobile Originator (received). */
|
|
38
|
+
type RcsDirection = 'MT' | 'MO';
|
|
39
|
+
/** Message status — final or temporary. See doc "Message Status Values". */
|
|
40
|
+
type RcsStatusValue = 'SCHEDULED' | 'ENROUTE' | 'DELIVERED' | 'READ' | 'UNDELIVERABLE' | 'UNDELIVERED';
|
|
41
|
+
/** Detailed status information. See doc "Status Detail Values". */
|
|
42
|
+
type RcsStatusDetail = 'IN_PROGRESS' | 'DELIVERED_TO_NETWORK' | 'INSUFFICIENT_CREDIT' | 'DAILY_LIMIT_EXCEEDED' | 'ORGANISATION_MONTHLY_LIMIT_EXCEEDED' | 'ROUTE_NOT_AVAILABLE' | 'SPAM' | 'INVALID_PHONE_NUMBER' | 'BLACKLISTED' | 'PHONE_NOT_SUITABLE' | 'NETWORK_NOT_SUITABLE' | 'MEDIA_INVALID' | 'EXPIRED' | 'CANCELLED' | 'INTERNAL_ERROR';
|
|
43
|
+
/** Body content kind. See doc "Body type values". */
|
|
44
|
+
type RcsBodyType = 'BASIC' | 'TEXT' | 'CARD' | 'CAROUSEL' | 'FILE';
|
|
45
|
+
/** Suggested action kind. See doc "Body Suggestions type values". */
|
|
46
|
+
type RcsSuggestionType = 'REPLY' | 'OPEN_URL' | 'DIAL_PHONE' | 'SHOW_LOCATION' | 'REQUEST_LOCATION' | 'CREATE_CALENDAR_EVENT';
|
|
47
|
+
/** Webview display size for OPEN_URL suggestions. */
|
|
48
|
+
type RcsWebviewSize = 'NONE' | 'HALF' | 'TALL' | 'FULL';
|
|
49
|
+
/** Card media height — only applicable when orientation is VERTICAL. */
|
|
50
|
+
type RcsMediaHeight = 'SHORT' | 'MEDIUM' | 'TALL';
|
|
51
|
+
/** Card orientation. */
|
|
52
|
+
type RcsCardOrientation = 'VERTICAL' | 'HORIZONTAL';
|
|
53
|
+
/** Card alignment. */
|
|
54
|
+
type RcsCardAlignment = 'LEFT' | 'RIGHT';
|
|
55
|
+
/** Carousel card width. */
|
|
56
|
+
type RcsCardWidth = 'SMALL' | 'MEDIUM';
|
|
57
|
+
interface RcsPrice {
|
|
58
|
+
amount: number;
|
|
59
|
+
currency: string;
|
|
60
|
+
}
|
|
61
|
+
interface RcsValidity {
|
|
62
|
+
/** Duration value (integer). Min 30 SECONDS, max 48 HOURS (default). */
|
|
63
|
+
amount: number;
|
|
64
|
+
/** Unit of time. Defaults to MINUTES when omitted. */
|
|
65
|
+
timeUnit: 'SECONDS' | 'MINUTES' | 'HOURS';
|
|
66
|
+
}
|
|
67
|
+
interface RcsStatus {
|
|
68
|
+
value: RcsStatusValue;
|
|
69
|
+
detail?: RcsStatusDetail;
|
|
70
|
+
/** ISO 8601 date-time. */
|
|
71
|
+
deliveryDate?: string;
|
|
72
|
+
/** Network lookup data. Structure not yet documented. */
|
|
73
|
+
lookup?: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
interface RcsRecipient {
|
|
76
|
+
to: string;
|
|
77
|
+
/** Per-recipient dynamic variables for campaigns. Keys are used as `$key` in body.text. */
|
|
78
|
+
parameters?: Record<string, string>;
|
|
79
|
+
/** Per-recipient reference tag for campaigns. 3-140 chars. */
|
|
80
|
+
refClient?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Channel details embedded in a Message. */
|
|
83
|
+
interface RcsChannel {
|
|
84
|
+
channelId: string;
|
|
85
|
+
name?: string;
|
|
86
|
+
type: 'RCS';
|
|
87
|
+
flow?: 'TRANSACTIONAL' | 'MARKETING' | 'OTP';
|
|
88
|
+
}
|
|
89
|
+
/** Base fields shared by all suggestion types. */
|
|
90
|
+
interface RcsSuggestionBase {
|
|
91
|
+
type: RcsSuggestionType;
|
|
92
|
+
/** Text displayed in the suggestion. Max 25 chars. */
|
|
93
|
+
text: string;
|
|
94
|
+
/** Base64-encoded payload returned to the agent on tap. Max 2048 chars. */
|
|
95
|
+
postbackData: string;
|
|
96
|
+
}
|
|
97
|
+
/** Suggested quick reply — no extra fields. */
|
|
98
|
+
interface RcsReplySuggestion extends RcsSuggestionBase {
|
|
99
|
+
type: 'REPLY';
|
|
100
|
+
}
|
|
101
|
+
/** Suggested URL opening. */
|
|
102
|
+
interface RcsOpenUrlSuggestion extends RcsSuggestionBase {
|
|
103
|
+
type: 'OPEN_URL';
|
|
104
|
+
/** URL to open. Max 255 chars. */
|
|
105
|
+
url: string;
|
|
106
|
+
/** Webview display size. @default "NONE" */
|
|
107
|
+
webviewSize?: RcsWebviewSize;
|
|
108
|
+
}
|
|
109
|
+
/** Suggested phone call. */
|
|
110
|
+
interface RcsDialPhoneSuggestion extends RcsSuggestionBase {
|
|
111
|
+
type: 'DIAL_PHONE';
|
|
112
|
+
/** Phone number in E.164 format. */
|
|
113
|
+
phoneNumber: string;
|
|
114
|
+
}
|
|
115
|
+
/** Suggested location display. */
|
|
116
|
+
interface RcsShowLocationSuggestion extends RcsSuggestionBase {
|
|
117
|
+
type: 'SHOW_LOCATION';
|
|
118
|
+
/** Latitude. -90 to 90. */
|
|
119
|
+
latitude: number;
|
|
120
|
+
/** Longitude. -180 to 180. */
|
|
121
|
+
longitude: number;
|
|
122
|
+
/** Location label. Max 100 chars. */
|
|
123
|
+
label?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Suggested location request — no extra fields. */
|
|
126
|
+
interface RcsRequestLocationSuggestion extends RcsSuggestionBase {
|
|
127
|
+
type: 'REQUEST_LOCATION';
|
|
128
|
+
}
|
|
129
|
+
/** Suggested calendar event creation. */
|
|
130
|
+
interface RcsCreateCalendarEventSuggestion extends RcsSuggestionBase {
|
|
131
|
+
type: 'CREATE_CALENDAR_EVENT';
|
|
132
|
+
/** ISO 8601 date-time — event start. */
|
|
133
|
+
startTime: string;
|
|
134
|
+
/** ISO 8601 date-time — event end. */
|
|
135
|
+
endTime: string;
|
|
136
|
+
/** Event title. Max 100 chars. */
|
|
137
|
+
title: string;
|
|
138
|
+
/** Event description. Max 500 chars. */
|
|
139
|
+
description?: string;
|
|
140
|
+
}
|
|
141
|
+
/** Discriminated union of all RCS suggestion types. */
|
|
142
|
+
type RcsSuggestion = RcsReplySuggestion | RcsOpenUrlSuggestion | RcsDialPhoneSuggestion | RcsShowLocationSuggestion | RcsRequestLocationSuggestion | RcsCreateCalendarEventSuggestion;
|
|
143
|
+
/** Media content inside a Card or Carousel item. */
|
|
144
|
+
interface RcsCardMedia {
|
|
145
|
+
/** URL of the media to display. Max 255 chars. */
|
|
146
|
+
fileUrl: string;
|
|
147
|
+
/** Thumbnail URL — only when fileUrl is a video. */
|
|
148
|
+
thumbnailUrl?: string;
|
|
149
|
+
/** Media height. @default "MEDIUM". Only applicable when orientation is VERTICAL. */
|
|
150
|
+
height?: RcsMediaHeight;
|
|
151
|
+
}
|
|
152
|
+
/** Card content — shared between CARD `content` and CAROUSEL `contents[]` items. */
|
|
153
|
+
interface RcsCardContent {
|
|
154
|
+
/** Card title. Max 200 chars. */
|
|
155
|
+
title?: string;
|
|
156
|
+
/** Card description. Max 2000 chars. */
|
|
157
|
+
description?: string;
|
|
158
|
+
/** Card media (image or video). */
|
|
159
|
+
media?: RcsCardMedia;
|
|
160
|
+
/** Suggestions inside the card. Max 4 items. */
|
|
161
|
+
suggestions?: RcsSuggestion[];
|
|
162
|
+
}
|
|
163
|
+
/** BASIC body — plain text, no suggestions. Max 160 chars. */
|
|
164
|
+
interface RcsBasicBody {
|
|
165
|
+
type: 'BASIC';
|
|
166
|
+
/** Plain text message. Max 160 chars. */
|
|
167
|
+
text: string;
|
|
168
|
+
}
|
|
169
|
+
/** TEXT body — rich text with optional suggestions. Max 3072 chars. */
|
|
170
|
+
interface RcsTextBody {
|
|
171
|
+
type: 'TEXT';
|
|
172
|
+
/** Text message content. Max 3072 chars. */
|
|
173
|
+
text: string;
|
|
174
|
+
/** Suggestions list. Max 11 items. */
|
|
175
|
+
suggestions?: RcsSuggestion[];
|
|
176
|
+
}
|
|
177
|
+
/** FILE body — media file with optional suggestions. */
|
|
178
|
+
interface RcsFileBody {
|
|
179
|
+
type: 'FILE';
|
|
180
|
+
/** URL of the media. Max 255 chars. Supported: images, videos, audio, PDF. */
|
|
181
|
+
fileUrl: string;
|
|
182
|
+
/** Thumbnail URL — only when fileUrl is a video. */
|
|
183
|
+
thumbnailUrl?: string;
|
|
184
|
+
/** Suggestions list. Max 11 items. */
|
|
185
|
+
suggestions?: RcsSuggestion[];
|
|
186
|
+
}
|
|
187
|
+
/** CARD body — rich card with content, orientation, alignment and suggestions. */
|
|
188
|
+
interface RcsCardBody {
|
|
189
|
+
type: 'CARD';
|
|
190
|
+
/** Card content. Must contain at least `media` or `title`. */
|
|
191
|
+
content: RcsCardContent;
|
|
192
|
+
/** Card orientation. @default "VERTICAL" */
|
|
193
|
+
orientation?: RcsCardOrientation;
|
|
194
|
+
/** Card alignment. @default "LEFT" */
|
|
195
|
+
alignment?: RcsCardAlignment;
|
|
196
|
+
/** Suggestions below the card. Max 11 items. */
|
|
197
|
+
suggestions?: RcsSuggestion[];
|
|
198
|
+
}
|
|
199
|
+
/** CAROUSEL body — 2 to 11 cards with optional suggestions. */
|
|
200
|
+
interface RcsCarouselBody {
|
|
201
|
+
type: 'CAROUSEL';
|
|
202
|
+
/** Carousel cards. Min 2, max 11 items. */
|
|
203
|
+
contents: RcsCardContent[];
|
|
204
|
+
/** Card width. @default "MEDIUM" */
|
|
205
|
+
cardWidth?: RcsCardWidth;
|
|
206
|
+
/** Suggestions below the carousel. Max 11 items. */
|
|
207
|
+
suggestions?: RcsSuggestion[];
|
|
208
|
+
}
|
|
209
|
+
/** Discriminated union of all RCS body types. */
|
|
210
|
+
type RcsBody = RcsBasicBody | RcsTextBody | RcsFileBody | RcsCardBody | RcsCarouselBody;
|
|
211
|
+
/** RCS Message resource as returned by the API. */
|
|
212
|
+
interface RcsMessage {
|
|
213
|
+
messageId: string;
|
|
214
|
+
/** Present only for MO (Mobile Originator) messages. */
|
|
215
|
+
originMessageId?: string;
|
|
216
|
+
/** ISO 8601 date-time when the message was accepted by smsmode. */
|
|
217
|
+
acceptedAt: string;
|
|
218
|
+
/** ISO 8601 date-time when the message has been or will be sent. */
|
|
219
|
+
sentDate: string;
|
|
220
|
+
channel: RcsChannel;
|
|
221
|
+
type: 'RCS';
|
|
222
|
+
direction: RcsDirection;
|
|
223
|
+
recipient: RcsRecipient;
|
|
224
|
+
/** RCS agent used for sending. 1-40 chars. Default "Default RCS Agent". */
|
|
225
|
+
from: string;
|
|
226
|
+
body: RcsBody;
|
|
227
|
+
price: RcsPrice;
|
|
228
|
+
status: RcsStatus;
|
|
229
|
+
validity: RcsValidity;
|
|
230
|
+
/** Client reference tag. 3-140 chars. */
|
|
231
|
+
refClient?: string;
|
|
232
|
+
/** DLR callback URL. Max 255 chars. */
|
|
233
|
+
callbackUrlStatus?: string;
|
|
234
|
+
/** MO callback URL. Max 255 chars. */
|
|
235
|
+
callbackUrlMo?: string;
|
|
236
|
+
/** Link to message details operation. */
|
|
237
|
+
href: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Corps de requête pour l'envoi d'un message RCS unitaire.
|
|
241
|
+
* Pour un envoi en batch, utiliser un tableau `RcsSendPayload[]` (max 1000).
|
|
242
|
+
*/
|
|
243
|
+
interface RcsSendPayload {
|
|
244
|
+
recipient: RcsRecipient;
|
|
245
|
+
body: RcsBody;
|
|
246
|
+
/** RCS agent used for sending. 1-40 chars. @default "Default RCS Agent" */
|
|
247
|
+
from?: string;
|
|
248
|
+
/**
|
|
249
|
+
* ISO 8601 date-time. Future date <= 1 year.
|
|
250
|
+
* Si sentDate < 5 min dans le futur, envoi immédiat. @default now
|
|
251
|
+
*/
|
|
252
|
+
sentDate?: string;
|
|
253
|
+
/** Message validity period. Min 30 SECONDS, max 48 HOURS (default). */
|
|
254
|
+
validity?: RcsValidity;
|
|
255
|
+
/** Client reference tag. 3-140 chars. */
|
|
256
|
+
refClient?: string;
|
|
257
|
+
/** DLR callback URL. Max 255 chars. */
|
|
258
|
+
callbackUrlStatus?: string;
|
|
259
|
+
/** MO callback URL. Max 255 chars. */
|
|
260
|
+
callbackUrlMo?: string;
|
|
261
|
+
}
|
|
262
|
+
/** Batch send payload — up to 1000 messages per request. */
|
|
263
|
+
type RcsBatchSendPayload = RcsSendPayload[];
|
|
264
|
+
/** Sort order for paginated lists. */
|
|
265
|
+
type RcsSortOrder = 'ASC' | 'DESC';
|
|
266
|
+
/** Filter fields for GET /messages. Serialized as `searchBy[<key>]`. */
|
|
267
|
+
interface RcsMessageSearchBy {
|
|
268
|
+
/** Filter: MT (sent) or MO (incoming). @default MT */
|
|
269
|
+
direction?: RcsDirection;
|
|
270
|
+
/** Filter by client reference tag. 3-140 chars. */
|
|
271
|
+
refClient?: string;
|
|
272
|
+
/** Filter by recipient phone number (E.164). */
|
|
273
|
+
to?: string;
|
|
274
|
+
/** Filter by origin message UUID. Must be combined with `direction=MO`. */
|
|
275
|
+
originMessageId?: string;
|
|
276
|
+
}
|
|
277
|
+
/** Sort fields for GET /messages. Serialized as `sortBy[<key>]`. */
|
|
278
|
+
interface RcsMessageSortBy {
|
|
279
|
+
sentDate?: RcsSortOrder;
|
|
280
|
+
refClient?: RcsSortOrder;
|
|
281
|
+
}
|
|
282
|
+
/** Query parameters for GET /messages. */
|
|
283
|
+
interface RcsListParams {
|
|
284
|
+
/** ISO 8601. @default 10 days earlier than now */
|
|
285
|
+
startDate?: string;
|
|
286
|
+
/** ISO 8601. @default now */
|
|
287
|
+
endDate?: string;
|
|
288
|
+
/** Page number, min 1. @default 1 */
|
|
289
|
+
page?: number;
|
|
290
|
+
/** Page size, 1-100. @default 10 */
|
|
291
|
+
pageSize?: number;
|
|
292
|
+
searchBy?: RcsMessageSearchBy;
|
|
293
|
+
sortBy?: RcsMessageSortBy;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Corps de requête pour la modification d'un message RCS programmé.
|
|
297
|
+
* Tous les champs sont optionnels. Une valeur vide (`""`) permet de retirer
|
|
298
|
+
* un paramètre optionnel (ex: `refClient: ""`).
|
|
299
|
+
* Impossible d'éditer dans les 5 minutes précédant l'envoi ("preloaded" state).
|
|
300
|
+
*/
|
|
301
|
+
interface RcsUpdatePayload {
|
|
302
|
+
recipient?: RcsRecipient;
|
|
303
|
+
/** ISO 8601. Future date entre 5 minutes et 1 an. */
|
|
304
|
+
sentDate?: string;
|
|
305
|
+
/** Client reference tag. 3-140 chars. `""` pour retirer. */
|
|
306
|
+
refClient?: string;
|
|
307
|
+
/** DLR callback URL. Max 255 chars. `""` pour retirer. */
|
|
308
|
+
callbackUrlStatus?: string;
|
|
309
|
+
/** MO callback URL. Max 255 chars. `""` pour retirer. */
|
|
310
|
+
callbackUrlMo?: string;
|
|
311
|
+
}
|
|
312
|
+
/** Campaign state. See doc "Campaign Status Values". */
|
|
313
|
+
type RcsCampaignStatus = 'SCHEDULED' | 'ONGOING' | 'ENDED' | 'CANCELED';
|
|
314
|
+
/** Aggregated delivery status entry inside a Campaign response. */
|
|
315
|
+
interface RcsCampaignStatusEntry {
|
|
316
|
+
/** ISO 8601 date-time when the delivery report was received. */
|
|
317
|
+
deliveryDate?: string;
|
|
318
|
+
value: RcsStatusValue;
|
|
319
|
+
detail?: RcsStatusDetail;
|
|
320
|
+
/** Number of messages for this status. */
|
|
321
|
+
quantity: number;
|
|
322
|
+
}
|
|
323
|
+
/** RCS Campaign resource as returned by the API. */
|
|
324
|
+
interface RcsCampaign {
|
|
325
|
+
campaignId: string;
|
|
326
|
+
/** Max 100 chars. */
|
|
327
|
+
name?: string;
|
|
328
|
+
/** ISO 8601 date-time when the campaign was accepted by smsmode. */
|
|
329
|
+
acceptedAt: string;
|
|
330
|
+
/** ISO 8601 date-time when the campaign has been or will be sent. */
|
|
331
|
+
sentDate: string;
|
|
332
|
+
/** ISO 8601 date-time when the campaign will finish. */
|
|
333
|
+
endDate: string;
|
|
334
|
+
channel: RcsChannel;
|
|
335
|
+
type: 'RCS';
|
|
336
|
+
/** Recipient list. Max 1000. */
|
|
337
|
+
recipients: RcsRecipient[];
|
|
338
|
+
/** RCS agent used for sending. 1-40 chars. Default "Default RCS Agent". */
|
|
339
|
+
from: string;
|
|
340
|
+
body: RcsBody;
|
|
341
|
+
/** Total of Messages sent. */
|
|
342
|
+
quantity: number;
|
|
343
|
+
price: RcsPrice;
|
|
344
|
+
status: RcsCampaignStatus;
|
|
345
|
+
statuses: RcsCampaignStatusEntry[];
|
|
346
|
+
/** Client reference tag. 3-140 chars. */
|
|
347
|
+
refClient?: string;
|
|
348
|
+
/** DLR callback URL. Max 255 chars. */
|
|
349
|
+
callbackUrlStatus?: string;
|
|
350
|
+
/** MO callback URL. Max 255 chars. */
|
|
351
|
+
callbackUrlMo?: string;
|
|
352
|
+
/** Link to campaign details operation. */
|
|
353
|
+
href: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Corps de requête pour l'envoi/programmation d'une campagne RCS.
|
|
357
|
+
* Limité à 1000 destinataires. Pour plus, utiliser POST /campaigns/{id}/messages.
|
|
358
|
+
*/
|
|
359
|
+
interface RcsCampaignSendPayload {
|
|
360
|
+
/** Campaign name. Max 100 chars. */
|
|
361
|
+
name: string;
|
|
362
|
+
/** Recipient list. Max 1000. */
|
|
363
|
+
recipients: RcsRecipient[];
|
|
364
|
+
body: RcsBody;
|
|
365
|
+
/** RCS agent used for sending. 1-40 chars. @default "Default RCS Agent" */
|
|
366
|
+
from?: string;
|
|
367
|
+
/**
|
|
368
|
+
* ISO 8601 date-time. Future, <= 1 year, au moins +30 minutes vs now.
|
|
369
|
+
* @default now
|
|
370
|
+
*/
|
|
371
|
+
sentDate?: string;
|
|
372
|
+
/** Client reference tag. 3-140 chars. */
|
|
373
|
+
refClient?: string;
|
|
374
|
+
/** DLR callback URL. Max 255 chars. */
|
|
375
|
+
callbackUrlStatus?: string;
|
|
376
|
+
/** MO callback URL. Max 255 chars. */
|
|
377
|
+
callbackUrlMo?: string;
|
|
378
|
+
}
|
|
379
|
+
/** Filter fields for GET /campaigns. Serialized as `searchBy[<key>]`. */
|
|
380
|
+
interface RcsCampaignSearchBy {
|
|
381
|
+
/** Filter by campaign status. @default ONGOING */
|
|
382
|
+
status?: RcsCampaignStatus;
|
|
383
|
+
/** Filter by client reference tag. 3-140 chars. */
|
|
384
|
+
refClient?: string;
|
|
385
|
+
}
|
|
386
|
+
/** Sort fields for GET /campaigns. Serialized as `sortBy[<key>]`. */
|
|
387
|
+
interface RcsCampaignSortBy {
|
|
388
|
+
sentDate?: RcsSortOrder;
|
|
389
|
+
refClient?: RcsSortOrder;
|
|
390
|
+
}
|
|
391
|
+
/** Query parameters for GET /campaigns. */
|
|
392
|
+
interface RcsCampaignListParams {
|
|
393
|
+
/** ISO 8601. @default 10 days earlier than today */
|
|
394
|
+
startDate?: string;
|
|
395
|
+
/** ISO 8601. @default today */
|
|
396
|
+
endDate?: string;
|
|
397
|
+
/** Page number, min 1. @default 1 */
|
|
398
|
+
page?: number;
|
|
399
|
+
/** Page size, 1-100. @default 10 */
|
|
400
|
+
pageSize?: number;
|
|
401
|
+
searchBy?: RcsCampaignSearchBy;
|
|
402
|
+
sortBy?: RcsCampaignSortBy;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Corps de requête pour la modification d'une campagne RCS programmée.
|
|
406
|
+
* Les champs sont appliqués à tous les messages unitaires de la campagne.
|
|
407
|
+
* Une valeur vide (`""`) permet de retirer un paramètre optionnel (ex: `refClient: ""`),
|
|
408
|
+
* sauf pour `name` (non vidable) et pour `callbackUrlStatus` / `callbackUrlMo` lorsqu'ils
|
|
409
|
+
* ont une valeur par défaut configurée au niveau du Channel.
|
|
410
|
+
*/
|
|
411
|
+
interface RcsCampaignUpdatePayload {
|
|
412
|
+
/** Campaign name. Max 100 chars. Non vidable. */
|
|
413
|
+
name?: string;
|
|
414
|
+
/**
|
|
415
|
+
* ISO 8601 date-time. Future, <= 1 year, au moins +30 minutes vs now.
|
|
416
|
+
*/
|
|
417
|
+
sentDate?: string;
|
|
418
|
+
/** Client reference tag. 3-140 chars. `""` pour retirer. */
|
|
419
|
+
refClient?: string;
|
|
420
|
+
/** DLR callback URL. Max 255 chars. */
|
|
421
|
+
callbackUrlStatus?: string;
|
|
422
|
+
/** MO callback URL. Max 255 chars. */
|
|
423
|
+
callbackUrlMo?: string;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Delivery Report (DLR) webhook payload — reçu sur l'URL configurée via
|
|
427
|
+
* `callbackUrlStatus` (dynamique dans la requête ou défini au niveau du Channel).
|
|
428
|
+
* Schéma identique à {@link RcsMessage} (source : section "Receive Status reports
|
|
429
|
+
* Webhook" de la doc officielle smsmode RCS).
|
|
430
|
+
*/
|
|
431
|
+
type RcsDeliveryReportPayload = RcsMessage;
|
|
432
|
+
/**
|
|
433
|
+
* Incoming Message (MO) webhook payload — reçu sur l'URL configurée via
|
|
434
|
+
* `callbackUrlMo` (dynamique dans la requête ou défini au niveau du Channel).
|
|
435
|
+
* Schéma issu de la section "Receive RCS MO message Webhook" de la doc officielle.
|
|
436
|
+
*
|
|
437
|
+
* Sous-ensemble du modèle Message : pas de `acceptedAt`, `price`, `status`,
|
|
438
|
+
* `validity`, `callbackUrl*`. Le `body` est systématiquement de type TEXT.
|
|
439
|
+
*/
|
|
440
|
+
interface RcsIncomingMessagePayload {
|
|
441
|
+
messageId: string;
|
|
442
|
+
/** UUID du message d'origine (MT) auquel ce MO répond — toujours présent pour un MO. */
|
|
443
|
+
originMessageId: string;
|
|
444
|
+
/** ISO 8601 date-time when the message was received. */
|
|
445
|
+
sentDate: string;
|
|
446
|
+
channel: RcsChannel;
|
|
447
|
+
type: 'RCS';
|
|
448
|
+
direction: 'MO';
|
|
449
|
+
recipient: RcsRecipient;
|
|
450
|
+
/** RCS agent. 1-40 chars. Default "Default RCS Agent". */
|
|
451
|
+
from: string;
|
|
452
|
+
body: RcsTextBody;
|
|
453
|
+
/** Client reference tag. 3-140 chars. */
|
|
454
|
+
refClient?: string;
|
|
455
|
+
/** Link to message details operation. */
|
|
456
|
+
href: string;
|
|
457
|
+
}
|
|
458
|
+
/** Union discriminable par `direction` (MT = DLR, MO = incoming message). */
|
|
459
|
+
type RcsWebhookPayload = RcsDeliveryReportPayload | RcsIncomingMessagePayload;
|
|
460
|
+
|
|
461
|
+
declare class BaseClient {
|
|
462
|
+
private readonly apiKey;
|
|
463
|
+
private readonly baseUrl;
|
|
464
|
+
private readonly timeout;
|
|
465
|
+
constructor(options: SmsmodeClientOptions);
|
|
466
|
+
private encodeParams;
|
|
467
|
+
private buildUrl;
|
|
468
|
+
private handleErrorResponse;
|
|
469
|
+
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
470
|
+
get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
471
|
+
post<T>(path: string, body?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
472
|
+
patch<T>(path: string, body?: unknown, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
473
|
+
delete<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Campaigns resource — grouped RCS sends (max 1000 recipients per campaign)
|
|
478
|
+
* and campaign statistics. Accessed via `client.campaigns` on {@link SmsmodeRcsClient}.
|
|
479
|
+
*/
|
|
480
|
+
declare class CampaignsResource {
|
|
481
|
+
private readonly client;
|
|
482
|
+
constructor(client: BaseClient);
|
|
483
|
+
private buildBasePath;
|
|
484
|
+
private buildCampaignPath;
|
|
485
|
+
private flattenListParams;
|
|
486
|
+
/** Send or schedule a campaign (max 1000 recipients) */
|
|
487
|
+
send(payload: RcsCampaignSendPayload, options?: CampaignPathOptions): Promise<RcsCampaign>;
|
|
488
|
+
/** List campaigns with optional filters and pagination */
|
|
489
|
+
list(params?: RcsCampaignListParams, options?: CampaignPathOptions): Promise<PaginatedResponse<RcsCampaign>>;
|
|
490
|
+
/** Get a campaign by ID */
|
|
491
|
+
get(campaignId: string, options?: CampaignPathOptions): Promise<RcsCampaign>;
|
|
492
|
+
/** Update a scheduled campaign before it is sent */
|
|
493
|
+
update(campaignId: string, payload: RcsCampaignUpdatePayload, options?: CampaignPathOptions): Promise<RcsCampaign>;
|
|
494
|
+
/** Cancel a scheduled campaign before it is sent */
|
|
495
|
+
cancel(campaignId: string, options?: CampaignPathOptions): Promise<void>;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Main entry point of the `@smsmode/rcs`.
|
|
500
|
+
*
|
|
501
|
+
* Exposes RCS message methods directly on the instance, and namespaces the
|
|
502
|
+
* Campaign resource under `.campaigns`.
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```ts
|
|
506
|
+
* const client = new SmsmodeRcsClient({ apiKey: 'your-api-key' });
|
|
507
|
+
* await client.send({ recipient: { to: '33612345678' }, body: { type: 'TEXT' } });
|
|
508
|
+
* await client.campaigns.list();
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
declare class SmsmodeRcsClient {
|
|
512
|
+
private readonly messages;
|
|
513
|
+
readonly campaigns: CampaignsResource;
|
|
514
|
+
constructor(options: SmsmodeClientOptions);
|
|
515
|
+
/** Send a single RCS message or a batch (max 1000) */
|
|
516
|
+
send(payload: RcsSendPayload, options?: MessagePathOptions): Promise<RcsMessage>;
|
|
517
|
+
send(payload: RcsBatchSendPayload, options?: MessagePathOptions): Promise<RcsMessage[]>;
|
|
518
|
+
/** List messages with optional filters and pagination */
|
|
519
|
+
list(params?: RcsListParams, options?: MessagePathOptions): Promise<PaginatedResponse<RcsMessage>>;
|
|
520
|
+
/** Get a message by ID */
|
|
521
|
+
get(messageId: string, options?: MessagePathOptions): Promise<RcsMessage>;
|
|
522
|
+
/** Update a scheduled message before it is sent */
|
|
523
|
+
update(messageId: string, payload: RcsUpdatePayload, options?: MessagePathOptions): Promise<RcsMessage>;
|
|
524
|
+
/** Cancel a scheduled message before it is sent */
|
|
525
|
+
cancel(messageId: string, options?: MessagePathOptions): Promise<void>;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** Base class for all SDK errors — enables a unified `instanceof RcsError` check. */
|
|
529
|
+
declare class RcsError extends Error {
|
|
530
|
+
constructor(message: string);
|
|
531
|
+
}
|
|
532
|
+
/** Thrown when the response contains a structured smsmode error body. All fields are guaranteed. */
|
|
533
|
+
declare class SmsModeApiError extends RcsError {
|
|
534
|
+
readonly httpStatus: number;
|
|
535
|
+
readonly title: string;
|
|
536
|
+
readonly detail: string;
|
|
537
|
+
readonly errorCode: string;
|
|
538
|
+
readonly docsUrl: string;
|
|
539
|
+
readonly details: unknown;
|
|
540
|
+
constructor(httpStatus: number, body: Record<string, unknown>);
|
|
541
|
+
toString(): string;
|
|
542
|
+
}
|
|
543
|
+
/** Thrown when no structured smsmode body is present (5xx, proxy errors, empty bodies). */
|
|
544
|
+
declare class SmsModeHttpError extends RcsError {
|
|
545
|
+
readonly httpStatus: number;
|
|
546
|
+
readonly statusText: string;
|
|
547
|
+
constructor(httpStatus: number, statusText: string);
|
|
548
|
+
toString(): string;
|
|
549
|
+
}
|
|
550
|
+
/** Thrown on HTTP 401 — invalid or missing API key. */
|
|
551
|
+
declare class AuthError extends SmsModeApiError {
|
|
552
|
+
constructor(httpStatus: number, body: Record<string, unknown>);
|
|
553
|
+
}
|
|
554
|
+
/** Thrown on HTTP 429 — rate limit exceeded. Check retryAfter for delay in seconds. */
|
|
555
|
+
declare class RateLimitError extends SmsModeApiError {
|
|
556
|
+
readonly retryAfter?: number | undefined;
|
|
557
|
+
constructor(httpStatus: number, body: Record<string, unknown>, retryAfter?: number | undefined);
|
|
558
|
+
}
|
|
559
|
+
/** Thrown when a webhook payload fails local structural validation (not an HTTP error). */
|
|
560
|
+
declare class ValidationError extends RcsError {
|
|
561
|
+
constructor(message: string);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Parse a raw webhook body (object or JSON string) into a typed RCS webhook payload.
|
|
566
|
+
* Performs a minimal structural check — downstream code should rely on the
|
|
567
|
+
* discriminated union (`direction`) via `isDeliveryReport` / `isIncomingMessage`.
|
|
568
|
+
*
|
|
569
|
+
* @throws {ValidationError} if the body is not a valid RCS webhook payload.
|
|
570
|
+
*/
|
|
571
|
+
declare function parseWebhookPayload(body: unknown): RcsWebhookPayload;
|
|
572
|
+
/** Type guard — true when the payload is a Delivery Report (MT). */
|
|
573
|
+
declare function isDeliveryReport(payload: RcsWebhookPayload): payload is RcsDeliveryReportPayload;
|
|
574
|
+
/** Type guard — true when the payload is an Incoming Message (MO). */
|
|
575
|
+
declare function isIncomingMessage(payload: RcsWebhookPayload): payload is RcsIncomingMessagePayload;
|
|
576
|
+
|
|
577
|
+
export { AuthError, type CampaignPathOptions, type MessagePathOptions, type PaginatedResponse, RateLimitError, type RcsBasicBody, type RcsBatchSendPayload, type RcsBody, type RcsBodyType, type RcsCampaign, type RcsCampaignListParams, type RcsCampaignSendPayload, type RcsCampaignStatus, type RcsCampaignUpdatePayload, type RcsCardAlignment, type RcsCardBody, type RcsCardContent, type RcsCardMedia, type RcsCardOrientation, type RcsCardWidth, type RcsCarouselBody, type RcsChannel, type RcsCreateCalendarEventSuggestion, type RcsDeliveryReportPayload, type RcsDialPhoneSuggestion, type RcsDirection, RcsError, type RcsFileBody, type RcsIncomingMessagePayload, type RcsListParams, type RcsMediaHeight, type RcsMessage, type RcsOpenUrlSuggestion, type RcsPrice, type RcsRecipient, type RcsReplySuggestion, type RcsRequestLocationSuggestion, type RcsSendPayload, type RcsShowLocationSuggestion, type RcsSortOrder, type RcsStatus, type RcsStatusDetail, type RcsStatusValue, type RcsSuggestion, type RcsSuggestionBase, type RcsSuggestionType, type RcsTextBody, type RcsUpdatePayload, type RcsValidity, type RcsWebhookPayload, type RcsWebviewSize, SmsModeApiError, SmsModeHttpError, type SmsmodeClientOptions, SmsmodeRcsClient, ValidationError, isDeliveryReport, isIncomingMessage, parseWebhookPayload };
|