@oficialapi/sdk 3.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -306,6 +306,21 @@ await sdk.whatsapp.sendMediaCarousel({
306
306
  }, accessToken);
307
307
  ```
308
308
 
309
+ #### Baixar Mídia Descriptografada
310
+
311
+ ```typescript
312
+ const media = await sdk.whatsapp.downloadMedia({
313
+ token: 'sk_live_...',
314
+ url: 'https://lookaside.fbsbx.com/whatsapp_business/attachment/?mid=...'
315
+ }, accessToken);
316
+
317
+ // A mídia retorna em base64
318
+ console.log(media.data.buffer); // Base64 string
319
+ console.log(media.data.mimeType); // image/jpeg, video/mp4, etc.
320
+ console.log(media.data.filename); // Nome do arquivo
321
+ console.log(media.data.size); // Tamanho em bytes
322
+ ```
323
+
309
324
  #### Responder Mensagem
310
325
 
311
326
  ```typescript
@@ -544,6 +559,23 @@ await sdk.telegram.deleteMessage({
544
559
  }, accessToken);
545
560
  ```
546
561
 
562
+ #### Baixar Mídia Descriptografada
563
+
564
+ ```typescript
565
+
566
+
567
+ const media = await sdk.telegram.downloadMedia({
568
+ token: 'sk_live_...',
569
+ fileId: 'AgACAgEAAxkBAAItNmlmklyYNCEtvaFphVfSSO7CrEOjAALUC2sbh9owR9hT7MhQnTGfAQADAgADcwADOAQ'
570
+ }, accessToken);
571
+
572
+ // A mídia retorna em base64
573
+ console.log(media.data.buffer); // Base64 string
574
+ console.log(media.data.mimeType); // image/jpeg, video/mp4, etc.
575
+ console.log(media.data.filename); // Nome do arquivo
576
+ console.log(media.data.size); // Tamanho em bytes
577
+ ```
578
+
547
579
  ### WebChat
548
580
 
549
581
  #### Enviar Mensagem de Texto
@@ -816,6 +848,21 @@ const pageProfile = await sdk.facebook.getPageProfile({
816
848
  }, accessToken);
817
849
  ```
818
850
 
851
+ #### Baixar Mídia Descriptografada
852
+
853
+ ```typescript
854
+ const media = await sdk.facebook.downloadMedia({
855
+ token: 'sk_live_...',
856
+ url: 'https://lookaside.fbsbx.com/ig_messaging_cdn/...'
857
+ }, accessToken);
858
+
859
+ // A mídia retorna em base64
860
+ console.log(media.data.buffer); // Base64 string
861
+ console.log(media.data.mimeType); // image/jpeg, video/mp4, etc.
862
+ console.log(media.data.filename); // Nome do arquivo
863
+ console.log(media.data.size); // Tamanho em bytes
864
+ ```
865
+
819
866
  ### Instagram
820
867
 
821
868
  #### Enviar Mensagem de Texto
@@ -1006,6 +1053,21 @@ const businessProfile = await sdk.instagram.getBusinessProfile({
1006
1053
  }, accessToken);
1007
1054
  ```
1008
1055
 
1056
+ #### Baixar Mídia Descriptografada
1057
+
1058
+ ```typescript
1059
+ const media = await sdk.instagram.downloadMedia({
1060
+ token: 'sk_live_...',
1061
+ url: 'https://lookaside.fbsbx.com/ig_messaging_cdn/...'
1062
+ }, accessToken);
1063
+
1064
+ // A mídia retorna em base64
1065
+ console.log(media.data.buffer); // Base64 string
1066
+ console.log(media.data.mimeType); // image/jpeg, video/mp4, etc.
1067
+ console.log(media.data.filename); // Nome do arquivo
1068
+ console.log(media.data.size); // Tamanho em bytes
1069
+ ```
1070
+
1009
1071
  ### Canais
1010
1072
 
1011
1073
  #### Listar Canais
package/dist/index.d.mts CHANGED
@@ -87,19 +87,22 @@ interface SendWhatsAppTemplateParams {
87
87
  interface SendWhatsAppButtonsParams {
88
88
  token: string;
89
89
  sender: string;
90
- messageText: string;
90
+ text: string;
91
91
  buttons: Array<{
92
- type: 'reply';
93
- reply: {
94
- id: string;
95
- title: string;
96
- };
92
+ id: string;
93
+ title: string;
97
94
  }>;
95
+ media?: {
96
+ type: string;
97
+ url: string;
98
+ };
98
99
  }
99
100
  interface SendWhatsAppListParams {
100
101
  token: string;
101
102
  sender: string;
102
- messageText: string;
103
+ headerText: string;
104
+ bodyText: string;
105
+ footerText?: string;
103
106
  buttonText: string;
104
107
  sections: Array<{
105
108
  title: string;
@@ -112,13 +115,16 @@ interface SendWhatsAppListParams {
112
115
  }
113
116
  interface ReplyWhatsAppParams {
114
117
  token: string;
115
- messageId: string;
118
+ sender: string;
116
119
  messageText: string;
120
+ replyMessageId?: string;
121
+ preview_url?: boolean;
117
122
  }
118
123
  interface ReactWhatsAppParams {
119
124
  token: string;
120
- messageId: string;
125
+ sender: string;
121
126
  emoji: string;
127
+ message_id?: string;
122
128
  }
123
129
  interface CreateTemplateParams {
124
130
  token: string;
@@ -149,47 +155,113 @@ interface UploadMediaParams {
149
155
  interface SendOrderDetailsParams {
150
156
  token: string;
151
157
  sender: string;
152
- orderId: string;
153
- orderItems: Array<{
154
- item_code: string;
155
- description: string;
156
- quantity: number;
157
- price: number;
158
- }>;
159
- orderTotal: number;
158
+ headerText?: string;
159
+ bodyText: string;
160
+ footerText?: string;
161
+ reference_id: string;
162
+ type: 'digital-goods' | 'physical-goods';
160
163
  currency: string;
161
- paymentMethods: Array<{
162
- type: 'PIX' | 'CREDIT_CARD' | 'DEBIT_CARD' | 'BANK_TRANSFER';
163
- name: string;
164
+ total_amount: {
165
+ value: number;
166
+ offset: number;
167
+ description?: string;
168
+ };
169
+ order: {
170
+ status: 'pending' | 'processing' | 'partially-shipped' | 'shipped' | 'completed' | 'canceled';
171
+ catalog_id?: string;
172
+ items: Array<{
173
+ retailer_id: string;
174
+ name: string;
175
+ amount: {
176
+ value: number;
177
+ offset: number;
178
+ description?: string;
179
+ };
180
+ quantity: number;
181
+ sale_amount?: {
182
+ value: number;
183
+ offset: number;
184
+ description?: string;
185
+ };
186
+ }>;
187
+ subtotal: {
188
+ value: number;
189
+ offset: number;
190
+ description?: string;
191
+ };
192
+ tax: {
193
+ value: number;
194
+ offset: number;
195
+ description?: string;
196
+ };
197
+ shipping?: {
198
+ value: number;
199
+ offset: number;
200
+ description?: string;
201
+ };
202
+ discount?: {
203
+ value: number;
204
+ offset: number;
205
+ description?: string;
206
+ discount_program_name?: string;
207
+ };
208
+ expiration?: {
209
+ timestamp: string;
210
+ description: string;
211
+ };
212
+ };
213
+ payment_settings?: Array<{
214
+ type: 'pix_dynamic_code' | 'payment_link' | 'boleto' | 'offsite_card_pay';
215
+ pix_dynamic_code?: {
216
+ code: string;
217
+ merchant_name: string;
218
+ key: string;
219
+ key_type: 'CPF' | 'CNPJ' | 'EMAIL' | 'PHONE' | 'EVP';
220
+ };
221
+ payment_link?: {
222
+ uri: string;
223
+ };
224
+ boleto?: {
225
+ digitable_line: string;
226
+ };
227
+ offsite_card_pay?: {
228
+ last_four_digits: string;
229
+ credential_id: string;
230
+ };
164
231
  }>;
165
232
  }
166
233
  interface SendOrderStatusParams {
167
234
  token: string;
168
235
  sender: string;
169
- orderId: string;
170
- status: 'PENDING' | 'CONFIRMED' | 'PROCESSING' | 'SHIPPED' | 'DELIVERED' | 'CANCELLED';
171
- messageText?: string;
236
+ bodyText: string;
237
+ footerText?: string;
238
+ reference_id: string;
239
+ order_status: 'pending' | 'processing' | 'partially-shipped' | 'shipped' | 'completed' | 'canceled';
240
+ status_description?: string;
241
+ payment_status?: 'pending' | 'captured' | 'failed';
242
+ payment_timestamp?: number;
172
243
  }
173
244
  interface SendWhatsAppAudioParams {
174
245
  token: string;
175
246
  sender: string;
176
- audioUrl: string;
247
+ mediaId: string;
248
+ voice?: boolean;
177
249
  }
178
250
  interface SendWhatsAppStickerParams {
179
251
  token: string;
180
252
  sender: string;
181
- stickerUrl: string;
253
+ mediaId: string;
182
254
  }
183
255
  interface SendWhatsAppVideoParams {
184
256
  token: string;
185
257
  sender: string;
186
- videoUrl: string;
258
+ mediaId: string;
187
259
  caption?: string;
188
260
  }
189
261
  interface SendWhatsAppDocumentParams {
190
262
  token: string;
191
263
  sender: string;
192
- documentUrl: string;
264
+ mediaId: string;
193
265
  filename?: string;
194
266
  caption?: string;
195
267
  }
@@ -246,32 +318,40 @@ interface SendWhatsAppLocationParams {
246
318
  interface SendWhatsAppLocationRequestParams {
247
319
  token: string;
248
320
  sender: string;
249
- messageText: string;
321
+ bodyText: string;
322
+ headerText?: string;
323
+ footerText?: string;
250
324
  }
251
325
  interface SendWhatsAppCtaUrlParams {
252
326
  token: string;
253
327
  sender: string;
254
- messageText: string;
328
+ bodyText: string;
255
329
  buttonText: string;
256
330
  url: string;
331
+ header?: {
332
+ type: 'text' | 'image' | 'video' | 'document';
333
+ text?: string;
334
+ link?: string;
335
+ };
336
+ footerText?: string;
257
337
  }
258
338
  interface SendWhatsAppMediaCarouselParams {
259
339
  token: string;
260
340
  sender: string;
341
+ bodyText: string;
261
342
  cards: Array<{
262
- card_index: number;
263
- media: {
264
- link?: string;
265
- id?: string;
266
- };
267
- title: string;
268
- description: string;
269
- actions: Array<{
270
- type: 'link';
271
- value: string;
272
- }>;
343
+ cardIndex: number;
344
+ headerType: 'image' | 'video';
345
+ headerLink: string;
346
+ bodyText: string;
347
+ buttonText: string;
348
+ url: string;
273
349
  }>;
274
350
  }
351
+ interface DownloadWhatsAppMediaParams {
352
+ token: string;
353
+ url: string;
354
+ }
275
355
  interface SendTelegramTextParams {
276
356
  token: string;
277
357
  chatId: string | number;
@@ -391,6 +471,10 @@ interface DeleteTelegramMessageParams {
391
471
  chatId: string | number;
392
472
  messageId: number;
393
473
  }
474
+ interface DownloadTelegramMediaParams {
475
+ token: string;
476
+ fileId: string;
477
+ }
394
478
  interface SendWebChatTextParams {
395
479
  token: string;
396
480
  sender: string;
@@ -540,6 +624,10 @@ interface GetFacebookPageProfileParams {
540
624
  token: string;
541
625
  pageId: string;
542
626
  }
627
+ interface DownloadFacebookMediaParams {
628
+ token: string;
629
+ url: string;
630
+ }
543
631
  interface SendInstagramPrivateReplyParams {
544
632
  token: string;
545
633
  commentId: string;
@@ -633,6 +721,10 @@ interface ListInstagramPostsParams {
633
721
  interface GetInstagramBusinessProfileParams {
634
722
  token: string;
635
723
  }
724
+ interface DownloadInstagramMediaParams {
725
+ token: string;
726
+ url: string;
727
+ }
636
728
  interface CreateWebhookParams {
637
729
  url: string;
638
730
  expiresInDays?: number;
@@ -865,6 +957,12 @@ declare class WhatsAppModule {
865
957
  * @param accessToken Token de acesso do usuário
866
958
  */
867
959
  sendMediaCarousel(params: SendWhatsAppMediaCarouselParams, accessToken: string): Promise<ApiResponse<any>>;
960
+ /**
961
+ * Baixa uma mídia descriptografada do WhatsApp usando a URL
962
+ * @param params Parâmetros do download
963
+ * @param accessToken Token de acesso do usuário
964
+ */
965
+ downloadMedia(params: DownloadWhatsAppMediaParams, accessToken: string): Promise<ApiResponse<any>>;
868
966
  }
869
967
 
870
968
  /**
@@ -963,6 +1061,12 @@ declare class TelegramModule {
963
1061
  * @param accessToken Token de acesso do usuário
964
1062
  */
965
1063
  deleteMessage(params: DeleteTelegramMessageParams, accessToken: string): Promise<ApiResponse<any>>;
1064
+ /**
1065
+ * Baixa uma mídia descriptografada do Telegram usando o file_id
1066
+ * @param params Parâmetros do download
1067
+ * @param accessToken Token de acesso do usuário
1068
+ */
1069
+ downloadMedia(params: DownloadTelegramMediaParams, accessToken: string): Promise<ApiResponse<any>>;
966
1070
  }
967
1071
 
968
1072
  /**
@@ -1105,6 +1209,12 @@ declare class FacebookModule {
1105
1209
  * @param accessToken Token de acesso do usuário
1106
1210
  */
1107
1211
  getPageProfile(params: GetFacebookPageProfileParams, accessToken: string): Promise<ApiResponse<any>>;
1212
+ /**
1213
+ * Baixa uma mídia descriptografada do Facebook/Instagram usando a URL
1214
+ * @param params Parâmetros do download
1215
+ * @param accessToken Token de acesso do usuário
1216
+ */
1217
+ downloadMedia(params: DownloadFacebookMediaParams, accessToken: string): Promise<ApiResponse<any>>;
1108
1218
  }
1109
1219
 
1110
1220
  /**
@@ -1185,11 +1295,13 @@ declare class InstagramModule {
1185
1295
  * Obtém informações de perfil de um usuário do Instagram.
1186
1296
  *
1187
1297
  * Campos retornados:
1188
- * - name: Nome do usuário
1189
- * - profile_pic: URL da foto de perfil
1190
- * - username: Nome de usuário
1191
- * - follower_count: Número de seguidores
1192
- * - is_verified: Se está verificado
1298
+ * - id: ID do usuário
1299
+ * - name: Nome do usuário (pode ser nulo)
1300
+ * - username: Nome de usuário do Instagram
1301
+ *
1302
+ * ⚠️ Nota: A API do Instagram Graph API para usuários regulares (tipo User)
1303
+ * retorna apenas campos básicos. Campos como foto de perfil, número de seguidores
1304
+ * e status de verificação não estão disponíveis para usuários regulares.
1193
1305
  *
1194
1306
  * ⚠️ O usuário deve ter enviado mensagem direta para sua conta.
1195
1307
  * Não é possível obter perfil de quem apenas comentou.
@@ -1212,6 +1324,12 @@ declare class InstagramModule {
1212
1324
  * @param accessToken Token de acesso do usuário
1213
1325
  */
1214
1326
  getBusinessProfile(params: GetInstagramBusinessProfileParams, accessToken: string): Promise<ApiResponse<any>>;
1327
+ /**
1328
+ * Baixa uma mídia descriptografada do Instagram usando a URL
1329
+ * @param params Parâmetros do download
1330
+ * @param accessToken Token de acesso do usuário
1331
+ */
1332
+ downloadMedia(params: DownloadInstagramMediaParams, accessToken: string): Promise<ApiResponse<any>>;
1215
1333
  }
1216
1334
 
1217
1335
  /**
@@ -1247,4 +1365,4 @@ declare class OficialAPISDK {
1247
1365
  constructor(config: SDKConfig);
1248
1366
  }
1249
1367
 
1250
- export { type ApiResponse, type Channel, type CreatePostParams, type CreateTemplateParams, type CreateWebhookParams, type DeleteCommentParams, type DeleteTelegramMessageParams, type EditTelegramMessageParams, type GetFacebookPageProfileParams, type GetFacebookUserProfileParams, type GetInstagramBusinessProfileParams, type GetInstagramUserProfileParams, type ListCommentsParams, type ListInstagramPostsParams, type ListPostsParams, OficialAPISDK, type ReactInstagramMessageParams, type ReactWhatsAppParams, type RemoveInstagramReactionParams, type ReplyCommentParams, type ReplyFacebookMediaParams, type ReplyFacebookMessageParams, type ReplyWhatsAppParams, type SDKConfig, type SendFacebookButtonsParams, type SendFacebookMediaParams, type SendFacebookStickerParams, type SendFacebookTextParams, type SendInstagramButtonTemplateParams, type SendInstagramGenericTemplateParams, type SendInstagramImagesParams, type SendInstagramMediaParams, type SendInstagramPrivateReplyParams, type SendInstagramQuickRepliesParams, type SendInstagramSenderActionParams, type SendInstagramStickerParams, type SendInstagramTextParams, type SendOrderDetailsParams, type SendOrderStatusParams, type SendTelegramButtonsParams, type SendTelegramContactParams, type SendTelegramDiceParams, type SendTelegramLocationParams, type SendTelegramMediaGroupParams, type SendTelegramMediaParams, type SendTelegramPollParams, type SendTelegramReplyKeyboardParams, type SendTelegramStickerParams, type SendTelegramTextParams, type SendTelegramVenueParams, type SendTelegramVideoNoteParams, type SendTelegramVoiceParams, type SendWebChatButtonsParams, type SendWebChatCardParams, type SendWebChatCarouselParams, type SendWebChatFormParams, type SendWebChatMediaParams, type SendWebChatQuickRepliesParams, type SendWebChatTextParams, type SendWhatsAppAudioParams, type SendWhatsAppButtonsParams, type SendWhatsAppContactParams, type SendWhatsAppCtaUrlParams, type SendWhatsAppDocumentParams, type SendWhatsAppListParams, type SendWhatsAppLocationParams, type SendWhatsAppLocationRequestParams, type SendWhatsAppMediaCarouselParams, type SendWhatsAppMediaParams, type SendWhatsAppStickerParams, type SendWhatsAppTemplateParams, type SendWhatsAppTextParams, type SendWhatsAppVideoParams, type SharePostParams, type TokenResponse, type UploadMediaParams, type Webhook, OficialAPISDK as default };
1368
+ export { type ApiResponse, type Channel, type CreatePostParams, type CreateTemplateParams, type CreateWebhookParams, type DeleteCommentParams, type DeleteTelegramMessageParams, type DownloadFacebookMediaParams, type DownloadInstagramMediaParams, type DownloadTelegramMediaParams, type DownloadWhatsAppMediaParams, type EditTelegramMessageParams, type GetFacebookPageProfileParams, type GetFacebookUserProfileParams, type GetInstagramBusinessProfileParams, type GetInstagramUserProfileParams, type ListCommentsParams, type ListInstagramPostsParams, type ListPostsParams, OficialAPISDK, type ReactInstagramMessageParams, type ReactWhatsAppParams, type RemoveInstagramReactionParams, type ReplyCommentParams, type ReplyFacebookMediaParams, type ReplyFacebookMessageParams, type ReplyWhatsAppParams, type SDKConfig, type SendFacebookButtonsParams, type SendFacebookMediaParams, type SendFacebookStickerParams, type SendFacebookTextParams, type SendInstagramButtonTemplateParams, type SendInstagramGenericTemplateParams, type SendInstagramImagesParams, type SendInstagramMediaParams, type SendInstagramPrivateReplyParams, type SendInstagramQuickRepliesParams, type SendInstagramSenderActionParams, type SendInstagramStickerParams, type SendInstagramTextParams, type SendOrderDetailsParams, type SendOrderStatusParams, type SendTelegramButtonsParams, type SendTelegramContactParams, type SendTelegramDiceParams, type SendTelegramLocationParams, type SendTelegramMediaGroupParams, type SendTelegramMediaParams, type SendTelegramPollParams, type SendTelegramReplyKeyboardParams, type SendTelegramStickerParams, type SendTelegramTextParams, type SendTelegramVenueParams, type SendTelegramVideoNoteParams, type SendTelegramVoiceParams, type SendWebChatButtonsParams, type SendWebChatCardParams, type SendWebChatCarouselParams, type SendWebChatFormParams, type SendWebChatMediaParams, type SendWebChatQuickRepliesParams, type SendWebChatTextParams, type SendWhatsAppAudioParams, type SendWhatsAppButtonsParams, type SendWhatsAppContactParams, type SendWhatsAppCtaUrlParams, type SendWhatsAppDocumentParams, type SendWhatsAppListParams, type SendWhatsAppLocationParams, type SendWhatsAppLocationRequestParams, type SendWhatsAppMediaCarouselParams, type SendWhatsAppMediaParams, type SendWhatsAppStickerParams, type SendWhatsAppTemplateParams, type SendWhatsAppTextParams, type SendWhatsAppVideoParams, type SharePostParams, type TokenResponse, type UploadMediaParams, type Webhook, OficialAPISDK as default };