-
Notifications
You must be signed in to change notification settings - Fork 44
/
conversations.d.ts
417 lines (369 loc) · 11.7 KB
/
conversations.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
import { datetime } from './general';
import { Contact } from './contact';
export type hsmLanguages =
| 'af'
| 'sq'
| 'ar'
| 'az'
| 'bn'
| 'bg'
| 'ca'
| 'zh_CN'
| 'zh_HK'
| 'zh_TW'
| 'hr'
| 'cs'
| 'da'
| 'nl'
| 'en'
| 'en_GB'
| 'es_LA'
| 'et'
| 'fil'
| 'fi'
| 'fr'
| 'de'
| 'el'
| 'gu'
| 'he'
| 'hi'
| 'hu'
| 'id'
| 'ga'
| 'it'
| 'ja'
| 'kn'
| 'kk'
| 'ko'
| 'lo'
| 'lv'
| 'lt'
| 'mk'
| 'ms'
| 'mr'
| 'nb'
| 'fa'
| 'pl'
| 'pt_BR'
| 'pt_PT'
| 'pa'
| 'ro'
| 'ru'
| 'sr'
| 'sk'
| 'sl'
| 'es'
| 'es_AR'
| 'es_ES'
| 'es_MX'
| 'sw'
| 'sv'
| 'ta'
| 'te'
| 'th'
| 'tr'
| 'uk'
| 'ur'
| 'uz'
| 'vi';
export interface StartConversationParameter {
/** The type of the message content. */
type: string;
/** Content of the message to send. The value of type defines the required fields. */
content: Content;
/** An channel-specific identifier for the receiver. For example: a mobile phone number (MSISDN) is valid for SMS or Whatsapp channels. */
to?: string;
/** The unique ID that identifies the channel over which the message should be sent. */
channelId?: string;
}
export type ChannelStatus = 'inactive' | 'active' | 'pending' | 'activation_required' | 'activation_code_required' | 'activating' | 'deleted';
export interface Channel {
/** The unique ID generated by the MessageBird platform that identifies this channel. */
id: string;
/** The name of this channel (configured through the MessageBird Dashboard). */
name: string;
/** A unique identifier for the platform that is used by this channel, for example: sms, Whatsapp or messenger. */
platformId: string;
/**
* The status of this channel. Only active channels can be used for messaging.
* Can be one of inactive, active, pending, activation_required, activation_code_required, activating, and deleted.
*/
status: ChannelStatus;
/** The date-time the channel was created, in RFC 3339 format (e.g. 2020-05-01T13:34:14Z). */
createdDatetime: datetime;
/** The date-time the channel was updated, in RFC 3339 format (e.g. 2020-05-01T13:34:14Z). */
updatedDatetime: datetime;
}
export interface StartConversationResponse {
/** The unique ID generated by the MessageBird platform that identifies this conversation. */
id: string;
/** The unique ID generated by the MessageBird platform that identifies the contact. */
contactId: string;
/** Contact details. */
contact: Contact;
/** Channels used in this conversation. */
channels: Channel[];
/**
* The status of this conversation. Only active conversations can be used for messaging.
* Can be one of active, archived.
*/
status: 'active' | 'archived';
/** The date-time the conversation was created, in RFC 3339 format (e.g. 2020-05-01T13:34:14Z). */
createdDatetime: datetime;
/** The date-time the conversation was updated, in RFC 3339 format (e.g. 2020-05-01T13:34:14Z). */
updatedDatetime: datetime;
/** The date-time the last message was received, in RFC 3339 format (e.g. 2020-05-01T13:34:14Z). */
lastReceivedDatetime: datetime;
/** Id of the channel that was used last in this conversation. */
lastUsedChannelId: string;
/** Information about messages in this conversation. */
messages: {
/** Total count of the messages in the conversation. */
totalCount: number;
/** URL to fetch messages in the conversation. */
href: string;
/** Id of the last message from the conversation. */
lastMessageId: string;
};
}
export interface ConversationParameter {
/** Either a channel-specific identifier for the receiver (e.g. MSISDN for SMS or WhatsApp channels), or the ID of a MessageBird Contact. */
to: string;
/** The ID that identifies the channel over which the message should be sent. */
from: string;
/** The type of the message content. */
type: string;
/** Content of the message. The value of type defines the required fields. */
content: Content;
/** The URL for delivery of status reports for the message. Must be HTTPS. */
reportUrl: string;
}
export type Content =
| TextContent
| ImageContent
| AudioContent
| VideoContent
| FileContent
| EmailContent
| LocationContent
| HSMContent;
export interface TextContent {
/** Required for type text. The plain-text content of the message. */
text: string;
}
export interface ImageContent {
/** Required for type image. An object of the form {"url": "<media url>"} containing the url of the remote media file. */
image: Media;
}
export interface VideoContent {
/** Required for type video. An object of the form {"url": "<media url>"} containing the url of the remote media file. */
video: Media;
}
export interface AudioContent {
/** Required for type video. An object of the form {"url": "<media url>"} containing the url of the remote media file. */
audio: Media;
}
export interface FileContent {
/** Required for type file. An object of the form {"url": "<media url>"} containing the url of the remote media file. */
file: Media;
}
export interface Media {
url: string;
caption?: string;
}
export interface EmailContent {
/** Required for type email. An object containing details of the email message. */
email: EmailContentContent;
}
export interface EmailContentContent {
/** A unique random ID for this message on the MessageBird platform, returned upon acceptance of the message. */
id?: string;
to: EmailRecipient[];
from: { name?: string; address: string; };
subject: string;
content: {
/** HTML content of the message, expected in UTF-8. */
html?: string;
/** Plain text of the message, expected in UTF-8. */
text?: string
};
/** Email address used to compose the email’s “Reply-To” header. */
replyTo?: string;
/** Email address used to compose the email’s “Return-Path” header. Must match your sending domain. */
returnPath?: string;
/** Object containing custom headers other than Subject, From, To, and Reply-To. These will be sent along with your message. */
headers?: Record<string, string>;
/** Allows you to set tracking options. */
tracking?: {
open?: boolean;
click?: boolean;
};
/** The URL for delivery of status reports for the message. Must use https. */
reportUrl?: string;
/** Perform substitutions of variables inside the content or headers of your email (Default: true). */
performSubstitutions?: boolean;
/** List of files attached to a message. */
attachments?: EmailAttachment;
/** List of inline images added to the message content. */
inlineImages?: EmailInlineImage;
}
export interface EmailAttachment {
id?: string;
name?: string;
type?: string;
URL: string;
length?: number;
}
export interface EmailInlineImage extends EmailAttachment {
contentId?: string;
}
export interface EmailRecipient {
/** Required. Valid email address */
email: string;
/** Name attached to the email address, this appears in the To field in a users email client */
name?: string;
/** List of variables used for placeholders inside the content or headers of your email */
variables?: Record<string, string>;
}
export interface LocationContent {
/** Latitude and longitude are expected as floats. */
location: {
latitude: number;
longitude: number;
};
}
export interface HSMContent {
/** Required for type hsm. Available only for WhatsApp. */
hsm: HSMContentContent | HSMComponentContent;
}
export interface HSMContentContent {
/** WhatsApp namespace for your account. You will receive this value when setting up your WhatsApp account. */
namespace: string;
/** The name of the template. */
templateName: string;
language: HSMLanguage;
params: HSMLocalizableParameters[];
}
export interface HSMComponentContent {
/** WhatsApp namespace for your account. You will receive this value when setting up your WhatsApp account. */
namespace: string;
/** The name of the template. */
templateName: string;
language: HSMLanguage;
components: HSMComponent[];
}
export interface HSMComponent {
type: 'header' | 'body';
parameters: HSMComponentParameter[];
}
export type HSMComponentParameter = HSMComponentTextParameter | HSMComponentCurrencyParameter | HSMComponentDateTimeParameter | HSMComponentDocumentParameter |
HSMComponentImageParameter | HSMComponentVideoParameter | HSMComponentPayloadParameter;
export interface HSMComponentTextParameter {
type: 'text';
text: string;
}
export interface HSMComponentCurrencyParameter {
type: 'currency';
currency: {
/**
* ISO 4217 currency code
*/
currencyCode: string,
/**
* Total amount together with cents as a float, multiplied by 1000
*/
amount: number
};
}
export interface HSMComponentDateTimeParameter {
type: 'date_time';
/**
* RFC3339 representation of the date and time
*/
dateTime: string;
}
export interface HSMComponentDocumentParameter {
type: 'document';
document: Media;
}
export interface HSMComponentImageParameter {
type: 'image';
image: Media;
}
export interface HSMComponentVideoParameter {
type: 'video';
video: Media;
}
export interface HSMComponentPayloadParameter {
type: 'payload';
payload: string;
}
export interface HSMLanguage {
/**
* Deterministic will deliver the message template in exactly the language and locale asked for while fallback will deliver the message template in user's device language,
* if the settings can't be found on users device the fallback language is used.
*/
policy: 'fallback' | 'deterministic';
/** The code of the language or locale to use, accepts both language and language_locale formats (e.g., en or en_US). */
code: hsmLanguages;
}
export type HSMLocalizableParameters =
| HSMLocalizableParametersCurrency
| HSMLocalizableParametersDateTime;
export interface HSMLocalizableParametersCurrency {
/**
* Default value of the parameter, it is used when localization fails. The only field needed when specifying parameter value that doesn't require localization.
*/
default: string;
currency?: {
/** string of ISO 4217 currency code */
currencyCode: string;
/** integer of total amount together with cents as a float, multipled by 1000 */
amount: number;
};
}
export interface HSMLocalizableParametersDateTime {
/**
* Default value of the parameter, it is used when localization fails. The only field needed when specifying parameter value that doesn't require localization.
*/
default: string;
/**
* RFC3339 representation of the date and time.
*/
dateTime?: datetime;
}
export interface SendResponse {
message: SendResponseMessage;
}
export interface SendResponseMessage {
/** A unique ID generated by the MessageBird platform that identifies this message. */
id: string;
/** The status of the message. It will be initially set to accepted. */
status: string | 'accepted';
}
export interface UpdateConversationParameters {
/** The new status of the conversation */
status: 'active' | 'archived';
}
export interface ReplyConversationParameters {
/** The unique ID that identifies the conversation */
id: string;
}
export namespace Webhooks {
interface CreateParameters {
/** A list of event name strings from the list of available events that should trigger this webhook. */
events: string[];
/** The unique identifier for a MessageBird channel that this webhook will subcribe to events for. */
channelId: string;
/** The endpoint URL that requests should be sent to. */
url: string;
}
interface UpdateParameters {
/** A list of event name strings from the list of available events that should trigger this webhook. */
events: string[];
/** The endpoint URL that requests should be sent to. */
url: string;
/** Status of the webhook */
status: 'enabled' | 'disabled';
}
}