@opens/gateways 1.2.0 → 1.4.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 +376 -8
- package/dist/index.d.ts +376 -8
- package/dist/index.js +134 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,38 @@ interface WorkGroupResponse {
|
|
|
62
62
|
/** Response returned by the Customer Service API when fetching members of a work group. */
|
|
63
63
|
type WorkGroupMembersResponse = WorkGroupMember[];
|
|
64
64
|
|
|
65
|
+
interface User {
|
|
66
|
+
id: string;
|
|
67
|
+
username: string;
|
|
68
|
+
email: string;
|
|
69
|
+
profile: 'p_admin' | 'p_manager' | 'p_corporative' | 'p_agent';
|
|
70
|
+
status: 'new' | 'activated' | 'disabled';
|
|
71
|
+
avatar: string | null;
|
|
72
|
+
type: string;
|
|
73
|
+
companyId: string;
|
|
74
|
+
createdAt: string;
|
|
75
|
+
updatedAt: string;
|
|
76
|
+
}
|
|
77
|
+
interface GetAllUsersParams {
|
|
78
|
+
status?: string;
|
|
79
|
+
includeWorkGroups?: boolean;
|
|
80
|
+
withoutOpensUsers?: boolean;
|
|
81
|
+
}
|
|
82
|
+
interface GetAllUsersResponse {
|
|
83
|
+
users: User[];
|
|
84
|
+
}
|
|
85
|
+
interface ManagedUser {
|
|
86
|
+
id: string;
|
|
87
|
+
username: string;
|
|
88
|
+
email: string;
|
|
89
|
+
profile: string;
|
|
90
|
+
status: string;
|
|
91
|
+
companyId: string;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
updatedAt: string;
|
|
94
|
+
}
|
|
95
|
+
type GetManagedUsersResponse = ManagedUser[];
|
|
96
|
+
|
|
65
97
|
/**
|
|
66
98
|
* Gateway for interacting with the Customer Service API.
|
|
67
99
|
*/
|
|
@@ -96,6 +128,8 @@ declare class CustomerServiceGateway {
|
|
|
96
128
|
* @returns The members of the work group.
|
|
97
129
|
*/
|
|
98
130
|
getWorkGroupMembers(groupId: string, companyId?: string, profile?: string[]): Promise<WorkGroupMembersResponse>;
|
|
131
|
+
getAllUsers(params?: GetAllUsersParams): Promise<GetAllUsersResponse>;
|
|
132
|
+
getManagedUsers(managerId: string): Promise<GetManagedUsersResponse>;
|
|
99
133
|
}
|
|
100
134
|
|
|
101
135
|
/** A provider entity returned by the Chat Config API. */
|
|
@@ -199,6 +233,104 @@ interface Queue {
|
|
|
199
233
|
members: QueueMember[];
|
|
200
234
|
distributionType: DistributionType;
|
|
201
235
|
}
|
|
236
|
+
/** Response returned when listing queues. */
|
|
237
|
+
interface QueueListResponse {
|
|
238
|
+
queues: Queue[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Representation of a button in a Meta template. */
|
|
242
|
+
interface MetaTemplateButton {
|
|
243
|
+
/** Unique identifier of the button. */
|
|
244
|
+
id: string;
|
|
245
|
+
/** Type of the button (e.g. 'URL', 'PHONE_NUMBER', 'QUICK_REPLY'). */
|
|
246
|
+
type: string;
|
|
247
|
+
/** Text displayed on the button. */
|
|
248
|
+
text: string;
|
|
249
|
+
/** Value of the button (e.g. URL or phone number). */
|
|
250
|
+
value?: string | null;
|
|
251
|
+
/** Dynamic variable of the button. */
|
|
252
|
+
variable?: string | null;
|
|
253
|
+
/** ID of the template configuration to which the button belongs. */
|
|
254
|
+
templateConfigId: string;
|
|
255
|
+
/** Creation date of the record. */
|
|
256
|
+
createdAt?: string;
|
|
257
|
+
/** Update date of the record. */
|
|
258
|
+
updatedAt?: string;
|
|
259
|
+
}
|
|
260
|
+
/** Detailed configuration of a Meta template. */
|
|
261
|
+
interface MetaTemplateConfigResponse {
|
|
262
|
+
/** Unique identifier of the template configuration. */
|
|
263
|
+
id: string;
|
|
264
|
+
/** Name of the template in Meta. */
|
|
265
|
+
name: string;
|
|
266
|
+
/** Identifier of the template in Meta. */
|
|
267
|
+
templateId: string;
|
|
268
|
+
/** Company identifier in Meta. */
|
|
269
|
+
companyId: string;
|
|
270
|
+
/** Format of the template (e.g. TEXT, IMAGE, VIDEO). */
|
|
271
|
+
format?: string | null;
|
|
272
|
+
/** Content of the template header. */
|
|
273
|
+
headerContent?: string | null;
|
|
274
|
+
/** Defines if the header has dynamic content (parameters). */
|
|
275
|
+
isDynamicHeader: boolean;
|
|
276
|
+
/** Type of the header (e.g. TEXT, IMAGE, DOCUMENT, VIDEO). */
|
|
277
|
+
headerType?: string | null;
|
|
278
|
+
/** Content of the template body. */
|
|
279
|
+
bodyContent?: string | null;
|
|
280
|
+
/** Type of the body (e.g. TEXT). */
|
|
281
|
+
bodyType?: string | null;
|
|
282
|
+
/** Content of the template footer. */
|
|
283
|
+
footerContent?: string | null;
|
|
284
|
+
/** Type of the footer (e.g. TEXT). */
|
|
285
|
+
footerType?: string | null;
|
|
286
|
+
/** ID of the configuration associated with the template. */
|
|
287
|
+
configId?: string | null;
|
|
288
|
+
/** ID of the provider associated with the template. */
|
|
289
|
+
providerId?: string | null;
|
|
290
|
+
/** Creation date of the record. */
|
|
291
|
+
createdAt?: string;
|
|
292
|
+
/** Update date of the record. */
|
|
293
|
+
updatedAt?: string;
|
|
294
|
+
/** List of buttons in the template. */
|
|
295
|
+
buttons?: MetaTemplateButton[];
|
|
296
|
+
}
|
|
297
|
+
/** Response containing the list of template configurations associated with a configuration. */
|
|
298
|
+
interface MetaTemplateConfigsResponse {
|
|
299
|
+
/** List of Meta template configurations. */
|
|
300
|
+
templatesConfig: MetaTemplateConfigResponse[];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Request payload for finding or creating a queue rule. */
|
|
304
|
+
interface FindOrCreateQueueRuleRequest {
|
|
305
|
+
companyId: string;
|
|
306
|
+
queueId: string;
|
|
307
|
+
configId: string;
|
|
308
|
+
}
|
|
309
|
+
/** Response returned when finding or creating a queue rule. */
|
|
310
|
+
interface QueueRule {
|
|
311
|
+
id: string;
|
|
312
|
+
companyId: string;
|
|
313
|
+
name: string;
|
|
314
|
+
action: string;
|
|
315
|
+
message?: string;
|
|
316
|
+
automaticMessage?: Record<string, unknown>;
|
|
317
|
+
callOnQueue?: Record<string, unknown>;
|
|
318
|
+
uraDescription: string;
|
|
319
|
+
interactiveMessageId: string | null;
|
|
320
|
+
configId?: string;
|
|
321
|
+
queueId?: string;
|
|
322
|
+
redirectQueue: Record<string, unknown> | null;
|
|
323
|
+
redirectRuleId?: string;
|
|
324
|
+
questionnaire?: Record<string, unknown>;
|
|
325
|
+
webhook?: Record<string, unknown>;
|
|
326
|
+
isRoot: boolean;
|
|
327
|
+
redirectDefault: boolean;
|
|
328
|
+
redirectTimeout?: number;
|
|
329
|
+
delay?: number;
|
|
330
|
+
createdAt: string;
|
|
331
|
+
updatedAt: string;
|
|
332
|
+
flow?: Record<string, unknown>[];
|
|
333
|
+
}
|
|
202
334
|
|
|
203
335
|
/**
|
|
204
336
|
* Gateway for interacting with the Chat Config API.
|
|
@@ -225,9 +357,25 @@ declare class ChatConfigGateway {
|
|
|
225
357
|
* @returns The queue data.
|
|
226
358
|
*/
|
|
227
359
|
getQueueById(queueId: string): Promise<Queue>;
|
|
228
|
-
getQueues(
|
|
229
|
-
|
|
230
|
-
|
|
360
|
+
getQueues(): Promise<Queue[]>;
|
|
361
|
+
/**
|
|
362
|
+
* Retrieves a Meta template configuration by its ID.
|
|
363
|
+
* @param templateId - The unique identifier of the template.
|
|
364
|
+
* @returns The Meta template configuration.
|
|
365
|
+
*/
|
|
366
|
+
getMetaTemplateById(templateId: string): Promise<MetaTemplateConfigResponse>;
|
|
367
|
+
/**
|
|
368
|
+
* Retrieves template configurations associated with a configuration ID.
|
|
369
|
+
* @param configId - The configuration identifier.
|
|
370
|
+
* @returns The list of template configurations.
|
|
371
|
+
*/
|
|
372
|
+
getTemplateConfigsByConfigId(configId: string): Promise<MetaTemplateConfigsResponse>;
|
|
373
|
+
/**
|
|
374
|
+
* Finds an existing queue rule or creates a new one if it does not exist.
|
|
375
|
+
* @param payload - The payload containing companyId, queueId, and configId.
|
|
376
|
+
* @returns The found or created queue rule.
|
|
377
|
+
*/
|
|
378
|
+
findOrCreateQueueRule(payload: FindOrCreateQueueRuleRequest): Promise<QueueRule>;
|
|
231
379
|
}
|
|
232
380
|
|
|
233
381
|
/** Campaign status literals. */
|
|
@@ -338,14 +486,117 @@ interface CampaignQueryParams {
|
|
|
338
486
|
createdBy?: string;
|
|
339
487
|
assignedTo?: string;
|
|
340
488
|
name?: string;
|
|
341
|
-
limit?: number;
|
|
342
|
-
skip?: number;
|
|
489
|
+
$limit?: number;
|
|
490
|
+
$skip?: number;
|
|
343
491
|
}
|
|
344
|
-
|
|
492
|
+
/** User entity returned by the Campaigns API. */
|
|
493
|
+
interface CampaignUser {
|
|
345
494
|
id: string;
|
|
346
495
|
name: string;
|
|
496
|
+
status: 'new' | 'activated' | 'disabled';
|
|
347
497
|
}
|
|
348
498
|
|
|
499
|
+
/** Dispatch status literals for a campaign contact. */
|
|
500
|
+
type CampaignContactDispatchStatus = 'scheduled' | 'queued' | 'delivered' | 'converted' | 'failed';
|
|
501
|
+
/** Campaign status literals accepted by campaign contact queries. */
|
|
502
|
+
type CampaignContactCampaignStatus = 'ongoing' | 'finished';
|
|
503
|
+
/** Primitive values accepted by REST query filters. */
|
|
504
|
+
type CampaignContactQueryValue = string | number | boolean;
|
|
505
|
+
/** Sort direction accepted by REST query parameters. */
|
|
506
|
+
type CampaignContactSortDirection = 1 | -1;
|
|
507
|
+
/** Query operators accepted by REST query filters. */
|
|
508
|
+
type CampaignContactQueryOperators<T extends CampaignContactQueryValue> = {
|
|
509
|
+
$eq?: T;
|
|
510
|
+
$ne?: T;
|
|
511
|
+
$in?: T[];
|
|
512
|
+
$nin?: T[];
|
|
513
|
+
$lt?: T;
|
|
514
|
+
$lte?: T;
|
|
515
|
+
$gt?: T;
|
|
516
|
+
$gte?: T;
|
|
517
|
+
};
|
|
518
|
+
/** Case-insensitive LIKE operator accepted by contact name and endpoint filters. */
|
|
519
|
+
type CampaignContactLikeQueryOperators = {
|
|
520
|
+
$ilike?: string;
|
|
521
|
+
};
|
|
522
|
+
/** Campaign contact entity returned by the Campaign Contacts API. */
|
|
523
|
+
interface CampaignContactResponse {
|
|
524
|
+
id: string;
|
|
525
|
+
contactId: string;
|
|
526
|
+
campaignId: string;
|
|
527
|
+
createdAt: string;
|
|
528
|
+
updatedAt: string;
|
|
529
|
+
contactEndpointId?: string;
|
|
530
|
+
dispatchStatusMessage: string;
|
|
531
|
+
contactName?: string;
|
|
532
|
+
contactEndpoint?: string;
|
|
533
|
+
metadata?: unknown;
|
|
534
|
+
communicationChannelId: string;
|
|
535
|
+
dispatchStatus: CampaignContactDispatchStatus;
|
|
536
|
+
isMessageRead?: boolean;
|
|
537
|
+
}
|
|
538
|
+
/** Paginated response returned by the Campaign Contacts API for list endpoints. */
|
|
539
|
+
type CampaignContactPaginatedResponse = {
|
|
540
|
+
total: number;
|
|
541
|
+
limit: number;
|
|
542
|
+
skip: number;
|
|
543
|
+
data: CampaignContactResponse[];
|
|
544
|
+
};
|
|
545
|
+
/** Request payload for creating a campaign contact. */
|
|
546
|
+
type CreateCampaignContactRequest = {
|
|
547
|
+
contactId: string;
|
|
548
|
+
campaignId: string;
|
|
549
|
+
contactEndpointId?: string;
|
|
550
|
+
contactName?: string;
|
|
551
|
+
contactEndpoint?: string;
|
|
552
|
+
metadata?: unknown;
|
|
553
|
+
};
|
|
554
|
+
/** Request payload for partially updating a campaign contact. */
|
|
555
|
+
type PatchCampaignContactRequest = {
|
|
556
|
+
id?: string;
|
|
557
|
+
contactId?: string;
|
|
558
|
+
campaignId?: string;
|
|
559
|
+
createdAt?: string;
|
|
560
|
+
updatedAt?: string;
|
|
561
|
+
contactEndpointId?: string;
|
|
562
|
+
dispatchStatusMessage?: string;
|
|
563
|
+
contactName?: string;
|
|
564
|
+
contactEndpoint?: string;
|
|
565
|
+
metadata?: unknown;
|
|
566
|
+
communicationChannelId?: string;
|
|
567
|
+
dispatchStatus?: CampaignContactDispatchStatus;
|
|
568
|
+
isMessageRead?: boolean;
|
|
569
|
+
};
|
|
570
|
+
/** Sort fields accepted when listing campaign contacts. */
|
|
571
|
+
type CampaignContactSortParams = {
|
|
572
|
+
contactId?: CampaignContactSortDirection;
|
|
573
|
+
createdAt?: CampaignContactSortDirection;
|
|
574
|
+
updatedAt?: CampaignContactSortDirection;
|
|
575
|
+
campaignId?: CampaignContactSortDirection;
|
|
576
|
+
dispatchStatus?: CampaignContactSortDirection;
|
|
577
|
+
contactName?: CampaignContactSortDirection;
|
|
578
|
+
contactEndpoint?: CampaignContactSortDirection;
|
|
579
|
+
contactEndpointId?: CampaignContactSortDirection;
|
|
580
|
+
communicationChannelId?: CampaignContactSortDirection;
|
|
581
|
+
};
|
|
582
|
+
/** Query parameters for listing campaign contacts. */
|
|
583
|
+
type CampaignContactQueryParams = {
|
|
584
|
+
contactId?: string | CampaignContactQueryOperators<string>;
|
|
585
|
+
createdAt?: string | CampaignContactQueryOperators<string>;
|
|
586
|
+
updatedAt?: string | CampaignContactQueryOperators<string>;
|
|
587
|
+
campaignId?: string | CampaignContactQueryOperators<string>;
|
|
588
|
+
dispatchStatus?: CampaignContactDispatchStatus | CampaignContactQueryOperators<CampaignContactDispatchStatus>;
|
|
589
|
+
contactName?: string | CampaignContactQueryOperators<string> | CampaignContactLikeQueryOperators;
|
|
590
|
+
contactEndpoint?: string | CampaignContactQueryOperators<string> | CampaignContactLikeQueryOperators;
|
|
591
|
+
contactEndpointId?: string | CampaignContactQueryOperators<string>;
|
|
592
|
+
communicationChannelId?: string | CampaignContactQueryOperators<string>;
|
|
593
|
+
'campaign.status'?: CampaignContactCampaignStatus | CampaignContactQueryOperators<CampaignContactCampaignStatus>;
|
|
594
|
+
$limit?: number;
|
|
595
|
+
$skip?: number;
|
|
596
|
+
$sort?: CampaignContactSortParams;
|
|
597
|
+
$select?: (keyof CampaignContactResponse)[];
|
|
598
|
+
};
|
|
599
|
+
|
|
349
600
|
/**
|
|
350
601
|
* Gateway for interacting with the Campaigns API.
|
|
351
602
|
*/
|
|
@@ -384,7 +635,120 @@ declare class CampaignsGateway {
|
|
|
384
635
|
* @returns The removed campaign.
|
|
385
636
|
*/
|
|
386
637
|
remove(id: string): Promise<Campaign>;
|
|
387
|
-
|
|
638
|
+
/**
|
|
639
|
+
* Retrieves a paginated list of campaign contacts.
|
|
640
|
+
* @param query - Optional query parameters for filtering and pagination.
|
|
641
|
+
* @returns The paginated campaign contacts response.
|
|
642
|
+
*/
|
|
643
|
+
findCampaignContacts(query?: CampaignContactQueryParams): Promise<CampaignContactPaginatedResponse>;
|
|
644
|
+
/**
|
|
645
|
+
* Retrieves a campaign contact by its unique identifier.
|
|
646
|
+
* @param id - The unique identifier of the campaign contact.
|
|
647
|
+
* @returns The campaign contact data.
|
|
648
|
+
*/
|
|
649
|
+
getCampaignContacts(id: string): Promise<CampaignContactResponse>;
|
|
650
|
+
/**
|
|
651
|
+
* Creates a new campaign contact.
|
|
652
|
+
* @param payload - The campaign contact data to create.
|
|
653
|
+
* @returns The created campaign contact.
|
|
654
|
+
*/
|
|
655
|
+
createCampaignContact(payload: CreateCampaignContactRequest): Promise<CampaignContactResponse>;
|
|
656
|
+
/**
|
|
657
|
+
* Partially updates an existing campaign contact.
|
|
658
|
+
* @param id - The unique identifier of the campaign contact.
|
|
659
|
+
* @param payload - The fields to update.
|
|
660
|
+
* @returns The updated campaign contact.
|
|
661
|
+
*/
|
|
662
|
+
patchCampaignContact(id: string, payload: PatchCampaignContactRequest): Promise<CampaignContactResponse>;
|
|
663
|
+
/**
|
|
664
|
+
* Removes a campaign contact by its unique identifier.
|
|
665
|
+
* @param id - The unique identifier of the campaign contact.
|
|
666
|
+
* @returns The removed campaign contact.
|
|
667
|
+
*/
|
|
668
|
+
removeCampaignContact(id: string): Promise<CampaignContactResponse>;
|
|
669
|
+
getUsers(): Promise<CampaignUser[]>;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/** Parameters for retrieving configuration templates. */
|
|
673
|
+
interface GetConfigTemplatesParams {
|
|
674
|
+
/** Optional template name filter. */
|
|
675
|
+
templateName?: string;
|
|
676
|
+
/** Optional maximum number of templates to return. */
|
|
677
|
+
limit?: number;
|
|
678
|
+
/** Optional status filter (e.g. 'APPROVED', 'REJECTED', 'PENDING'). */
|
|
679
|
+
status?: string;
|
|
680
|
+
/** Optional category filter (e.g. 'UTILITY', 'MARKETING', 'AUTHENTICATION'). */
|
|
681
|
+
category?: string;
|
|
682
|
+
/** Optional pagination cursor token/URL. */
|
|
683
|
+
next?: string;
|
|
684
|
+
/** Optional pagination cursor 'after' parameter. */
|
|
685
|
+
after?: string;
|
|
686
|
+
}
|
|
687
|
+
/** Component of a message template. */
|
|
688
|
+
interface MessageTemplateComponent {
|
|
689
|
+
/** Type of the component (e.g. 'HEADER', 'BODY', 'FOOTER', 'BUTTONS'). */
|
|
690
|
+
type: string;
|
|
691
|
+
/** Format of the component (e.g. 'TEXT', 'IMAGE', 'DOCUMENT', 'VIDEO'). */
|
|
692
|
+
format?: string;
|
|
693
|
+
/** Text content of the component. */
|
|
694
|
+
text?: string;
|
|
695
|
+
/** List of buttons in the component if type is 'BUTTONS'. */
|
|
696
|
+
buttons?: Array<{
|
|
697
|
+
type: string;
|
|
698
|
+
text: string;
|
|
699
|
+
url?: string;
|
|
700
|
+
phoneNumber?: string;
|
|
701
|
+
}>;
|
|
702
|
+
}
|
|
703
|
+
/** Details of a message template. */
|
|
704
|
+
interface MessageTemplate {
|
|
705
|
+
/** Name of the message template. */
|
|
706
|
+
name: string;
|
|
707
|
+
/** Status of the template (e.g. 'APPROVED', 'REJECTED', 'PENDING'). */
|
|
708
|
+
status: string;
|
|
709
|
+
/** Category of the template (e.g. 'UTILITY', 'MARKETING', 'AUTHENTICATION'). */
|
|
710
|
+
category: string;
|
|
711
|
+
/** Language locale of the template (e.g. 'pt_BR', 'en_US'). */
|
|
712
|
+
language: string;
|
|
713
|
+
/** Components that build up the template content. */
|
|
714
|
+
components: MessageTemplateComponent[];
|
|
715
|
+
/** Unique identifier of the template. */
|
|
716
|
+
id: string;
|
|
717
|
+
}
|
|
718
|
+
/** Pagination information for the template query response. */
|
|
719
|
+
interface ConfigTemplatesPaging {
|
|
720
|
+
/** Cursors used to paginate results. */
|
|
721
|
+
cursors?: {
|
|
722
|
+
/** Cursor pointing to the start of the current range. */
|
|
723
|
+
before?: string;
|
|
724
|
+
/** Cursor pointing to the end of the current range. */
|
|
725
|
+
after?: string;
|
|
726
|
+
};
|
|
727
|
+
/** URL for the next page of results. */
|
|
728
|
+
next?: string;
|
|
729
|
+
}
|
|
730
|
+
/** Response containing the list of message templates configured. */
|
|
731
|
+
interface GetConfigTemplatesResponse {
|
|
732
|
+
/** List of message templates. */
|
|
733
|
+
data: MessageTemplate[];
|
|
734
|
+
/** Pagination information. */
|
|
735
|
+
paging?: ConfigTemplatesPaging;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Gateway for interacting with the Chat Adapter API.
|
|
740
|
+
*/
|
|
741
|
+
declare class ChatAdapterGateway {
|
|
742
|
+
private readonly httpClient;
|
|
743
|
+
private readonly baseUrl;
|
|
744
|
+
constructor(httpClient: AxiosInstance, baseUrl: string);
|
|
745
|
+
/**
|
|
746
|
+
* Retrieves message templates associated with a configuration.
|
|
747
|
+
* @param configId - The unique identifier of the configuration.
|
|
748
|
+
* @param params - Optional query parameters for filtering and pagination.
|
|
749
|
+
* @returns A promise that resolves to the template list response.
|
|
750
|
+
*/
|
|
751
|
+
getConfigTemplates(configId: string, params?: GetConfigTemplatesParams): Promise<GetConfigTemplatesResponse>;
|
|
388
752
|
}
|
|
389
753
|
|
|
390
754
|
/**
|
|
@@ -399,6 +763,7 @@ type GatewayMap = {
|
|
|
399
763
|
'customer-service': CustomerServiceGateway;
|
|
400
764
|
'chat-config': ChatConfigGateway;
|
|
401
765
|
'campaigns': CampaignsGateway;
|
|
766
|
+
'chat-adapter': ChatAdapterGateway;
|
|
402
767
|
};
|
|
403
768
|
/**
|
|
404
769
|
* Parameters required to configure the SDK client.
|
|
@@ -420,6 +785,9 @@ interface GatewayClientParams {
|
|
|
420
785
|
campaigns?: {
|
|
421
786
|
baseUrl: string;
|
|
422
787
|
};
|
|
788
|
+
chatAdapter?: {
|
|
789
|
+
baseUrl: string;
|
|
790
|
+
};
|
|
423
791
|
};
|
|
424
792
|
}
|
|
425
793
|
|
|
@@ -446,4 +814,4 @@ declare const configure: (params: GatewayClientParams) => void;
|
|
|
446
814
|
*/
|
|
447
815
|
declare function gateway<T extends keyof GatewayMap>(service: T): GatewayMap[T];
|
|
448
816
|
|
|
449
|
-
export { type Campaign, type CampaignContactFilter, type CampaignPaginatedResponse, type CampaignProvider, type CampaignQueryParams, type CampaignSchedule, type CampaignStatus, type CompanyData, type CompanyResponse, type Config, type ConfigListByProviderResponse, type ConfigProvider, type CreateCampaignRequest, type DistributionType, type GetConfigsByProviderParams, type PatchCampaignRequest, type Provider, type ProviderListResponse, type Queue, type QueueMember, type User, type WhatsAppPayload, type WhatsAppTemplateComponent, type WorkGroup, type WorkGroupListResponse, type WorkGroupMember, type WorkGroupMembersResponse, type WorkGroupResponse, configure, gateway };
|
|
817
|
+
export { type Campaign, type CampaignContactCampaignStatus, type CampaignContactDispatchStatus, type CampaignContactFilter, type CampaignContactLikeQueryOperators, type CampaignContactPaginatedResponse, type CampaignContactQueryOperators, type CampaignContactQueryParams, type CampaignContactQueryValue, type CampaignContactResponse, type CampaignContactSortDirection, type CampaignContactSortParams, type CampaignPaginatedResponse, type CampaignProvider, type CampaignQueryParams, type CampaignSchedule, type CampaignStatus, type CampaignUser, type CompanyData, type CompanyResponse, type Config, type ConfigListByProviderResponse, type ConfigProvider, type ConfigTemplatesPaging, type CreateCampaignContactRequest, type CreateCampaignRequest, type DistributionType, type FindOrCreateQueueRuleRequest, type GetAllUsersParams, type GetAllUsersResponse, type GetConfigTemplatesParams, type GetConfigTemplatesResponse, type GetConfigsByProviderParams, type GetManagedUsersResponse, type ManagedUser, type MessageTemplate, type MessageTemplateComponent, type MetaTemplateButton, type MetaTemplateConfigResponse, type MetaTemplateConfigsResponse, type PatchCampaignContactRequest, type PatchCampaignRequest, type Provider, type ProviderListResponse, type Queue, type QueueListResponse, type QueueMember, type QueueRule, type User, type WhatsAppPayload, type WhatsAppTemplateComponent, type WorkGroup, type WorkGroupListResponse, type WorkGroupMember, type WorkGroupMembersResponse, type WorkGroupResponse, configure, gateway };
|
package/dist/index.js
CHANGED
|
@@ -85,6 +85,19 @@ var CustomerServiceGateway = class {
|
|
|
85
85
|
);
|
|
86
86
|
return data;
|
|
87
87
|
}
|
|
88
|
+
async getAllUsers(params) {
|
|
89
|
+
const { data } = await this.httpClient.get(
|
|
90
|
+
`${this.baseUrl}/companies/users`,
|
|
91
|
+
{ params }
|
|
92
|
+
);
|
|
93
|
+
return data;
|
|
94
|
+
}
|
|
95
|
+
async getManagedUsers(managerId) {
|
|
96
|
+
const { data } = await this.httpClient.get(
|
|
97
|
+
`${this.baseUrl}/users/managed/${managerId}`
|
|
98
|
+
);
|
|
99
|
+
return data;
|
|
100
|
+
}
|
|
88
101
|
};
|
|
89
102
|
|
|
90
103
|
// src/chat-config/index.ts
|
|
@@ -125,8 +138,42 @@ var ChatConfigGateway = class {
|
|
|
125
138
|
const { data } = await this.httpClient.get(`${this.baseUrl}/queue/${queueId}`);
|
|
126
139
|
return data;
|
|
127
140
|
}
|
|
128
|
-
async getQueues(
|
|
129
|
-
const { data } = await this.httpClient.get(`${this.baseUrl}/queues
|
|
141
|
+
async getQueues() {
|
|
142
|
+
const { data } = await this.httpClient.get(`${this.baseUrl}/queues`);
|
|
143
|
+
return data;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Retrieves a Meta template configuration by its ID.
|
|
147
|
+
* @param templateId - The unique identifier of the template.
|
|
148
|
+
* @returns The Meta template configuration.
|
|
149
|
+
*/
|
|
150
|
+
async getMetaTemplateById(templateId) {
|
|
151
|
+
const { data } = await this.httpClient.get(
|
|
152
|
+
`${this.baseUrl}/meta-templates-config/${templateId}`
|
|
153
|
+
);
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves template configurations associated with a configuration ID.
|
|
158
|
+
* @param configId - The configuration identifier.
|
|
159
|
+
* @returns The list of template configurations.
|
|
160
|
+
*/
|
|
161
|
+
async getTemplateConfigsByConfigId(configId) {
|
|
162
|
+
const { data } = await this.httpClient.get(
|
|
163
|
+
`${this.baseUrl}/meta-templates-config/config/${configId}`
|
|
164
|
+
);
|
|
165
|
+
return data;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Finds an existing queue rule or creates a new one if it does not exist.
|
|
169
|
+
* @param payload - The payload containing companyId, queueId, and configId.
|
|
170
|
+
* @returns The found or created queue rule.
|
|
171
|
+
*/
|
|
172
|
+
async findOrCreateQueueRule(payload) {
|
|
173
|
+
const { data } = await this.httpClient.put(
|
|
174
|
+
`${this.baseUrl}/rules/queue/find-or-create`,
|
|
175
|
+
payload
|
|
176
|
+
);
|
|
130
177
|
return data;
|
|
131
178
|
}
|
|
132
179
|
};
|
|
@@ -187,21 +234,97 @@ var CampaignsGateway = class {
|
|
|
187
234
|
const { data } = await this.httpClient.delete(`${this.baseUrl}/campaigns/${id}`);
|
|
188
235
|
return data;
|
|
189
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Retrieves a paginated list of campaign contacts.
|
|
239
|
+
* @param query - Optional query parameters for filtering and pagination.
|
|
240
|
+
* @returns The paginated campaign contacts response.
|
|
241
|
+
*/
|
|
242
|
+
async findCampaignContacts(query) {
|
|
243
|
+
const { data } = await this.httpClient.get(`${this.baseUrl}/campaign-contacts`, {
|
|
244
|
+
params: query
|
|
245
|
+
});
|
|
246
|
+
return data;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Retrieves a campaign contact by its unique identifier.
|
|
250
|
+
* @param id - The unique identifier of the campaign contact.
|
|
251
|
+
* @returns The campaign contact data.
|
|
252
|
+
*/
|
|
253
|
+
async getCampaignContacts(id) {
|
|
254
|
+
const { data } = await this.httpClient.get(`${this.baseUrl}/campaign-contacts/${id}`);
|
|
255
|
+
return data;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Creates a new campaign contact.
|
|
259
|
+
* @param payload - The campaign contact data to create.
|
|
260
|
+
* @returns The created campaign contact.
|
|
261
|
+
*/
|
|
262
|
+
async createCampaignContact(payload) {
|
|
263
|
+
const { data } = await this.httpClient.post(`${this.baseUrl}/campaign-contacts`, payload);
|
|
264
|
+
return data;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Partially updates an existing campaign contact.
|
|
268
|
+
* @param id - The unique identifier of the campaign contact.
|
|
269
|
+
* @param payload - The fields to update.
|
|
270
|
+
* @returns The updated campaign contact.
|
|
271
|
+
*/
|
|
272
|
+
async patchCampaignContact(id, payload) {
|
|
273
|
+
const { data } = await this.httpClient.patch(
|
|
274
|
+
`${this.baseUrl}/campaign-contacts/${id}`,
|
|
275
|
+
payload
|
|
276
|
+
);
|
|
277
|
+
return data;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Removes a campaign contact by its unique identifier.
|
|
281
|
+
* @param id - The unique identifier of the campaign contact.
|
|
282
|
+
* @returns The removed campaign contact.
|
|
283
|
+
*/
|
|
284
|
+
async removeCampaignContact(id) {
|
|
285
|
+
const { data } = await this.httpClient.delete(`${this.baseUrl}/campaign-contacts/${id}`);
|
|
286
|
+
return data;
|
|
287
|
+
}
|
|
190
288
|
async getUsers() {
|
|
191
289
|
const { data } = await this.httpClient.get(`${this.baseUrl}/users`);
|
|
192
290
|
return data;
|
|
193
291
|
}
|
|
194
292
|
};
|
|
195
293
|
|
|
294
|
+
// src/chat-adapter/index.ts
|
|
295
|
+
var ChatAdapterGateway = class {
|
|
296
|
+
constructor(httpClient, baseUrl) {
|
|
297
|
+
this.httpClient = httpClient;
|
|
298
|
+
this.baseUrl = baseUrl;
|
|
299
|
+
}
|
|
300
|
+
httpClient;
|
|
301
|
+
baseUrl;
|
|
302
|
+
/**
|
|
303
|
+
* Retrieves message templates associated with a configuration.
|
|
304
|
+
* @param configId - The unique identifier of the configuration.
|
|
305
|
+
* @param params - Optional query parameters for filtering and pagination.
|
|
306
|
+
* @returns A promise that resolves to the template list response.
|
|
307
|
+
*/
|
|
308
|
+
async getConfigTemplates(configId, params) {
|
|
309
|
+
const { data } = await this.httpClient.get(
|
|
310
|
+
`${this.baseUrl}/message-templates/${configId}`,
|
|
311
|
+
{ params }
|
|
312
|
+
);
|
|
313
|
+
return data;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
196
317
|
// src/@common/client.ts
|
|
197
318
|
var SDKGateways = class {
|
|
198
319
|
customerService;
|
|
199
320
|
chatConfig;
|
|
200
321
|
campaigns;
|
|
201
|
-
|
|
322
|
+
chatAdapter;
|
|
323
|
+
constructor(customerService, chatConfig, campaigns, chatAdapter) {
|
|
202
324
|
this.customerService = customerService;
|
|
203
325
|
this.chatConfig = chatConfig;
|
|
204
326
|
this.campaigns = campaigns;
|
|
327
|
+
this.chatAdapter = chatAdapter;
|
|
205
328
|
}
|
|
206
329
|
};
|
|
207
330
|
function createClient(params) {
|
|
@@ -209,14 +332,16 @@ function createClient(params) {
|
|
|
209
332
|
const customerService = params.services.customerService ? new CustomerServiceGateway(httpClient, params.services.customerService.baseUrl) : null;
|
|
210
333
|
const chatConfig = params.services.chatConfig ? new ChatConfigGateway(httpClient, params.services.chatConfig.baseUrl) : null;
|
|
211
334
|
const campaigns = params.services.campaigns ? new CampaignsGateway(httpClient, params.services.campaigns.baseUrl) : null;
|
|
212
|
-
|
|
335
|
+
const chatAdapter = params.services.chatAdapter ? new ChatAdapterGateway(httpClient, params.services.chatAdapter.baseUrl) : null;
|
|
336
|
+
return new SDKGateways(customerService, chatConfig, campaigns, chatAdapter);
|
|
213
337
|
}
|
|
214
338
|
|
|
215
339
|
// src/@common/enums.ts
|
|
216
340
|
var SERVICE_GATEWAYS = {
|
|
217
341
|
CUSTOMER_SERVICE: "customer-service",
|
|
218
342
|
CHAT_CONFIG: "chat-config",
|
|
219
|
-
CAMPAIGNS: "campaigns"
|
|
343
|
+
CAMPAIGNS: "campaigns",
|
|
344
|
+
CHAT_ADAPTER: "chat-adapter"
|
|
220
345
|
};
|
|
221
346
|
|
|
222
347
|
// src/index.ts
|
|
@@ -248,6 +373,10 @@ function gateway(service) {
|
|
|
248
373
|
if (!sdk.client.campaigns)
|
|
249
374
|
throw new Error(`Service 'campaigns' is not configured. Provide its baseUrl in configure().`);
|
|
250
375
|
return sdk.client.campaigns;
|
|
376
|
+
case SERVICE_GATEWAYS.CHAT_ADAPTER:
|
|
377
|
+
if (!sdk.client.chatAdapter)
|
|
378
|
+
throw new Error(`Service 'chat-adapter' is not configured. Provide its baseUrl in configure().`);
|
|
379
|
+
return sdk.client.chatAdapter;
|
|
251
380
|
default:
|
|
252
381
|
throw new Error(`Unknown service gateway: ${service}`);
|
|
253
382
|
}
|