@oficialapi/sdk 9.0.7 → 9.0.8
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 -1
- package/dist/index.d.mts +51 -50
- package/dist/index.d.ts +51 -50
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +61 -61
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ interface Channel {
|
|
|
38
38
|
id: number;
|
|
39
39
|
channelToken: string;
|
|
40
40
|
nome: string;
|
|
41
|
-
channel:
|
|
41
|
+
channel: "whatsapp" | "facebook" | "instagram" | "webchat" | "email" | "telegram";
|
|
42
42
|
status: boolean;
|
|
43
43
|
numero?: string | null;
|
|
44
44
|
instagram?: {
|
|
@@ -56,7 +56,7 @@ interface SendWhatsAppMediaParams {
|
|
|
56
56
|
channelToken: string;
|
|
57
57
|
sender: string;
|
|
58
58
|
fileUrl: string;
|
|
59
|
-
type:
|
|
59
|
+
type: "image" | "video" | "audio" | "document";
|
|
60
60
|
caption?: string;
|
|
61
61
|
fileName?: string;
|
|
62
62
|
}
|
|
@@ -66,25 +66,25 @@ interface SendWhatsAppTemplateParams {
|
|
|
66
66
|
templateName: string;
|
|
67
67
|
languageCode: string;
|
|
68
68
|
components?: Array<{
|
|
69
|
-
type:
|
|
69
|
+
type: "HEADER" | "BODY" | "BUTTONS";
|
|
70
70
|
parameters?: Array<{
|
|
71
|
-
type:
|
|
71
|
+
type: "text";
|
|
72
72
|
text: string;
|
|
73
73
|
} | {
|
|
74
|
-
type:
|
|
74
|
+
type: "image";
|
|
75
75
|
image: {
|
|
76
76
|
link?: string;
|
|
77
77
|
id?: string;
|
|
78
78
|
};
|
|
79
79
|
} | {
|
|
80
|
-
type:
|
|
80
|
+
type: "document";
|
|
81
81
|
document: {
|
|
82
82
|
link?: string;
|
|
83
83
|
id?: string;
|
|
84
84
|
filename?: string;
|
|
85
85
|
};
|
|
86
86
|
} | {
|
|
87
|
-
type:
|
|
87
|
+
type: "video";
|
|
88
88
|
video: {
|
|
89
89
|
link?: string;
|
|
90
90
|
id?: string;
|
|
@@ -138,17 +138,17 @@ interface CreateTemplateParams {
|
|
|
138
138
|
channelToken: string;
|
|
139
139
|
name: string;
|
|
140
140
|
language: string;
|
|
141
|
-
category:
|
|
141
|
+
category: "MARKETING" | "UTILITY" | "AUTHENTICATION";
|
|
142
142
|
components: Array<{
|
|
143
|
-
type:
|
|
144
|
-
format?:
|
|
143
|
+
type: "HEADER" | "BODY" | "FOOTER" | "BUTTONS";
|
|
144
|
+
format?: "TEXT" | "IMAGE" | "VIDEO" | "DOCUMENT";
|
|
145
145
|
text?: string;
|
|
146
146
|
example?: {
|
|
147
147
|
header_text?: string[];
|
|
148
148
|
body_text?: string[][];
|
|
149
149
|
};
|
|
150
150
|
buttons?: Array<{
|
|
151
|
-
type:
|
|
151
|
+
type: "QUICK_REPLY" | "URL" | "PHONE_NUMBER";
|
|
152
152
|
text?: string;
|
|
153
153
|
url?: string;
|
|
154
154
|
phone_number?: string;
|
|
@@ -158,7 +158,7 @@ interface CreateTemplateParams {
|
|
|
158
158
|
interface UploadMediaParams {
|
|
159
159
|
channelToken: string;
|
|
160
160
|
file: File | Blob | Buffer;
|
|
161
|
-
mediaType:
|
|
161
|
+
mediaType: "image" | "video" | "document";
|
|
162
162
|
filename?: string;
|
|
163
163
|
}
|
|
164
164
|
interface SendOrderDetailsParams {
|
|
@@ -168,7 +168,7 @@ interface SendOrderDetailsParams {
|
|
|
168
168
|
bodyText: string;
|
|
169
169
|
footerText?: string;
|
|
170
170
|
reference_id: string;
|
|
171
|
-
type:
|
|
171
|
+
type: "digital-goods" | "physical-goods";
|
|
172
172
|
currency: string;
|
|
173
173
|
total_amount: {
|
|
174
174
|
value: number;
|
|
@@ -176,7 +176,7 @@ interface SendOrderDetailsParams {
|
|
|
176
176
|
description?: string;
|
|
177
177
|
};
|
|
178
178
|
order: {
|
|
179
|
-
status:
|
|
179
|
+
status: "pending" | "processing" | "partially-shipped" | "shipped" | "completed" | "canceled";
|
|
180
180
|
catalog_id?: string;
|
|
181
181
|
items: Array<{
|
|
182
182
|
retailer_id: string;
|
|
@@ -220,12 +220,12 @@ interface SendOrderDetailsParams {
|
|
|
220
220
|
};
|
|
221
221
|
};
|
|
222
222
|
payment_settings?: Array<{
|
|
223
|
-
type:
|
|
223
|
+
type: "pix_dynamic_code" | "payment_link" | "boleto" | "offsite_card_pay";
|
|
224
224
|
pix_dynamic_code?: {
|
|
225
225
|
code: string;
|
|
226
226
|
merchant_name: string;
|
|
227
227
|
key: string;
|
|
228
|
-
key_type:
|
|
228
|
+
key_type: "CPF" | "CNPJ" | "EMAIL" | "PHONE" | "EVP";
|
|
229
229
|
};
|
|
230
230
|
payment_link?: {
|
|
231
231
|
uri: string;
|
|
@@ -245,9 +245,9 @@ interface SendOrderStatusParams {
|
|
|
245
245
|
bodyText: string;
|
|
246
246
|
footerText?: string;
|
|
247
247
|
reference_id: string;
|
|
248
|
-
order_status:
|
|
248
|
+
order_status: "pending" | "processing" | "partially-shipped" | "shipped" | "completed" | "canceled";
|
|
249
249
|
status_description?: string;
|
|
250
|
-
payment_status?:
|
|
250
|
+
payment_status?: "pending" | "captured" | "failed";
|
|
251
251
|
payment_timestamp?: number;
|
|
252
252
|
}
|
|
253
253
|
interface SendWhatsAppAudioParams {
|
|
@@ -338,7 +338,7 @@ interface SendWhatsAppCtaUrlParams {
|
|
|
338
338
|
buttonText: string;
|
|
339
339
|
url: string;
|
|
340
340
|
header?: {
|
|
341
|
-
type:
|
|
341
|
+
type: "text" | "image" | "video" | "document";
|
|
342
342
|
text?: string;
|
|
343
343
|
link?: string;
|
|
344
344
|
};
|
|
@@ -350,7 +350,7 @@ interface SendWhatsAppMediaCarouselParams {
|
|
|
350
350
|
bodyText: string;
|
|
351
351
|
cards: Array<{
|
|
352
352
|
cardIndex: number;
|
|
353
|
-
headerType:
|
|
353
|
+
headerType: "image" | "video";
|
|
354
354
|
headerLink: string;
|
|
355
355
|
bodyText: string;
|
|
356
356
|
buttonText: string;
|
|
@@ -365,7 +365,7 @@ interface SendTelegramTextParams {
|
|
|
365
365
|
channelToken: string;
|
|
366
366
|
chatId: string | number;
|
|
367
367
|
text: string;
|
|
368
|
-
parseMode?:
|
|
368
|
+
parseMode?: "HTML" | "Markdown" | "MarkdownV2";
|
|
369
369
|
replyToMessageId?: number;
|
|
370
370
|
disableNotification?: boolean;
|
|
371
371
|
}
|
|
@@ -373,9 +373,9 @@ interface SendTelegramMediaParams {
|
|
|
373
373
|
channelToken: string;
|
|
374
374
|
chatId: string | number;
|
|
375
375
|
fileUrl: string;
|
|
376
|
-
type:
|
|
376
|
+
type: "photo" | "video" | "audio" | "document" | "voice";
|
|
377
377
|
caption?: string;
|
|
378
|
-
parseMode?:
|
|
378
|
+
parseMode?: "HTML" | "Markdown" | "MarkdownV2";
|
|
379
379
|
replyToMessageId?: number;
|
|
380
380
|
}
|
|
381
381
|
interface SendTelegramButtonsParams {
|
|
@@ -390,7 +390,7 @@ interface SendTelegramButtonsParams {
|
|
|
390
390
|
url: string;
|
|
391
391
|
};
|
|
392
392
|
}>>;
|
|
393
|
-
parseMode?:
|
|
393
|
+
parseMode?: "HTML" | "Markdown" | "MarkdownV2";
|
|
394
394
|
}
|
|
395
395
|
interface SendTelegramLocationParams {
|
|
396
396
|
channelToken: string;
|
|
@@ -413,7 +413,7 @@ interface SendTelegramPollParams {
|
|
|
413
413
|
question: string;
|
|
414
414
|
options: string[];
|
|
415
415
|
isAnonymous?: boolean;
|
|
416
|
-
type?:
|
|
416
|
+
type?: "quiz" | "regular";
|
|
417
417
|
correctOptionId?: number;
|
|
418
418
|
}
|
|
419
419
|
interface SendTelegramVenueParams {
|
|
@@ -428,7 +428,7 @@ interface SendTelegramVenueParams {
|
|
|
428
428
|
interface SendTelegramDiceParams {
|
|
429
429
|
channelToken: string;
|
|
430
430
|
chatId: string | number;
|
|
431
|
-
emoji?:
|
|
431
|
+
emoji?: "🎲" | "🎯" | "🏀" | "⚽" | "🎳" | "🎰";
|
|
432
432
|
}
|
|
433
433
|
interface SendTelegramStickerParams {
|
|
434
434
|
channelToken: string;
|
|
@@ -453,7 +453,7 @@ interface SendTelegramMediaGroupParams {
|
|
|
453
453
|
channelToken: string;
|
|
454
454
|
chatId: string | number;
|
|
455
455
|
media: Array<{
|
|
456
|
-
type:
|
|
456
|
+
type: "photo" | "video";
|
|
457
457
|
media: string;
|
|
458
458
|
caption?: string;
|
|
459
459
|
}>;
|
|
@@ -473,7 +473,7 @@ interface EditTelegramMessageParams {
|
|
|
473
473
|
chatId: string | number;
|
|
474
474
|
messageId: number;
|
|
475
475
|
text: string;
|
|
476
|
-
parseMode?:
|
|
476
|
+
parseMode?: "HTML" | "Markdown" | "MarkdownV2";
|
|
477
477
|
}
|
|
478
478
|
interface DeleteTelegramMessageParams {
|
|
479
479
|
channelToken: string;
|
|
@@ -495,7 +495,7 @@ interface SendWebChatMediaParams {
|
|
|
495
495
|
channelToken: string;
|
|
496
496
|
chatId: string;
|
|
497
497
|
fileUrl: string;
|
|
498
|
-
type:
|
|
498
|
+
type: "image" | "video" | "audio" | "file";
|
|
499
499
|
caption?: string;
|
|
500
500
|
typing?: boolean;
|
|
501
501
|
typingTime?: number;
|
|
@@ -510,7 +510,7 @@ interface SendWebChatCarouselParams {
|
|
|
510
510
|
buttons?: Array<{
|
|
511
511
|
id?: string;
|
|
512
512
|
text: string;
|
|
513
|
-
type:
|
|
513
|
+
type: "text" | "url" | "phone" | "postback";
|
|
514
514
|
value?: string;
|
|
515
515
|
url?: string;
|
|
516
516
|
}>;
|
|
@@ -526,7 +526,7 @@ interface SendWebChatFormParams {
|
|
|
526
526
|
fields: Array<{
|
|
527
527
|
id?: string;
|
|
528
528
|
name?: string;
|
|
529
|
-
type:
|
|
529
|
+
type: "text" | "email" | "number" | "tel" | "date" | "select";
|
|
530
530
|
label: string;
|
|
531
531
|
placeholder?: string;
|
|
532
532
|
required?: boolean;
|
|
@@ -560,7 +560,7 @@ interface SendWebChatCardParams {
|
|
|
560
560
|
buttons?: Array<{
|
|
561
561
|
id?: string;
|
|
562
562
|
text: string;
|
|
563
|
-
type:
|
|
563
|
+
type: "text" | "url" | "phone" | "postback";
|
|
564
564
|
value?: string;
|
|
565
565
|
url?: string;
|
|
566
566
|
}>;
|
|
@@ -574,7 +574,7 @@ interface SendWebChatButtonsParams {
|
|
|
574
574
|
buttons: Array<{
|
|
575
575
|
id?: string;
|
|
576
576
|
text: string;
|
|
577
|
-
type:
|
|
577
|
+
type: "text" | "url" | "phone" | "postback";
|
|
578
578
|
value?: string;
|
|
579
579
|
url?: string;
|
|
580
580
|
}>;
|
|
@@ -583,29 +583,30 @@ interface SendWebChatButtonsParams {
|
|
|
583
583
|
}
|
|
584
584
|
interface ListPostsParams {
|
|
585
585
|
channelToken: string;
|
|
586
|
-
channelType:
|
|
586
|
+
channelType: "facebook" | "instagram";
|
|
587
587
|
pageId?: string;
|
|
588
588
|
limit?: number;
|
|
589
589
|
after?: string;
|
|
590
|
-
type?:
|
|
590
|
+
type?: "feed" | "photos" | "videos" | "events" | "media";
|
|
591
591
|
includeComments?: boolean;
|
|
592
592
|
includeReactions?: boolean;
|
|
593
593
|
}
|
|
594
594
|
interface ListCommentsParams {
|
|
595
595
|
channelToken: string;
|
|
596
|
-
channelType:
|
|
596
|
+
channelType: "facebook" | "instagram";
|
|
597
597
|
postId: string;
|
|
598
598
|
limit?: number;
|
|
599
599
|
after?: string;
|
|
600
|
-
order?:
|
|
600
|
+
order?: "created_time" | "like_count";
|
|
601
601
|
filterUnanswered?: boolean;
|
|
602
602
|
includeReplies?: boolean;
|
|
603
603
|
}
|
|
604
604
|
interface CreatePostParams {
|
|
605
605
|
channelToken: string;
|
|
606
|
-
pageId: string;
|
|
607
606
|
message: string;
|
|
607
|
+
channelType: "facebook" | "instagram";
|
|
608
608
|
link?: string;
|
|
609
|
+
mediaType?: string;
|
|
609
610
|
}
|
|
610
611
|
interface ReplyCommentParams {
|
|
611
612
|
channelToken: string;
|
|
@@ -625,7 +626,7 @@ interface SendFacebookMediaParams {
|
|
|
625
626
|
channelToken: string;
|
|
626
627
|
recipientId: string;
|
|
627
628
|
fileUrl: string;
|
|
628
|
-
type:
|
|
629
|
+
type: "image" | "video" | "audio" | "file";
|
|
629
630
|
caption?: string;
|
|
630
631
|
}
|
|
631
632
|
interface SendFacebookButtonsParams {
|
|
@@ -633,7 +634,7 @@ interface SendFacebookButtonsParams {
|
|
|
633
634
|
recipientId: string;
|
|
634
635
|
message: string;
|
|
635
636
|
buttons: Array<{
|
|
636
|
-
type:
|
|
637
|
+
type: "web_url" | "postback";
|
|
637
638
|
title: string;
|
|
638
639
|
url?: string;
|
|
639
640
|
payload?: string;
|
|
@@ -653,7 +654,7 @@ interface ReplyFacebookMediaParams {
|
|
|
653
654
|
channelToken: string;
|
|
654
655
|
messageId: string;
|
|
655
656
|
fileUrl: string;
|
|
656
|
-
type:
|
|
657
|
+
type: "image" | "video" | "audio" | "file";
|
|
657
658
|
caption?: string;
|
|
658
659
|
}
|
|
659
660
|
interface SharePostParams {
|
|
@@ -688,7 +689,7 @@ interface SendInstagramMediaParams {
|
|
|
688
689
|
channelToken: string;
|
|
689
690
|
recipientId: string;
|
|
690
691
|
attachment: {
|
|
691
|
-
type:
|
|
692
|
+
type: "image" | "video" | "audio" | "file";
|
|
692
693
|
url: string;
|
|
693
694
|
};
|
|
694
695
|
tags?: string[];
|
|
@@ -704,12 +705,12 @@ interface SendInstagramImagesParams {
|
|
|
704
705
|
interface SendInstagramStickerParams {
|
|
705
706
|
channelToken: string;
|
|
706
707
|
recipientId: string;
|
|
707
|
-
stickerType:
|
|
708
|
+
stickerType: "like" | "heart";
|
|
708
709
|
}
|
|
709
710
|
interface ReactInstagramMessageParams {
|
|
710
711
|
channelToken: string;
|
|
711
712
|
messageId: string;
|
|
712
|
-
reactionType:
|
|
713
|
+
reactionType: "like" | "love" | "wow" | "haha" | "sorry" | "anger";
|
|
713
714
|
}
|
|
714
715
|
interface RemoveInstagramReactionParams {
|
|
715
716
|
channelToken: string;
|
|
@@ -721,7 +722,7 @@ interface SendInstagramQuickRepliesParams {
|
|
|
721
722
|
recipientId: string;
|
|
722
723
|
message: string;
|
|
723
724
|
quickReplies: Array<{
|
|
724
|
-
content_type:
|
|
725
|
+
content_type: "text";
|
|
725
726
|
title: string;
|
|
726
727
|
payload: string;
|
|
727
728
|
}>;
|
|
@@ -734,7 +735,7 @@ interface SendInstagramGenericTemplateParams {
|
|
|
734
735
|
subtitle?: string;
|
|
735
736
|
image_url?: string;
|
|
736
737
|
buttons?: Array<{
|
|
737
|
-
type:
|
|
738
|
+
type: "web_url" | "postback";
|
|
738
739
|
title: string;
|
|
739
740
|
url?: string;
|
|
740
741
|
payload?: string;
|
|
@@ -746,7 +747,7 @@ interface SendInstagramButtonTemplateParams {
|
|
|
746
747
|
recipientId: string;
|
|
747
748
|
text: string;
|
|
748
749
|
buttons: Array<{
|
|
749
|
-
type:
|
|
750
|
+
type: "web_url" | "postback";
|
|
750
751
|
title: string;
|
|
751
752
|
url?: string;
|
|
752
753
|
payload?: string;
|
|
@@ -755,7 +756,7 @@ interface SendInstagramButtonTemplateParams {
|
|
|
755
756
|
interface SendInstagramSenderActionParams {
|
|
756
757
|
channelToken: string;
|
|
757
758
|
recipientId: string;
|
|
758
|
-
action:
|
|
759
|
+
action: "typing_on" | "typing_off" | "mark_seen";
|
|
759
760
|
}
|
|
760
761
|
interface GetInstagramUserProfileParams {
|
|
761
762
|
channelToken: string;
|
|
@@ -773,8 +774,8 @@ interface DownloadInstagramMediaParams {
|
|
|
773
774
|
channelToken: string;
|
|
774
775
|
url: string;
|
|
775
776
|
}
|
|
776
|
-
type InstagramPublishMediaType =
|
|
777
|
-
type GraduationStrategy =
|
|
777
|
+
type InstagramPublishMediaType = "IMAGE" | "VIDEO" | "REELS" | "STORIES" | "CAROUSEL";
|
|
778
|
+
type GraduationStrategy = "MANUAL" | "SS_PERFORMANCE";
|
|
778
779
|
interface CreateInstagramMediaContainerParams {
|
|
779
780
|
channelToken: string;
|
|
780
781
|
image_url?: string;
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* @version 1.0.0
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
var I="https://api.oficialapi.com.br",l=class{constructor(e){this.config={clientId:e.clientId,clientSecret:e.clientSecret,timeout:e.timeout||3e4,maxRetries:e.maxRetries||3,retryDelay:e.retryDelay||1e3,headers:e.headers||{}},this.axiosInstance=P__default.default.create({baseURL:I,timeout:this.config.timeout,headers:{"Content-Type":"application/json",...this.config.headers}}),this.setupInterceptors();}setupInterceptors(){this.axiosInstance.interceptors.request.use(e=>{if(e.url?.includes("/auth/token"))return e;let t=e;return t.accessToken&&e.headers&&(e.headers.Authorization=`Bearer ${t.accessToken}`),e},e=>Promise.reject(e)),this.axiosInstance.interceptors.response.use(e=>e,async e=>{let t=e.config;if(!t)return Promise.reject(this.formatError(e));if((!e.response||e.response.status>=500&&e.response.status<600)&&(!t._retryCount||t._retryCount<this.config.maxRetries)){t._retryCount=(t._retryCount||0)+1;let s=this.config.retryDelay*t._retryCount;return await new Promise(i=>setTimeout(i,s)),this.axiosInstance(t)}return Promise.reject(this.formatError(e))});}formatError(e){if(e.response){let t=e.response.data,n=t?.error?.message||t?.message||e.message,s=t?.error?.details||[],i=new Error(n);return i.status=e.response.status,i.data=e.response.data,i.details=s,i}return e.request?new Error("Erro de conex\xE3o com a API. Verifique sua conex\xE3o com a internet."):e}async get(e,t,n){let s={...n,accessToken:t};return (await this.axiosInstance.get(e,s)).data}async post(e,t,n,s){let i={...s,accessToken:n};return (await this.axiosInstance.post(e,t,i)).data}async put(e,t,n,s){let i={...s,accessToken:n};return (await this.axiosInstance.put(e,t,i)).data}async delete(e,t,n,s){let i={...s,accessToken:t,data:n};return (await this.axiosInstance.delete(e,i)).data}async upload(e,t,n,s="file",i){let o=new FormData;if(t instanceof Buffer){let y=new Blob([t]);o.append(s,y);}else o.append(s,t);i&&Object.entries(i).forEach(([y,r])=>{r!=null&&o.append(y,typeof r=="string"?r:JSON.stringify(r));});let C={headers:{"Content-Type":"multipart/form-data"},accessToken:n};return (await this.axiosInstance.post(e,o,C)).data}};var d=class{constructor(e){this.httpClient=e;}async getToken(e,t){let n=await this.httpClient.post("/api/v1/auth/token",{client_id:e,client_secret:t});if(!n.success||!n.data)throw new Error(n.error?.message||"Falha ao obter token");return n.data}};var c=class{constructor(e){this.httpClient=e;}async list(e){let t=await this.httpClient.get("/api/v1/channels",e);if(!t.success||!t.data)throw new Error(t.error?.message||"Falha ao listar canais");return Array.isArray(t.data)?t.data:[t.data]}};var h=class{constructor(e){this.httpClient=e;}async createWebhook(e,t){let n=await this.httpClient.post("/api/v1/integrations",{url:e.url,expiresInDays:e.expiresInDays},t);if(!n.success||!n.data)throw new Error(n.error?.message||"Falha ao criar webhook");return n.data}};var p=class{constructor(e){this.httpClient=e;}async sendText(e,t){return this.httpClient.post("/api/v1/whatsapp/send-message",{channelToken:e.channelToken,sender:e.sender,messageText:e.messageText},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/whatsapp/send-media",{channelToken:e.channelToken,sender:e.sender,fileUrl:e.fileUrl,type:e.type,caption:e.caption,...e.fileName&&{fileName:e.fileName}},t)}async sendTemplate(e,t){return this.httpClient.post("/api/v1/whatsapp/send-template",{channelToken:e.channelToken,sender:e.sender,templateName:e.templateName,languageCode:e.languageCode,components:e.components},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/whatsapp/send-buttons",{channelToken:e.channelToken,sender:e.sender,text:e.text,buttons:e.buttons,...e.media&&{media:e.media}},t)}async sendList(e,t){return this.httpClient.post("/api/v1/whatsapp/send-list",{channelToken:e.channelToken,sender:e.sender,headerText:e.headerText,bodyText:e.bodyText,buttonText:e.buttonText,sections:e.sections,...e.footerText&&{footerText:e.footerText}},t)}async replyMessage(e,t){return this.httpClient.post("/api/v1/whatsapp/reply-message",{channelToken:e.channelToken,sender:e.sender,messageText:e.messageText,...e.replyMessageId&&{replyMessageId:e.replyMessageId},...e.preview_url!==void 0&&{preview_url:e.preview_url}},t)}async reactMessage(e,t){return this.httpClient.post("/api/v1/whatsapp/react-message",{channelToken:e.channelToken,sender:e.sender,emoji:e.emoji,...e.message_id&&{message_id:e.message_id}},t)}async createTemplate(e,t){return this.httpClient.post("/api/v1/whatsapp/create-template",{channelToken:e.channelToken,name:e.name,language:e.language,category:e.category,components:e.components},t)}async listTemplates(e,t){return this.httpClient.get(`/api/v1/whatsapp/templates?channelToken=${encodeURIComponent(e)}`,t)}async getTemplate(e,t,n){return this.httpClient.get(`/api/v1/whatsapp/templates/${t}?channelToken=${encodeURIComponent(e)}`,n)}async uploadMedia(e,t){return this.httpClient.upload("/api/v1/whatsapp/upload-media",e.file,t,"file",{channelToken:e.channelToken,mediaType:e.mediaType,...e.filename&&{filename:e.filename}})}async sendOrderDetails(e,t){return this.httpClient.post("/api/v1/whatsapp/send-order-details",{channelToken:e.channelToken,sender:e.sender,...e.headerText&&{headerText:e.headerText},bodyText:e.bodyText,...e.footerText&&{footerText:e.footerText},reference_id:e.reference_id,type:e.type,currency:e.currency,total_amount:e.total_amount,order:e.order,...e.payment_settings&&{payment_settings:e.payment_settings}},t)}async sendOrderStatus(e,t){return this.httpClient.post("/api/v1/whatsapp/send-order-status",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,...e.footerText&&{footerText:e.footerText},reference_id:e.reference_id,order_status:e.order_status,...e.status_description&&{status_description:e.status_description},...e.payment_status&&{payment_status:e.payment_status},...e.payment_timestamp!==void 0&&{payment_timestamp:e.payment_timestamp}},t)}async sendAudio(e,t){return this.httpClient.post("/api/v1/whatsapp/send-audio",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId,...e.voice!==void 0&&{voice:e.voice}},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/whatsapp/send-sticker",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId},t)}async sendVideo(e,t){return this.httpClient.post("/api/v1/whatsapp/send-video",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId,...e.caption&&{caption:e.caption}},t)}async sendDocument(e,t){return this.httpClient.post("/api/v1/whatsapp/send-document",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId,...e.filename&&{filename:e.filename},...e.caption&&{caption:e.caption}},t)}async sendContact(e,t){return this.httpClient.post("/api/v1/whatsapp/send-contact",{channelToken:e.channelToken,sender:e.sender,contacts:e.contacts},t)}async sendLocation(e,t){return this.httpClient.post("/api/v1/whatsapp/send-location",{channelToken:e.channelToken,sender:e.sender,latitude:e.latitude,longitude:e.longitude,name:e.name,address:e.address},t)}async sendLocationRequest(e,t){return this.httpClient.post("/api/v1/whatsapp/send-location-request",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,...e.headerText&&{headerText:e.headerText},...e.footerText&&{footerText:e.footerText}},t)}async sendCtaUrl(e,t){return this.httpClient.post("/api/v1/whatsapp/send-cta-url",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,buttonText:e.buttonText,url:e.url,...e.header&&{header:e.header},...e.footerText&&{footerText:e.footerText}},t)}async sendMediaCarousel(e,t){return this.httpClient.post("/api/v1/whatsapp/send-media-carousel",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,cards:e.cards},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/whatsapp/download-media",{channelToken:e.channelToken,url:e.url},t)}};var g=class{constructor(e){this.httpClient=e;}async sendMessage(e,t){return this.httpClient.post("/api/v1/telegram/send-message",{channelToken:e.channelToken,chatId:e.chatId,text:e.text,parseMode:e.parseMode,replyToMessageId:e.replyToMessageId,disableNotification:e.disableNotification},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/telegram/send-media",{channelToken:e.channelToken,chatId:e.chatId,fileUrl:e.fileUrl,type:e.type,caption:e.caption,parseMode:e.parseMode,replyToMessageId:e.replyToMessageId},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/telegram/send-buttons",{channelToken:e.channelToken,chatId:e.chatId,text:e.text,buttons:e.buttons,parseMode:e.parseMode},t)}async sendLocation(e,t){return this.httpClient.post("/api/v1/telegram/send-location",{channelToken:e.channelToken,chatId:e.chatId,latitude:e.latitude,longitude:e.longitude,livePeriod:e.livePeriod},t)}async sendContact(e,t){return this.httpClient.post("/api/v1/telegram/send-contact",{channelToken:e.channelToken,chatId:e.chatId,phoneNumber:e.phoneNumber,firstName:e.firstName,lastName:e.lastName,vcard:e.vcard},t)}async sendPoll(e,t){return this.httpClient.post("/api/v1/telegram/send-poll",{channelToken:e.channelToken,chatId:e.chatId,question:e.question,options:e.options,isAnonymous:e.isAnonymous,type:e.type,correctOptionId:e.correctOptionId},t)}async sendVenue(e,t){return this.httpClient.post("/api/v1/telegram/send-venue",{channelToken:e.channelToken,chatId:e.chatId,latitude:e.latitude,longitude:e.longitude,title:e.title,address:e.address,foursquareId:e.foursquareId},t)}async sendDice(e,t){return this.httpClient.post("/api/v1/telegram/send-dice",{channelToken:e.channelToken,chatId:e.chatId,emoji:e.emoji},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/telegram/send-sticker",{channelToken:e.channelToken,chatId:e.chatId,stickerUrl:e.stickerUrl},t)}async sendVoice(e,t){return this.httpClient.post("/api/v1/telegram/send-voice",{channelToken:e.channelToken,chatId:e.chatId,voiceUrl:e.voiceUrl,caption:e.caption,duration:e.duration},t)}async sendVideoNote(e,t){return this.httpClient.post("/api/v1/telegram/send-video-note",{channelToken:e.channelToken,chatId:e.chatId,videoNoteUrl:e.videoNoteUrl,duration:e.duration,length:e.length},t)}async sendMediaGroup(e,t){return this.httpClient.post("/api/v1/telegram/send-media-group",{channelToken:e.channelToken,chatId:e.chatId,media:e.media},t)}async sendReplyKeyboard(e,t){return this.httpClient.post("/api/v1/telegram/send-reply-keyboard",{channelToken:e.channelToken,chatId:e.chatId,text:e.text,keyboard:e.keyboard,resizeKeyboard:e.resizeKeyboard,oneTimeKeyboard:e.oneTimeKeyboard},t)}async editMessage(e,t){return this.httpClient.post("/api/v1/telegram/edit-message",{channelToken:e.channelToken,chatId:e.chatId,messageId:e.messageId,text:e.text,parseMode:e.parseMode},t)}async deleteMessage(e,t){return this.httpClient.post("/api/v1/telegram/delete-message",{channelToken:e.channelToken,chatId:e.chatId,messageId:e.messageId},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/telegram/download-media",{channelToken:e.channelToken,fileId:e.fileId},t)}};var u=class{constructor(e){this.httpClient=e;}async sendText(e,t){return this.httpClient.post("/api/v1/webchat/send-text",{channelToken:e.channelToken,chatId:e.chatId,type:"text",content:{text:e.messageText,typingTime:e.typingTime},typing:e.typing},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/webchat/send-media",{channelToken:e.channelToken,chatId:e.chatId,type:e.type,content:{url:e.fileUrl,caption:e.caption,typingTime:e.typingTime},typing:e.typing},t)}async sendCarousel(e,t){return this.httpClient.post("/api/v1/webchat/send-carousel",{channelToken:e.channelToken,chatId:e.chatId,type:"carousel",content:{cards:e.cards.map(n=>({title:n.title,subtitle:n.subtitle,imageUrl:n.imageUrl,buttons:n.buttons?.map(s=>({id:s.id||`btn_${Date.now()}_${Math.random()}`,text:s.text,type:s.type,value:s.value,url:s.url}))})),typingTime:e.typingTime},typing:e.typing},t)}async sendForm(e,t){return this.httpClient.post("/api/v1/webchat/send-form",{channelToken:e.channelToken,chatId:e.chatId,type:"form",content:{id:e.id,title:e.title,submitText:e.submitButtonText,fields:e.fields.map(n=>({id:n.id||n.name,type:n.type,label:n.label,placeholder:n.placeholder,required:n.required,options:n.options})),typingTime:e.typingTime},typing:e.typing},t)}async sendQuickReplies(e,t){return this.httpClient.post("/api/v1/webchat/send-quick-replies",{channelToken:e.channelToken,chatId:e.chatId,type:"quickReplies",content:{text:e.messageText,quickReplies:e.quickReplies.map(n=>({id:n.id||`qr_${Date.now()}_${Math.random()}`,text:n.text,value:n.value})),typingTime:e.typingTime},typing:e.typing},t)}async sendCard(e,t){return this.httpClient.post("/api/v1/webchat/send-card",{channelToken:e.channelToken,chatId:e.chatId,type:"card",content:{title:e.title,subtitle:e.description,imageUrl:e.imageUrl,buttons:e.buttons?.map(n=>({id:n.id||`btn_${Date.now()}_${Math.random()}`,text:n.text,type:n.type,value:n.value,url:n.url})),typingTime:e.typingTime},typing:e.typing},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/webchat/send-buttons",{channelToken:e.channelToken,chatId:e.chatId,type:"buttons",content:{text:e.messageText,buttons:e.buttons.map(n=>({id:n.id||`btn_${Date.now()}_${Math.random()}`,text:n.text,type:n.type,value:n.value,url:n.url})),typingTime:e.typingTime},typing:e.typing},t)}};var m=class{constructor(e){this.httpClient=e;}async listPosts(e,t){return this.httpClient.post("/api/v1/facebook/list-posts",{channelToken:e.channelToken,channelType:e.channelType,limit:e.limit,after:e.after,type:e.type,includeComments:e.includeComments,includeReactions:e.includeReactions},t)}async listComments(e,t){return this.httpClient.post("/api/v1/facebook/list-comments",{channelToken:e.channelToken,channelType:e.channelType,postId:e.postId,limit:e.limit,after:e.after,order:e.order,filterUnanswered:e.filterUnanswered,includeReplies:e.includeReplies},t)}async createPost(e,t){return this.httpClient.post("/api/v1/facebook/create-post",{channelToken:e.channelToken,pageId:e.pageId,message:e.message,link:e.link},t)}async replyComment(e,t){return this.httpClient.post("/api/v1/facebook/reply-comment",{channelToken:e.channelToken,commentId:e.commentId,message:e.message},t)}async deleteComment(e,t){return this.httpClient.post("/api/v1/facebook/delete-comment",{channelToken:e.channelToken,commentId:e.commentId},t)}async sendText(e,t){return this.httpClient.post("/api/v1/facebook/send-text",{channelToken:e.channelToken,recipientId:e.recipientId,message:e.message},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/facebook/send-media",{channelToken:e.channelToken,recipientId:e.recipientId,fileUrl:e.fileUrl,type:e.type,caption:e.caption},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/facebook/send-buttons",{channelToken:e.channelToken,recipientId:e.recipientId,message:e.message,buttons:e.buttons},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/facebook/send-sticker",{channelToken:e.channelToken,recipientId:e.recipientId,stickerId:e.stickerId},t)}async replyMessage(e,t){return this.httpClient.post("/api/v1/facebook/reply-message",{channelToken:e.channelToken,messageId:e.messageId,message:e.message},t)}async replyMedia(e,t){return this.httpClient.post("/api/v1/facebook/reply-media",{channelToken:e.channelToken,messageId:e.messageId,fileUrl:e.fileUrl,type:e.type,caption:e.caption},t)}async sharePost(e,t){return this.httpClient.post("/api/v1/facebook/share-post",{channelToken:e.channelToken,mediaId:e.mediaId,recipientId:e.recipientId},t)}async getUserProfile(e,t){return this.httpClient.post("/api/v1/facebook/user-profile",{channelToken:e.channelToken,userId:e.userId},t)}async getPageProfile(e,t){return this.httpClient.post("/api/v1/facebook/page-profile",{channelToken:e.channelToken,pageId:e.pageId},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/facebook/download-media",{channelToken:e.channelToken,url:e.url},t)}};var T=class{constructor(e){this.httpClient=e;}async sendPrivateReply(e,t){return this.httpClient.post("/api/v1/instagram/private-reply",{channelToken:e.channelToken,commentId:e.commentId,message:e.message},t)}async sendText(e,t){return this.httpClient.post("/api/v1/instagram/messages/text",{channelToken:e.channelToken,recipientId:e.recipientId,text:e.text,...e.tags&&{tags:e.tags}},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/instagram/messages/media",{channelToken:e.channelToken,recipientId:e.recipientId,attachment:e.attachment,...e.tags&&{tags:e.tags}},t)}async sendImages(e,t){return this.httpClient.post("/api/v1/instagram/messages/images",{channelToken:e.channelToken,recipientId:e.recipientId,images:e.images},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/instagram/messages/sticker",{channelToken:e.channelToken,recipientId:e.recipientId,stickerType:e.stickerType},t)}async reactMessage(e,t){return this.httpClient.post("/api/v1/instagram/messages/reaction",{channelToken:e.channelToken,messageId:e.messageId,reactionType:e.reactionType},t)}async removeReaction(e,t){return this.httpClient.delete("/api/v1/instagram/messages/reaction",t,{channelToken:e.channelToken,recipientId:e.recipientId,messageId:e.messageId})}async sendQuickReplies(e,t){return this.httpClient.post("/api/v1/instagram/messages/quick-replies",{channelToken:e.channelToken,recipientId:e.recipientId,message:e.message,quickReplies:e.quickReplies},t)}async sendGenericTemplate(e,t){return this.httpClient.post("/api/v1/instagram/messages/generic-template",{channelToken:e.channelToken,recipientId:e.recipientId,elements:e.elements},t)}async sendButtonTemplate(e,t){return this.httpClient.post("/api/v1/instagram/messages/button-template",{channelToken:e.channelToken,recipientId:e.recipientId,text:e.text,buttons:e.buttons},t)}async sendSenderAction(e,t){return this.httpClient.post("/api/v1/instagram/messages/sender-action",{channelToken:e.channelToken,recipientId:e.recipientId,action:e.action},t)}async getUserProfile(e,t){return this.httpClient.post("/api/v1/instagram/user-profile",{channelToken:e.channelToken,userId:e.userId},t)}async listPosts(e,t){return this.httpClient.post("/api/v1/instagram/posts",{channelToken:e.channelToken,userId:e.userId,limit:e.limit},t)}async getBusinessProfile(e,t){return this.httpClient.post("/api/v1/instagram/business-profile",{channelToken:e.channelToken},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/instagram/download-media",{channelToken:e.channelToken,url:e.url},t)}async createMediaContainer(e,t){return this.httpClient.post("/api/v1/instagram/media",{channelToken:e.channelToken,image_url:e.image_url,video_url:e.video_url,media_type:e.media_type,caption:e.caption,is_carousel_item:e.is_carousel_item,children:e.children,upload_type:e.upload_type,trial_params:e.trial_params,alt_text:e.alt_text,location_id:e.location_id,product_tags:e.product_tags,user_tags:e.user_tags},t)}async publishMedia(e,t){return this.httpClient.post("/api/v1/instagram/media_publish",{channelToken:e.channelToken,creation_id:e.creation_id},t)}async getContainerStatus(e,t){return this.httpClient.post(`/api/v1/instagram/media/${e.container_id}/status`,{channelToken:e.channelToken},t)}async getPublishingLimit(e,t){return this.httpClient.post("/api/v1/instagram/content_publishing_limit",{channelToken:e.channelToken},t)}async uploadVideo(e,t){return this.httpClient.post("/api/v1/instagram/upload",{channelToken:e.channelToken,container_id:e.container_id,file_url:e.file_url,offset:e.offset,file_size:e.file_size},t)}};var k=class{constructor(e){this.httpClient=new l(e),this.auth=new d(this.httpClient),this.channels=new c(this.httpClient),this.integrations=new h(this.httpClient),this.whatsapp=new p(this.httpClient),this.telegram=new g(this.httpClient),this.webchat=new u(this.httpClient),this.facebook=new m(this.httpClient),this.instagram=new T(this.httpClient);}},K=k;
|
|
6
|
+
var I="https://api.oficialapi.com.br",l=class{constructor(e){this.config={clientId:e.clientId,clientSecret:e.clientSecret,timeout:e.timeout||3e4,maxRetries:e.maxRetries||3,retryDelay:e.retryDelay||1e3,headers:e.headers||{}},this.axiosInstance=P__default.default.create({baseURL:I,timeout:this.config.timeout,headers:{"Content-Type":"application/json",...this.config.headers}}),this.setupInterceptors();}setupInterceptors(){this.axiosInstance.interceptors.request.use(e=>{if(e.url?.includes("/auth/token"))return e;let t=e;return t.accessToken&&e.headers&&(e.headers.Authorization=`Bearer ${t.accessToken}`),e},e=>Promise.reject(e)),this.axiosInstance.interceptors.response.use(e=>e,async e=>{let t=e.config;if(!t)return Promise.reject(this.formatError(e));if((!e.response||e.response.status>=500&&e.response.status<600)&&(!t._retryCount||t._retryCount<this.config.maxRetries)){t._retryCount=(t._retryCount||0)+1;let s=this.config.retryDelay*t._retryCount;return await new Promise(i=>setTimeout(i,s)),this.axiosInstance(t)}return Promise.reject(this.formatError(e))});}formatError(e){if(e.response){let t=e.response.data,n=t?.error?.message||t?.message||e.message,s=t?.error?.details||[],i=new Error(n);return i.status=e.response.status,i.data=e.response.data,i.details=s,i}return e.request?new Error("Erro de conex\xE3o com a API. Verifique sua conex\xE3o com a internet."):e}async get(e,t,n){let s={...n,accessToken:t};return (await this.axiosInstance.get(e,s)).data}async post(e,t,n,s){let i={...s,accessToken:n};return (await this.axiosInstance.post(e,t,i)).data}async put(e,t,n,s){let i={...s,accessToken:n};return (await this.axiosInstance.put(e,t,i)).data}async delete(e,t,n,s){let i={...s,accessToken:t,data:n};return (await this.axiosInstance.delete(e,i)).data}async upload(e,t,n,s="file",i){let o=new FormData;if(t instanceof Buffer){let y=new Blob([t]);o.append(s,y);}else o.append(s,t);i&&Object.entries(i).forEach(([y,r])=>{r!=null&&o.append(y,typeof r=="string"?r:JSON.stringify(r));});let C={headers:{"Content-Type":"multipart/form-data"},accessToken:n};return (await this.axiosInstance.post(e,o,C)).data}};var d=class{constructor(e){this.httpClient=e;}async getToken(e,t){let n=await this.httpClient.post("/api/v1/auth/token",{client_id:e,client_secret:t});if(!n.success||!n.data)throw new Error(n.error?.message||"Falha ao obter token");return n.data}};var c=class{constructor(e){this.httpClient=e;}async list(e){let t=await this.httpClient.get("/api/v1/channels",e);if(!t.success||!t.data)throw new Error(t.error?.message||"Falha ao listar canais");return Array.isArray(t.data)?t.data:[t.data]}};var h=class{constructor(e){this.httpClient=e;}async createWebhook(e,t){let n=await this.httpClient.post("/api/v1/integrations",{url:e.url,expiresInDays:e.expiresInDays},t);if(!n.success||!n.data)throw new Error(n.error?.message||"Falha ao criar webhook");return n.data}};var p=class{constructor(e){this.httpClient=e;}async sendText(e,t){return this.httpClient.post("/api/v1/whatsapp/send-message",{channelToken:e.channelToken,sender:e.sender,messageText:e.messageText},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/whatsapp/send-media",{channelToken:e.channelToken,sender:e.sender,fileUrl:e.fileUrl,type:e.type,caption:e.caption,...e.fileName&&{fileName:e.fileName}},t)}async sendTemplate(e,t){return this.httpClient.post("/api/v1/whatsapp/send-template",{channelToken:e.channelToken,sender:e.sender,templateName:e.templateName,languageCode:e.languageCode,components:e.components},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/whatsapp/send-buttons",{channelToken:e.channelToken,sender:e.sender,text:e.text,buttons:e.buttons,...e.media&&{media:e.media}},t)}async sendList(e,t){return this.httpClient.post("/api/v1/whatsapp/send-list",{channelToken:e.channelToken,sender:e.sender,headerText:e.headerText,bodyText:e.bodyText,buttonText:e.buttonText,sections:e.sections,...e.footerText&&{footerText:e.footerText}},t)}async replyMessage(e,t){return this.httpClient.post("/api/v1/whatsapp/reply-message",{channelToken:e.channelToken,sender:e.sender,messageText:e.messageText,...e.replyMessageId&&{replyMessageId:e.replyMessageId},...e.preview_url!==void 0&&{preview_url:e.preview_url}},t)}async reactMessage(e,t){return this.httpClient.post("/api/v1/whatsapp/react-message",{channelToken:e.channelToken,sender:e.sender,emoji:e.emoji,...e.message_id&&{message_id:e.message_id}},t)}async createTemplate(e,t){return this.httpClient.post("/api/v1/whatsapp/create-template",{channelToken:e.channelToken,name:e.name,language:e.language,category:e.category,components:e.components},t)}async listTemplates(e,t){return this.httpClient.get(`/api/v1/whatsapp/templates?channelToken=${encodeURIComponent(e)}`,t)}async getTemplate(e,t,n){return this.httpClient.get(`/api/v1/whatsapp/templates/${t}?channelToken=${encodeURIComponent(e)}`,n)}async uploadMedia(e,t){return this.httpClient.upload("/api/v1/whatsapp/upload-media",e.file,t,"file",{channelToken:e.channelToken,mediaType:e.mediaType,...e.filename&&{filename:e.filename}})}async sendOrderDetails(e,t){return this.httpClient.post("/api/v1/whatsapp/send-order-details",{channelToken:e.channelToken,sender:e.sender,...e.headerText&&{headerText:e.headerText},bodyText:e.bodyText,...e.footerText&&{footerText:e.footerText},reference_id:e.reference_id,type:e.type,currency:e.currency,total_amount:e.total_amount,order:e.order,...e.payment_settings&&{payment_settings:e.payment_settings}},t)}async sendOrderStatus(e,t){return this.httpClient.post("/api/v1/whatsapp/send-order-status",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,...e.footerText&&{footerText:e.footerText},reference_id:e.reference_id,order_status:e.order_status,...e.status_description&&{status_description:e.status_description},...e.payment_status&&{payment_status:e.payment_status},...e.payment_timestamp!==void 0&&{payment_timestamp:e.payment_timestamp}},t)}async sendAudio(e,t){return this.httpClient.post("/api/v1/whatsapp/send-audio",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId,...e.voice!==void 0&&{voice:e.voice}},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/whatsapp/send-sticker",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId},t)}async sendVideo(e,t){return this.httpClient.post("/api/v1/whatsapp/send-video",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId,...e.caption&&{caption:e.caption}},t)}async sendDocument(e,t){return this.httpClient.post("/api/v1/whatsapp/send-document",{channelToken:e.channelToken,sender:e.sender,mediaId:e.mediaId,...e.filename&&{filename:e.filename},...e.caption&&{caption:e.caption}},t)}async sendContact(e,t){return this.httpClient.post("/api/v1/whatsapp/send-contact",{channelToken:e.channelToken,sender:e.sender,contacts:e.contacts},t)}async sendLocation(e,t){return this.httpClient.post("/api/v1/whatsapp/send-location",{channelToken:e.channelToken,sender:e.sender,latitude:e.latitude,longitude:e.longitude,name:e.name,address:e.address},t)}async sendLocationRequest(e,t){return this.httpClient.post("/api/v1/whatsapp/send-location-request",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,...e.headerText&&{headerText:e.headerText},...e.footerText&&{footerText:e.footerText}},t)}async sendCtaUrl(e,t){return this.httpClient.post("/api/v1/whatsapp/send-cta-url",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,buttonText:e.buttonText,url:e.url,...e.header&&{header:e.header},...e.footerText&&{footerText:e.footerText}},t)}async sendMediaCarousel(e,t){return this.httpClient.post("/api/v1/whatsapp/send-media-carousel",{channelToken:e.channelToken,sender:e.sender,bodyText:e.bodyText,cards:e.cards},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/whatsapp/download-media",{channelToken:e.channelToken,url:e.url},t)}};var g=class{constructor(e){this.httpClient=e;}async sendMessage(e,t){return this.httpClient.post("/api/v1/telegram/send-message",{channelToken:e.channelToken,chatId:e.chatId,text:e.text,parseMode:e.parseMode,replyToMessageId:e.replyToMessageId,disableNotification:e.disableNotification},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/telegram/send-media",{channelToken:e.channelToken,chatId:e.chatId,fileUrl:e.fileUrl,type:e.type,caption:e.caption,parseMode:e.parseMode,replyToMessageId:e.replyToMessageId},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/telegram/send-buttons",{channelToken:e.channelToken,chatId:e.chatId,text:e.text,buttons:e.buttons,parseMode:e.parseMode},t)}async sendLocation(e,t){return this.httpClient.post("/api/v1/telegram/send-location",{channelToken:e.channelToken,chatId:e.chatId,latitude:e.latitude,longitude:e.longitude,livePeriod:e.livePeriod},t)}async sendContact(e,t){return this.httpClient.post("/api/v1/telegram/send-contact",{channelToken:e.channelToken,chatId:e.chatId,phoneNumber:e.phoneNumber,firstName:e.firstName,lastName:e.lastName,vcard:e.vcard},t)}async sendPoll(e,t){return this.httpClient.post("/api/v1/telegram/send-poll",{channelToken:e.channelToken,chatId:e.chatId,question:e.question,options:e.options,isAnonymous:e.isAnonymous,type:e.type,correctOptionId:e.correctOptionId},t)}async sendVenue(e,t){return this.httpClient.post("/api/v1/telegram/send-venue",{channelToken:e.channelToken,chatId:e.chatId,latitude:e.latitude,longitude:e.longitude,title:e.title,address:e.address,foursquareId:e.foursquareId},t)}async sendDice(e,t){return this.httpClient.post("/api/v1/telegram/send-dice",{channelToken:e.channelToken,chatId:e.chatId,emoji:e.emoji},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/telegram/send-sticker",{channelToken:e.channelToken,chatId:e.chatId,stickerUrl:e.stickerUrl},t)}async sendVoice(e,t){return this.httpClient.post("/api/v1/telegram/send-voice",{channelToken:e.channelToken,chatId:e.chatId,voiceUrl:e.voiceUrl,caption:e.caption,duration:e.duration},t)}async sendVideoNote(e,t){return this.httpClient.post("/api/v1/telegram/send-video-note",{channelToken:e.channelToken,chatId:e.chatId,videoNoteUrl:e.videoNoteUrl,duration:e.duration,length:e.length},t)}async sendMediaGroup(e,t){return this.httpClient.post("/api/v1/telegram/send-media-group",{channelToken:e.channelToken,chatId:e.chatId,media:e.media},t)}async sendReplyKeyboard(e,t){return this.httpClient.post("/api/v1/telegram/send-reply-keyboard",{channelToken:e.channelToken,chatId:e.chatId,text:e.text,keyboard:e.keyboard,resizeKeyboard:e.resizeKeyboard,oneTimeKeyboard:e.oneTimeKeyboard},t)}async editMessage(e,t){return this.httpClient.post("/api/v1/telegram/edit-message",{channelToken:e.channelToken,chatId:e.chatId,messageId:e.messageId,text:e.text,parseMode:e.parseMode},t)}async deleteMessage(e,t){return this.httpClient.post("/api/v1/telegram/delete-message",{channelToken:e.channelToken,chatId:e.chatId,messageId:e.messageId},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/telegram/download-media",{channelToken:e.channelToken,fileId:e.fileId},t)}};var u=class{constructor(e){this.httpClient=e;}async sendText(e,t){return this.httpClient.post("/api/v1/webchat/send-text",{channelToken:e.channelToken,chatId:e.chatId,type:"text",content:{text:e.messageText,typingTime:e.typingTime},typing:e.typing},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/webchat/send-media",{channelToken:e.channelToken,chatId:e.chatId,type:e.type,content:{url:e.fileUrl,caption:e.caption,typingTime:e.typingTime},typing:e.typing},t)}async sendCarousel(e,t){return this.httpClient.post("/api/v1/webchat/send-carousel",{channelToken:e.channelToken,chatId:e.chatId,type:"carousel",content:{cards:e.cards.map(n=>({title:n.title,subtitle:n.subtitle,imageUrl:n.imageUrl,buttons:n.buttons?.map(s=>({id:s.id||`btn_${Date.now()}_${Math.random()}`,text:s.text,type:s.type,value:s.value,url:s.url}))})),typingTime:e.typingTime},typing:e.typing},t)}async sendForm(e,t){return this.httpClient.post("/api/v1/webchat/send-form",{channelToken:e.channelToken,chatId:e.chatId,type:"form",content:{id:e.id,title:e.title,submitText:e.submitButtonText,fields:e.fields.map(n=>({id:n.id||n.name,type:n.type,label:n.label,placeholder:n.placeholder,required:n.required,options:n.options})),typingTime:e.typingTime},typing:e.typing},t)}async sendQuickReplies(e,t){return this.httpClient.post("/api/v1/webchat/send-quick-replies",{channelToken:e.channelToken,chatId:e.chatId,type:"quickReplies",content:{text:e.messageText,quickReplies:e.quickReplies.map(n=>({id:n.id||`qr_${Date.now()}_${Math.random()}`,text:n.text,value:n.value})),typingTime:e.typingTime},typing:e.typing},t)}async sendCard(e,t){return this.httpClient.post("/api/v1/webchat/send-card",{channelToken:e.channelToken,chatId:e.chatId,type:"card",content:{title:e.title,subtitle:e.description,imageUrl:e.imageUrl,buttons:e.buttons?.map(n=>({id:n.id||`btn_${Date.now()}_${Math.random()}`,text:n.text,type:n.type,value:n.value,url:n.url})),typingTime:e.typingTime},typing:e.typing},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/webchat/send-buttons",{channelToken:e.channelToken,chatId:e.chatId,type:"buttons",content:{text:e.messageText,buttons:e.buttons.map(n=>({id:n.id||`btn_${Date.now()}_${Math.random()}`,text:n.text,type:n.type,value:n.value,url:n.url})),typingTime:e.typingTime},typing:e.typing},t)}};var m=class{constructor(e){this.httpClient=e;}async listPosts(e,t){return this.httpClient.post("/api/v1/facebook/list-posts",{channelToken:e.channelToken,channelType:e.channelType,limit:e.limit,after:e.after,type:e.type,includeComments:e.includeComments,includeReactions:e.includeReactions},t)}async listComments(e,t){return this.httpClient.post("/api/v1/facebook/list-comments",{channelToken:e.channelToken,channelType:e.channelType,postId:e.postId,limit:e.limit,after:e.after,order:e.order,filterUnanswered:e.filterUnanswered,includeReplies:e.includeReplies},t)}async createPost(e,t){return this.httpClient.post("/api/v1/facebook/create-post",{channelToken:e.channelToken,channelType:e.channelType,messageText:e.message,mediaUrl:e.link,mediaType:e.mediaType},t)}async replyComment(e,t){return this.httpClient.post("/api/v1/facebook/reply-comment",{channelToken:e.channelToken,commentId:e.commentId,message:e.message},t)}async deleteComment(e,t){return this.httpClient.post("/api/v1/facebook/delete-comment",{channelToken:e.channelToken,commentId:e.commentId},t)}async sendText(e,t){return this.httpClient.post("/api/v1/facebook/send-text",{channelToken:e.channelToken,recipientId:e.recipientId,message:e.message},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/facebook/send-media",{channelToken:e.channelToken,recipientId:e.recipientId,fileUrl:e.fileUrl,type:e.type,caption:e.caption},t)}async sendButtons(e,t){return this.httpClient.post("/api/v1/facebook/send-buttons",{channelToken:e.channelToken,recipientId:e.recipientId,message:e.message,buttons:e.buttons},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/facebook/send-sticker",{channelToken:e.channelToken,recipientId:e.recipientId,stickerId:e.stickerId},t)}async replyMessage(e,t){return this.httpClient.post("/api/v1/facebook/reply-message",{channelToken:e.channelToken,messageId:e.messageId,message:e.message},t)}async replyMedia(e,t){return this.httpClient.post("/api/v1/facebook/reply-media",{channelToken:e.channelToken,messageId:e.messageId,fileUrl:e.fileUrl,type:e.type,caption:e.caption},t)}async sharePost(e,t){return this.httpClient.post("/api/v1/facebook/share-post",{channelToken:e.channelToken,mediaId:e.mediaId,recipientId:e.recipientId},t)}async getUserProfile(e,t){return this.httpClient.post("/api/v1/facebook/user-profile",{channelToken:e.channelToken,userId:e.userId},t)}async getPageProfile(e,t){return this.httpClient.post("/api/v1/facebook/page-profile",{channelToken:e.channelToken,pageId:e.pageId},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/facebook/download-media",{channelToken:e.channelToken,url:e.url},t)}};var T=class{constructor(e){this.httpClient=e;}async sendPrivateReply(e,t){return this.httpClient.post("/api/v1/instagram/private-reply",{channelToken:e.channelToken,commentId:e.commentId,message:e.message},t)}async sendText(e,t){return this.httpClient.post("/api/v1/instagram/messages/text",{channelToken:e.channelToken,recipientId:e.recipientId,text:e.text,...e.tags&&{tags:e.tags}},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/instagram/messages/media",{channelToken:e.channelToken,recipientId:e.recipientId,attachment:e.attachment,...e.tags&&{tags:e.tags}},t)}async sendImages(e,t){return this.httpClient.post("/api/v1/instagram/messages/images",{channelToken:e.channelToken,recipientId:e.recipientId,images:e.images},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/instagram/messages/sticker",{channelToken:e.channelToken,recipientId:e.recipientId,stickerType:e.stickerType},t)}async reactMessage(e,t){return this.httpClient.post("/api/v1/instagram/messages/reaction",{channelToken:e.channelToken,messageId:e.messageId,reactionType:e.reactionType},t)}async removeReaction(e,t){return this.httpClient.delete("/api/v1/instagram/messages/reaction",t,{channelToken:e.channelToken,recipientId:e.recipientId,messageId:e.messageId})}async sendQuickReplies(e,t){return this.httpClient.post("/api/v1/instagram/messages/quick-replies",{channelToken:e.channelToken,recipientId:e.recipientId,message:e.message,quickReplies:e.quickReplies},t)}async sendGenericTemplate(e,t){return this.httpClient.post("/api/v1/instagram/messages/generic-template",{channelToken:e.channelToken,recipientId:e.recipientId,elements:e.elements},t)}async sendButtonTemplate(e,t){return this.httpClient.post("/api/v1/instagram/messages/button-template",{channelToken:e.channelToken,recipientId:e.recipientId,text:e.text,buttons:e.buttons},t)}async sendSenderAction(e,t){return this.httpClient.post("/api/v1/instagram/messages/sender-action",{channelToken:e.channelToken,recipientId:e.recipientId,action:e.action},t)}async getUserProfile(e,t){return this.httpClient.post("/api/v1/instagram/user-profile",{channelToken:e.channelToken,userId:e.userId},t)}async listPosts(e,t){return this.httpClient.post("/api/v1/instagram/posts",{channelToken:e.channelToken,userId:e.userId,limit:e.limit},t)}async getBusinessProfile(e,t){return this.httpClient.post("/api/v1/instagram/business-profile",{channelToken:e.channelToken},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/instagram/download-media",{channelToken:e.channelToken,url:e.url},t)}async createMediaContainer(e,t){return this.httpClient.post("/api/v1/instagram/media",{channelToken:e.channelToken,image_url:e.image_url,video_url:e.video_url,media_type:e.media_type,caption:e.caption,is_carousel_item:e.is_carousel_item,children:e.children,upload_type:e.upload_type,trial_params:e.trial_params,alt_text:e.alt_text,location_id:e.location_id,product_tags:e.product_tags,user_tags:e.user_tags},t)}async publishMedia(e,t){return this.httpClient.post("/api/v1/instagram/media_publish",{channelToken:e.channelToken,creation_id:e.creation_id},t)}async getContainerStatus(e,t){return this.httpClient.post(`/api/v1/instagram/media/${e.container_id}/status`,{channelToken:e.channelToken},t)}async getPublishingLimit(e,t){return this.httpClient.post("/api/v1/instagram/content_publishing_limit",{channelToken:e.channelToken},t)}async uploadVideo(e,t){return this.httpClient.post("/api/v1/instagram/upload",{channelToken:e.channelToken,container_id:e.container_id,file_url:e.file_url,offset:e.offset,file_size:e.file_size},t)}};var k=class{constructor(e){this.httpClient=new l(e),this.auth=new d(this.httpClient),this.channels=new c(this.httpClient),this.integrations=new h(this.httpClient),this.whatsapp=new p(this.httpClient),this.telegram=new g(this.httpClient),this.webchat=new u(this.httpClient),this.facebook=new m(this.httpClient),this.instagram=new T(this.httpClient);}},K=k;
|
|
7
7
|
exports.OficialAPISDK=k;exports.default=K;//# sourceMappingURL=index.js.map
|
|
8
8
|
//# sourceMappingURL=index.js.map
|