@adlanarifzr/whatsapp-sdk
Advanced tools
Comparing version 0.1.3 to 0.1.4
import type { ContactObject, InteractiveObject, LocationObject, MediaObject, MessageRequestBody, MessageResponseSuccess, ReactionObject, TemplateObject, TextObject } from './message.ts'; | ||
import type { WebhookPayloadObject, WebhookValueObject, WebhookStatusObject, WebhookMessageObject, WebhookErrorObject } from './webhook.js'; | ||
import { TemplateCreateRequestBody, TemplateUpdateRequestBody, TemplateLanguage } from './messageTemplate.js'; | ||
import { TemplateCreateRequestBody, TemplateUpdateRequestBody, TemplateLanguage, TemplateListRequestBody } from './messageTemplate.js'; | ||
export type { WebhookPayloadObject, WebhookValueObject, WebhookStatusObject, WebhookMessageObject, WebhookErrorObject }; | ||
@@ -236,2 +236,11 @@ export { TemplateLanguage }; | ||
updateMessageTemplate: (template_id: string | number, body: TemplateUpdateRequestBody) => Promise<any>; | ||
/** | ||
* **Get all message templates** | ||
* | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates#retrieve-templates}. | ||
* | ||
* @param params The query parameters. | ||
* @returns Object of axios response. | ||
*/ | ||
getMessageTemplates: (params: TemplateListRequestBody) => Promise<any>; | ||
} |
@@ -403,3 +403,17 @@ "use strict"; | ||
}; | ||
/** | ||
* **Get all message templates** | ||
* | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates#retrieve-templates}. | ||
* | ||
* @param params The query parameters. | ||
* @returns Object of axios response. | ||
*/ | ||
getMessageTemplates = async (params) => { | ||
return this.callMessageTemplateApi({ | ||
method: 'GET', | ||
params, | ||
}); | ||
}; | ||
} | ||
exports.default = WhatsappSdk; |
@@ -276,1 +276,141 @@ /** | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates#retrieve-templates}. | ||
*/ | ||
export type TemplateListRequestBody = { | ||
/** | ||
* **Optional.** | ||
* | ||
* List of [template fields](https://developers.facebook.com/docs/graph-api/reference/whats-app-business-hsm/#fields) you want returned. | ||
*/ | ||
fields?: Array<string | 'id' | 'category' | 'components' | 'correct_category' | 'cta_url_link_tracking_opted_out' | 'language' | 'library_template_name' | 'message_send_ttl_seconds' | 'name' | 'previous_category' | 'quality_score' | 'rejected_reason' | 'status' | 'sub_category'>; | ||
/** | ||
* **Optional.** | ||
* | ||
* The maximum number of templates you want returned in each page of results. | ||
* | ||
* Default is 25. | ||
*/ | ||
limit?: number; | ||
/** | ||
* **Optional.** | ||
* | ||
* The cursor of current page, which will return next result. | ||
*/ | ||
after?: string; | ||
/** | ||
* **Optional.** | ||
* | ||
* The cursor of current page, which will return previous result. | ||
*/ | ||
before?: string; | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/graph-api/reference/whats-app-business-hsm/#fields}. | ||
*/ | ||
export type TemplateObject = { | ||
/** | ||
* Template ID. | ||
*/ | ||
id: string; | ||
/** | ||
* The category type of the message template. | ||
*/ | ||
category?: 'AUTHENTICATION' | 'MARKETING' | 'UTILITY'; | ||
/** | ||
* An array of JSON objects describing the message template components. | ||
*/ | ||
components?: Array<TemplateComponentObject>; | ||
/** | ||
* The correct category for the template. | ||
*/ | ||
correct_category?: 'AUTHENTICATION' | 'MARKETING' | 'UTILITY'; | ||
/** | ||
* Optional boolean field for opting out/in of link tracking at template level | ||
*/ | ||
cta_url_link_tracking_opted_out?: boolean; | ||
/** | ||
* The language (and locale) of the element translation | ||
*/ | ||
language?: TemplateLanguage; | ||
/** | ||
* Template Library name that this HSM is clone from | ||
*/ | ||
library_template_name?: string; | ||
/** | ||
* Template message delivery retry time-to-live (TTL) override value. | ||
* If unable to deliver the template message to the WhatsApp user, we will periodically retry for this period of time. | ||
* If we are unable to deliver the message for this period of time, the message will be dropped. | ||
* | ||
* Only allowed for authentication message templates. See [Time-To-Live](https://developers.facebook.com/docs/whatsapp/business-management-api/authentication-templates/#time-to-live). | ||
*/ | ||
message_send_ttl_seconds?: number; | ||
/** | ||
* The message template name | ||
*/ | ||
name: string; | ||
/** | ||
* Previous category of the template. See [Template Categories](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates#categories). | ||
*/ | ||
previous_category?: 'AUTHENTICATION' | 'MARKETING' | 'UTILITY'; | ||
/** | ||
* Quality score of the HSM | ||
*/ | ||
quality_score?: { | ||
/** | ||
* Timestamp of the quality score | ||
*/ | ||
date?: number; | ||
/** | ||
* List of reasons for the score of the HSM | ||
*/ | ||
reasons?: Array<string>; | ||
/** | ||
* Quality score of the HSM | ||
*/ | ||
score?: string; | ||
}; | ||
/** | ||
* The reason the message template was rejected | ||
*/ | ||
rejected_reason?: 'ABUSIVE_CONTENT' | 'INVALID_FORMAT' | 'NONE' | 'PROMOTIONAL' | 'TAG_CONTENT_MISMATCH' | 'SCAM'; | ||
/** | ||
* The status of the message template | ||
*/ | ||
status: 'APPROVED' | 'IN_APPEAL' | 'PENDING' | 'REJECTED' | 'PENDING_DELETION' | 'DELETED' | 'DISABLED' | 'PAUSED' | 'LIMIT_EXCEEDED'; | ||
/** | ||
* Sub category of the template | ||
*/ | ||
sub_category?: string; | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates#example-response-2}. | ||
*/ | ||
export type TemplateListResponse = { | ||
/** | ||
* Array of message templates. | ||
*/ | ||
data: Array<TemplateObject>; | ||
/** | ||
* Information about the data pagination. | ||
*/ | ||
paging: { | ||
/** | ||
* Cursors for pagination. | ||
*/ | ||
cursors: { | ||
/** | ||
* Hash of the previous page cursor. | ||
*/ | ||
before: string; | ||
/** | ||
* Hash of the next page cursor. | ||
*/ | ||
after: string; | ||
}; | ||
/** | ||
* URL of the next page of data. | ||
*/ | ||
next: string; | ||
}; | ||
}; |
{ | ||
"name": "@adlanarifzr/whatsapp-sdk", | ||
"description": "Whatsapp Cloud API unofficial SDK", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
140131
4272