@oficialapi/sdk 9.0.3 → 9.0.5

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.ts CHANGED
@@ -36,7 +36,7 @@ interface ApiResponse<T = any> {
36
36
  }
37
37
  interface Channel {
38
38
  id: number;
39
- token: string;
39
+ channelToken: string;
40
40
  nome: string;
41
41
  channel: 'whatsapp' | 'facebook' | 'instagram' | 'webchat' | 'email' | 'telegram';
42
42
  status: boolean;
@@ -48,12 +48,12 @@ interface Channel {
48
48
  updatedAt: string;
49
49
  }
50
50
  interface SendWhatsAppTextParams {
51
- token: string;
51
+ channelToken: string;
52
52
  sender: string;
53
53
  messageText: string;
54
54
  }
55
55
  interface SendWhatsAppMediaParams {
56
- token: string;
56
+ channelToken: string;
57
57
  sender: string;
58
58
  fileUrl: string;
59
59
  type: 'image' | 'video' | 'audio' | 'document';
@@ -61,7 +61,7 @@ interface SendWhatsAppMediaParams {
61
61
  fileName?: string;
62
62
  }
63
63
  interface SendWhatsAppTemplateParams {
64
- token: string;
64
+ channelToken: string;
65
65
  sender: string;
66
66
  templateName: string;
67
67
  languageCode: string;
@@ -93,7 +93,7 @@ interface SendWhatsAppTemplateParams {
93
93
  }>;
94
94
  }
95
95
  interface SendWhatsAppButtonsParams {
96
- token: string;
96
+ channelToken: string;
97
97
  sender: string;
98
98
  text: string;
99
99
  buttons: Array<{
@@ -106,7 +106,7 @@ interface SendWhatsAppButtonsParams {
106
106
  };
107
107
  }
108
108
  interface SendWhatsAppListParams {
109
- token: string;
109
+ channelToken: string;
110
110
  sender: string;
111
111
  headerText: string;
112
112
  bodyText: string;
@@ -122,20 +122,20 @@ interface SendWhatsAppListParams {
122
122
  }>;
123
123
  }
124
124
  interface ReplyWhatsAppParams {
125
- token: string;
125
+ channelToken: string;
126
126
  sender: string;
127
127
  messageText: string;
128
128
  replyMessageId?: string;
129
129
  preview_url?: boolean;
130
130
  }
131
131
  interface ReactWhatsAppParams {
132
- token: string;
132
+ channelToken: string;
133
133
  sender: string;
134
134
  emoji: string;
135
135
  message_id?: string;
136
136
  }
137
137
  interface CreateTemplateParams {
138
- token: string;
138
+ channelToken: string;
139
139
  name: string;
140
140
  language: string;
141
141
  category: 'MARKETING' | 'UTILITY' | 'AUTHENTICATION';
@@ -156,13 +156,13 @@ interface CreateTemplateParams {
156
156
  }>;
157
157
  }
158
158
  interface UploadMediaParams {
159
- token: string;
159
+ channelToken: string;
160
160
  file: File | Blob | Buffer;
161
161
  mediaType: 'image' | 'video' | 'document';
162
162
  filename?: string;
163
163
  }
164
164
  interface SendOrderDetailsParams {
165
- token: string;
165
+ channelToken: string;
166
166
  sender: string;
167
167
  headerText?: string;
168
168
  bodyText: string;
@@ -240,7 +240,7 @@ interface SendOrderDetailsParams {
240
240
  }>;
241
241
  }
242
242
  interface SendOrderStatusParams {
243
- token: string;
243
+ channelToken: string;
244
244
  sender: string;
245
245
  bodyText: string;
246
246
  footerText?: string;
@@ -251,31 +251,31 @@ interface SendOrderStatusParams {
251
251
  payment_timestamp?: number;
252
252
  }
253
253
  interface SendWhatsAppAudioParams {
254
- token: string;
254
+ channelToken: string;
255
255
  sender: string;
256
256
  mediaId: string;
257
257
  voice?: boolean;
258
258
  }
259
259
  interface SendWhatsAppStickerParams {
260
- token: string;
260
+ channelToken: string;
261
261
  sender: string;
262
262
  mediaId: string;
263
263
  }
264
264
  interface SendWhatsAppVideoParams {
265
- token: string;
265
+ channelToken: string;
266
266
  sender: string;
267
267
  mediaId: string;
268
268
  caption?: string;
269
269
  }
270
270
  interface SendWhatsAppDocumentParams {
271
- token: string;
271
+ channelToken: string;
272
272
  sender: string;
273
273
  mediaId: string;
274
274
  filename?: string;
275
275
  caption?: string;
276
276
  }
277
277
  interface SendWhatsAppContactParams {
278
- token: string;
278
+ channelToken: string;
279
279
  sender: string;
280
280
  contacts: Array<{
281
281
  name: {
@@ -317,7 +317,7 @@ interface SendWhatsAppContactParams {
317
317
  }>;
318
318
  }
319
319
  interface SendWhatsAppLocationParams {
320
- token: string;
320
+ channelToken: string;
321
321
  sender: string;
322
322
  latitude: number;
323
323
  longitude: number;
@@ -325,14 +325,14 @@ interface SendWhatsAppLocationParams {
325
325
  address?: string;
326
326
  }
327
327
  interface SendWhatsAppLocationRequestParams {
328
- token: string;
328
+ channelToken: string;
329
329
  sender: string;
330
330
  bodyText: string;
331
331
  headerText?: string;
332
332
  footerText?: string;
333
333
  }
334
334
  interface SendWhatsAppCtaUrlParams {
335
- token: string;
335
+ channelToken: string;
336
336
  sender: string;
337
337
  bodyText: string;
338
338
  buttonText: string;
@@ -345,7 +345,7 @@ interface SendWhatsAppCtaUrlParams {
345
345
  footerText?: string;
346
346
  }
347
347
  interface SendWhatsAppMediaCarouselParams {
348
- token: string;
348
+ channelToken: string;
349
349
  sender: string;
350
350
  bodyText: string;
351
351
  cards: Array<{
@@ -358,11 +358,11 @@ interface SendWhatsAppMediaCarouselParams {
358
358
  }>;
359
359
  }
360
360
  interface DownloadWhatsAppMediaParams {
361
- token: string;
361
+ channelToken: string;
362
362
  url: string;
363
363
  }
364
364
  interface SendTelegramTextParams {
365
- token: string;
365
+ channelToken: string;
366
366
  chatId: string | number;
367
367
  text: string;
368
368
  parseMode?: 'HTML' | 'Markdown' | 'MarkdownV2';
@@ -370,7 +370,7 @@ interface SendTelegramTextParams {
370
370
  disableNotification?: boolean;
371
371
  }
372
372
  interface SendTelegramMediaParams {
373
- token: string;
373
+ channelToken: string;
374
374
  chatId: string | number;
375
375
  fileUrl: string;
376
376
  type: 'photo' | 'video' | 'audio' | 'document' | 'voice';
@@ -379,7 +379,7 @@ interface SendTelegramMediaParams {
379
379
  replyToMessageId?: number;
380
380
  }
381
381
  interface SendTelegramButtonsParams {
382
- token: string;
382
+ channelToken: string;
383
383
  chatId: string | number;
384
384
  text: string;
385
385
  buttons: Array<Array<{
@@ -393,14 +393,14 @@ interface SendTelegramButtonsParams {
393
393
  parseMode?: 'HTML' | 'Markdown' | 'MarkdownV2';
394
394
  }
395
395
  interface SendTelegramLocationParams {
396
- token: string;
396
+ channelToken: string;
397
397
  chatId: string | number;
398
398
  latitude: number;
399
399
  longitude: number;
400
400
  livePeriod?: number;
401
401
  }
402
402
  interface SendTelegramContactParams {
403
- token: string;
403
+ channelToken: string;
404
404
  chatId: string | number;
405
405
  phoneNumber: string;
406
406
  firstName: string;
@@ -408,7 +408,7 @@ interface SendTelegramContactParams {
408
408
  vcard?: string;
409
409
  }
410
410
  interface SendTelegramPollParams {
411
- token: string;
411
+ channelToken: string;
412
412
  chatId: string | number;
413
413
  question: string;
414
414
  options: string[];
@@ -417,7 +417,7 @@ interface SendTelegramPollParams {
417
417
  correctOptionId?: number;
418
418
  }
419
419
  interface SendTelegramVenueParams {
420
- token: string;
420
+ channelToken: string;
421
421
  chatId: string | number;
422
422
  latitude: number;
423
423
  longitude: number;
@@ -426,31 +426,31 @@ interface SendTelegramVenueParams {
426
426
  foursquareId?: string;
427
427
  }
428
428
  interface SendTelegramDiceParams {
429
- token: string;
429
+ channelToken: string;
430
430
  chatId: string | number;
431
431
  emoji?: '🎲' | '🎯' | '🏀' | '⚽' | '🎳' | '🎰';
432
432
  }
433
433
  interface SendTelegramStickerParams {
434
- token: string;
434
+ channelToken: string;
435
435
  chatId: string | number;
436
436
  stickerUrl: string;
437
437
  }
438
438
  interface SendTelegramVoiceParams {
439
- token: string;
439
+ channelToken: string;
440
440
  chatId: string | number;
441
441
  voiceUrl: string;
442
442
  caption?: string;
443
443
  duration?: number;
444
444
  }
445
445
  interface SendTelegramVideoNoteParams {
446
- token: string;
446
+ channelToken: string;
447
447
  chatId: string | number;
448
448
  videoNoteUrl: string;
449
449
  duration?: number;
450
450
  length?: number;
451
451
  }
452
452
  interface SendTelegramMediaGroupParams {
453
- token: string;
453
+ channelToken: string;
454
454
  chatId: string | number;
455
455
  media: Array<{
456
456
  type: 'photo' | 'video';
@@ -459,7 +459,7 @@ interface SendTelegramMediaGroupParams {
459
459
  }>;
460
460
  }
461
461
  interface SendTelegramReplyKeyboardParams {
462
- token: string;
462
+ channelToken: string;
463
463
  chatId: string | number;
464
464
  text: string;
465
465
  keyboard: Array<Array<{
@@ -469,19 +469,19 @@ interface SendTelegramReplyKeyboardParams {
469
469
  oneTimeKeyboard?: boolean;
470
470
  }
471
471
  interface EditTelegramMessageParams {
472
- token: string;
472
+ channelToken: string;
473
473
  chatId: string | number;
474
474
  messageId: number;
475
475
  text: string;
476
476
  parseMode?: 'HTML' | 'Markdown' | 'MarkdownV2';
477
477
  }
478
478
  interface DeleteTelegramMessageParams {
479
- token: string;
479
+ channelToken: string;
480
480
  chatId: string | number;
481
481
  messageId: number;
482
482
  }
483
483
  interface DownloadTelegramMediaParams {
484
- token: string;
484
+ channelToken: string;
485
485
  fileId: string;
486
486
  }
487
487
  interface SendWebChatTextParams {
@@ -582,44 +582,44 @@ interface SendWebChatButtonsParams {
582
582
  typingTime?: number;
583
583
  }
584
584
  interface ListPostsParams {
585
- token: string;
585
+ channelToken: string;
586
586
  pageId: string;
587
587
  limit?: number;
588
588
  }
589
589
  interface ListCommentsParams {
590
- token: string;
590
+ channelToken: string;
591
591
  postId: string;
592
592
  limit?: number;
593
593
  }
594
594
  interface CreatePostParams {
595
- token: string;
595
+ channelToken: string;
596
596
  pageId: string;
597
597
  message: string;
598
598
  link?: string;
599
599
  }
600
600
  interface ReplyCommentParams {
601
- token: string;
601
+ channelToken: string;
602
602
  commentId: string;
603
603
  message: string;
604
604
  }
605
605
  interface DeleteCommentParams {
606
- token: string;
606
+ channelToken: string;
607
607
  commentId: string;
608
608
  }
609
609
  interface SendFacebookTextParams {
610
- token: string;
610
+ channelToken: string;
611
611
  recipientId: string;
612
612
  message: string;
613
613
  }
614
614
  interface SendFacebookMediaParams {
615
- token: string;
615
+ channelToken: string;
616
616
  recipientId: string;
617
617
  fileUrl: string;
618
618
  type: 'image' | 'video' | 'audio' | 'file';
619
619
  caption?: string;
620
620
  }
621
621
  interface SendFacebookButtonsParams {
622
- token: string;
622
+ channelToken: string;
623
623
  recipientId: string;
624
624
  message: string;
625
625
  buttons: Array<{
@@ -630,58 +630,59 @@ interface SendFacebookButtonsParams {
630
630
  }>;
631
631
  }
632
632
  interface SendFacebookStickerParams {
633
- token: string;
633
+ channelToken: string;
634
634
  recipientId: string;
635
635
  stickerId: number;
636
636
  }
637
637
  interface ReplyFacebookMessageParams {
638
- token: string;
638
+ channelToken: string;
639
639
  messageId: string;
640
640
  message: string;
641
641
  }
642
642
  interface ReplyFacebookMediaParams {
643
- token: string;
643
+ channelToken: string;
644
644
  messageId: string;
645
645
  fileUrl: string;
646
646
  type: 'image' | 'video' | 'audio' | 'file';
647
647
  caption?: string;
648
648
  }
649
649
  interface SharePostParams {
650
- token: string;
650
+ channelToken: string;
651
651
  mediaId: string;
652
652
  recipientId: string;
653
653
  }
654
654
  interface GetFacebookUserProfileParams {
655
- token: string;
655
+ channelToken: string;
656
656
  userId: string;
657
657
  }
658
658
  interface GetFacebookPageProfileParams {
659
- token: string;
659
+ channelToken: string;
660
660
  pageId: string;
661
661
  }
662
662
  interface DownloadFacebookMediaParams {
663
- token: string;
663
+ channelToken: string;
664
664
  url: string;
665
665
  }
666
666
  interface SendInstagramPrivateReplyParams {
667
- token: string;
667
+ channelToken: string;
668
668
  commentId: string;
669
669
  message: string;
670
670
  }
671
671
  interface SendInstagramTextParams {
672
- token: string;
672
+ channelToken: string;
673
673
  recipientId: string;
674
- message: string;
674
+ text: string;
675
+ tags?: string[];
675
676
  }
676
677
  interface SendInstagramMediaParams {
677
- token: string;
678
+ channelToken: string;
678
679
  recipientId: string;
679
680
  fileUrl: string;
680
681
  type: 'image' | 'video' | 'audio' | 'file';
681
682
  caption?: string;
682
683
  }
683
684
  interface SendInstagramImagesParams {
684
- token: string;
685
+ channelToken: string;
685
686
  recipientId: string;
686
687
  images: Array<{
687
688
  url: string;
@@ -689,22 +690,22 @@ interface SendInstagramImagesParams {
689
690
  }>;
690
691
  }
691
692
  interface SendInstagramStickerParams {
692
- token: string;
693
+ channelToken: string;
693
694
  recipientId: string;
694
695
  stickerType: 'like' | 'heart';
695
696
  }
696
697
  interface ReactInstagramMessageParams {
697
- token: string;
698
+ channelToken: string;
698
699
  messageId: string;
699
700
  reactionType: 'like' | 'love' | 'wow' | 'haha' | 'sorry' | 'anger';
700
701
  }
701
702
  interface RemoveInstagramReactionParams {
702
- token: string;
703
+ channelToken: string;
703
704
  recipientId: string;
704
705
  messageId: string;
705
706
  }
706
707
  interface SendInstagramQuickRepliesParams {
707
- token: string;
708
+ channelToken: string;
708
709
  recipientId: string;
709
710
  message: string;
710
711
  quickReplies: Array<{
@@ -714,7 +715,7 @@ interface SendInstagramQuickRepliesParams {
714
715
  }>;
715
716
  }
716
717
  interface SendInstagramGenericTemplateParams {
717
- token: string;
718
+ channelToken: string;
718
719
  recipientId: string;
719
720
  elements: Array<{
720
721
  title: string;
@@ -729,7 +730,7 @@ interface SendInstagramGenericTemplateParams {
729
730
  }>;
730
731
  }
731
732
  interface SendInstagramButtonTemplateParams {
732
- token: string;
733
+ channelToken: string;
733
734
  recipientId: string;
734
735
  text: string;
735
736
  buttons: Array<{
@@ -740,30 +741,30 @@ interface SendInstagramButtonTemplateParams {
740
741
  }>;
741
742
  }
742
743
  interface SendInstagramSenderActionParams {
743
- token: string;
744
+ channelToken: string;
744
745
  recipientId: string;
745
746
  action: 'typing_on' | 'typing_off' | 'mark_seen';
746
747
  }
747
748
  interface GetInstagramUserProfileParams {
748
- token: string;
749
+ channelToken: string;
749
750
  userId: string;
750
751
  }
751
752
  interface ListInstagramPostsParams {
752
- token: string;
753
+ channelToken: string;
753
754
  userId?: string;
754
755
  limit?: number;
755
756
  }
756
757
  interface GetInstagramBusinessProfileParams {
757
- token: string;
758
+ channelToken: string;
758
759
  }
759
760
  interface DownloadInstagramMediaParams {
760
- token: string;
761
+ channelToken: string;
761
762
  url: string;
762
763
  }
763
764
  type InstagramPublishMediaType = 'IMAGE' | 'VIDEO' | 'REELS' | 'STORIES' | 'CAROUSEL';
764
765
  type GraduationStrategy = 'MANUAL' | 'SS_PERFORMANCE';
765
766
  interface CreateInstagramMediaContainerParams {
766
- token: string;
767
+ channelToken: string;
767
768
  image_url?: string;
768
769
  video_url?: string;
769
770
  media_type: InstagramPublishMediaType;
@@ -784,18 +785,18 @@ interface CreateInstagramMediaContainerParams {
784
785
  }>;
785
786
  }
786
787
  interface PublishInstagramMediaParams {
787
- token: string;
788
+ channelToken: string;
788
789
  creation_id: string;
789
790
  }
790
791
  interface GetInstagramContainerStatusParams {
791
- token: string;
792
+ channelToken: string;
792
793
  container_id: string;
793
794
  }
794
795
  interface GetInstagramPublishingLimitParams {
795
- token: string;
796
+ channelToken: string;
796
797
  }
797
798
  interface UploadInstagramVideoParams {
798
- token: string;
799
+ channelToken: string;
799
800
  container_id: string;
800
801
  file_url?: string;
801
802
  offset?: number;
@@ -953,14 +954,14 @@ declare class WhatsAppModule {
953
954
  * @param token Token do canal
954
955
  * @param accessToken Token de acesso do usuário
955
956
  */
956
- listTemplates(token: string, accessToken: string): Promise<ApiResponse<any>>;
957
+ listTemplates(channelToken: string, accessToken: string): Promise<ApiResponse<any>>;
957
958
  /**
958
959
  * Obtém detalhes de um template
959
- * @param token Token do canal
960
+ * @param channelToken Token do canal
960
961
  * @param templateId ID do template
961
962
  * @param accessToken Token de acesso do usuário
962
963
  */
963
- getTemplate(token: string, templateId: string, accessToken: string): Promise<ApiResponse<any>>;
964
+ getTemplate(channelToken: string, templateId: string, accessToken: string): Promise<ApiResponse<any>>;
964
965
  /**
965
966
  * Faz upload de mídia para templates
966
967
  * @param params Parâmetros do upload
@@ -1452,7 +1453,7 @@ declare class InstagramModule {
1452
1453
  *
1453
1454
  * // Enviar mensagem WhatsApp
1454
1455
  * const result = await sdk.whatsapp.sendText({
1455
- * token: 'sk_live_...',
1456
+ * channelToken: 'sk_live_...',
1456
1457
  * sender: '5511999999999',
1457
1458
  * messageText: 'Olá!'
1458
1459
  * });
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var I=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var I__default=/*#__PURE__*/_interopDefault(I);/**
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var P=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var P__default=/*#__PURE__*/_interopDefault(P);/**
2
2
  * OficialAPI SDK
3
3
  * @version 1.0.0
4
4
  * @license MIT
5
5
  */
6
- var T="https://api.oficialapi.com.br",d=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=I__default.default.create({baseURL:T,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 a=new FormData;if(t instanceof Buffer){let k=new Blob([t]);a.append(s,k);}else a.append(s,t);i&&Object.entries(i).forEach(([k,r])=>{r!=null&&a.append(k,typeof r=="string"?r:JSON.stringify(r));});let P={headers:{"Content-Type":"multipart/form-data"},accessToken:n};return (await this.axiosInstance.post(e,a,P)).data}};var l=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 p=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 h=class{constructor(e){this.httpClient=e;}async sendText(e,t){return this.httpClient.post("/api/v1/whatsapp/send-message",{token:e.token,sender:e.sender,messageText:e.messageText},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/whatsapp/send-media",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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?token=${encodeURIComponent(e)}`,t)}async getTemplate(e,t,n){return this.httpClient.get(`/api/v1/whatsapp/templates/${t}?token=${encodeURIComponent(e)}`,n)}async uploadMedia(e,t){return this.httpClient.upload("/api/v1/whatsapp/upload-media",e.file,t,"file",{token:e.token,mediaType:e.mediaType,...e.filename&&{filename:e.filename}})}async sendOrderDetails(e,t){return this.httpClient.post("/api/v1/whatsapp/send-order-details",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,sender:e.sender,mediaId:e.mediaId},t)}async sendVideo(e,t){return this.httpClient.post("/api/v1/whatsapp/send-video",{token:e.token,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",{token:e.token,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",{token:e.token,sender:e.sender,contacts:e.contacts},t)}async sendLocation(e,t){return this.httpClient.post("/api/v1/whatsapp/send-location",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,sender:e.sender,bodyText:e.bodyText,cards:e.cards},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/whatsapp/download-media",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,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",{token:e.token,chatId:e.chatId,emoji:e.emoji},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/telegram/send-sticker",{token:e.token,chatId:e.chatId,stickerUrl:e.stickerUrl},t)}async sendVoice(e,t){return this.httpClient.post("/api/v1/telegram/send-voice",{token:e.token,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",{token:e.token,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",{token:e.token,chatId:e.chatId,media:e.media},t)}async sendReplyKeyboard(e,t){return this.httpClient.post("/api/v1/telegram/send-reply-keyboard",{token:e.token,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",{token:e.token,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",{token:e.token,chatId:e.chatId,messageId:e.messageId},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/telegram/download-media",{token:e.token,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",{token:e.token,pageId:e.pageId,limit:e.limit},t)}async listComments(e,t){return this.httpClient.post("/api/v1/facebook/list-comments",{token:e.token,postId:e.postId,limit:e.limit},t)}async createPost(e,t){return this.httpClient.post("/api/v1/facebook/create-post",{token:e.token,pageId:e.pageId,message:e.message,link:e.link},t)}async replyComment(e,t){return this.httpClient.post("/api/v1/facebook/reply-comment",{token:e.token,commentId:e.commentId,message:e.message},t)}async deleteComment(e,t){return this.httpClient.post("/api/v1/facebook/delete-comment",{token:e.token,commentId:e.commentId},t)}async sendText(e,t){return this.httpClient.post("/api/v1/facebook/send-text",{token:e.token,recipientId:e.recipientId,message:e.message},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/facebook/send-media",{token:e.token,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",{token:e.token,recipientId:e.recipientId,message:e.message,buttons:e.buttons},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/facebook/send-sticker",{token:e.token,recipientId:e.recipientId,stickerId:e.stickerId},t)}async replyMessage(e,t){return this.httpClient.post("/api/v1/facebook/reply-message",{token:e.token,messageId:e.messageId,message:e.message},t)}async replyMedia(e,t){return this.httpClient.post("/api/v1/facebook/reply-media",{token:e.token,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",{token:e.token,mediaId:e.mediaId,recipientId:e.recipientId},t)}async getUserProfile(e,t){return this.httpClient.post("/api/v1/facebook/user-profile",{token:e.token,userId:e.userId},t)}async getPageProfile(e,t){return this.httpClient.post("/api/v1/facebook/page-profile",{token:e.token,pageId:e.pageId},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/facebook/download-media",{token:e.token,url:e.url},t)}};var y=class{constructor(e){this.httpClient=e;}async sendPrivateReply(e,t){return this.httpClient.post("/api/v1/instagram/private-reply",{token:e.token,commentId:e.commentId,message:e.message},t)}async sendText(e,t){return this.httpClient.post("/api/v1/instagram/messages/text",{token:e.token,recipientId:e.recipientId,message:e.message},t)}async sendMedia(e,t){return this.httpClient.post("/api/v1/instagram/messages/media",{token:e.token,recipientId:e.recipientId,fileUrl:e.fileUrl,type:e.type,caption:e.caption},t)}async sendImages(e,t){return this.httpClient.post("/api/v1/instagram/messages/images",{token:e.token,recipientId:e.recipientId,images:e.images},t)}async sendSticker(e,t){return this.httpClient.post("/api/v1/instagram/messages/sticker",{token:e.token,recipientId:e.recipientId,stickerType:e.stickerType},t)}async reactMessage(e,t){return this.httpClient.post("/api/v1/instagram/messages/reaction",{token:e.token,messageId:e.messageId,reactionType:e.reactionType},t)}async removeReaction(e,t){return this.httpClient.delete("/api/v1/instagram/messages/reaction",t,{token:e.token,recipientId:e.recipientId,messageId:e.messageId})}async sendQuickReplies(e,t){return this.httpClient.post("/api/v1/instagram/messages/quick-replies",{token:e.token,recipientId:e.recipientId,message:e.message,quickReplies:e.quickReplies},t)}async sendGenericTemplate(e,t){return this.httpClient.post("/api/v1/instagram/messages/generic-template",{token:e.token,recipientId:e.recipientId,elements:e.elements},t)}async sendButtonTemplate(e,t){return this.httpClient.post("/api/v1/instagram/messages/button-template",{token:e.token,recipientId:e.recipientId,text:e.text,buttons:e.buttons},t)}async sendSenderAction(e,t){return this.httpClient.post("/api/v1/instagram/messages/sender-action",{token:e.token,recipientId:e.recipientId,action:e.action},t)}async getUserProfile(e,t){return this.httpClient.post("/api/v1/instagram/user-profile",{token:e.token,userId:e.userId},t)}async listPosts(e,t){return this.httpClient.post("/api/v1/instagram/posts",{token:e.token,userId:e.userId,limit:e.limit},t)}async getBusinessProfile(e,t){return this.httpClient.post("/api/v1/instagram/business-profile",{token:e.token},t)}async downloadMedia(e,t){return this.httpClient.post("/api/v1/instagram/download-media",{token:e.token,url:e.url},t)}async createMediaContainer(e,t){return this.httpClient.post("/api/v1/instagram/media",{token:e.token,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",{token:e.token,creation_id:e.creation_id},t)}async getContainerStatus(e,t){return this.httpClient.post(`/api/v1/instagram/media/${e.container_id}/status`,{token:e.token},t)}async getPublishingLimit(e,t){return this.httpClient.post("/api/v1/instagram/content_publishing_limit",{token:e.token},t)}async uploadVideo(e,t){return this.httpClient.post("/api/v1/instagram/upload",{token:e.token,container_id:e.container_id,file_url:e.file_url,offset:e.offset,file_size:e.file_size},t)}};var C=class{constructor(e){this.httpClient=new d(e),this.auth=new l(this.httpClient),this.channels=new c(this.httpClient),this.integrations=new p(this.httpClient),this.whatsapp=new h(this.httpClient),this.telegram=new g(this.httpClient),this.webchat=new u(this.httpClient),this.facebook=new m(this.httpClient),this.instagram=new y(this.httpClient);}},K=C;
7
- exports.OficialAPISDK=C;exports.default=K;//# sourceMappingURL=index.js.map
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,pageId:e.pageId,limit:e.limit},t)}async listComments(e,t){return this.httpClient.post("/api/v1/facebook/list-comments",{channelToken:e.channelToken,postId:e.postId,limit:e.limit},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,fileUrl:e.fileUrl,type:e.type,caption:e.caption},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
+ exports.OficialAPISDK=k;exports.default=K;//# sourceMappingURL=index.js.map
8
8
  //# sourceMappingURL=index.js.map