New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

messaging-api-messenger

Package Overview
Dependencies
Maintainers
3
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messaging-api-messenger - npm Package Compare versions

Comparing version 1.0.0-beta.33 to 1.0.0-beta.34

137

dist/MessengerClient.d.ts

@@ -40,3 +40,3 @@ import FormData from 'form-data';

*/
getPageInfo({ fields, accessToken: customAccessToken, }?: Types.AccessTokenOptions & {
getPageInfo({ fields }?: {
fields?: string[];

@@ -49,3 +49,3 @@ }): Promise<Types.PageInfo>;

*/
debugToken({ accessToken: customAccessToken, }?: Types.AccessTokenOptions): Promise<Types.TokenInfo>;
debugToken(): Promise<Types.TokenInfo>;
/**

@@ -87,3 +87,3 @@ * Create Subscription

*/
getMessagingFeatureReview({ accessToken: customAccessToken, }?: Types.AccessTokenOptions): Promise<Types.MessagingFeatureReview[]>;
getMessagingFeatureReview(): Promise<Types.MessagingFeatureReview[]>;
/**

@@ -95,5 +95,4 @@ * Get User Profile

*/
getUserProfile(userId: string, { fields, accessToken: customAccessToken, }?: {
getUserProfile(userId: string, { fields, }?: {
fields?: Types.UserProfileField[];
accessToken?: string;
}): Promise<Types.User>;

@@ -105,5 +104,5 @@ /**

*/
getMessengerProfile(fields: string[], { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<Types.MessengerProfile[]>;
setMessengerProfile(profile: Types.MessengerProfile, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteMessengerProfile(fields: string[], { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
getMessengerProfile(fields: string[]): Promise<Types.MessengerProfile[]>;
setMessengerProfile(profile: Types.MessengerProfile): Promise<Types.MutationSuccessResponse>;
deleteMessengerProfile(fields: string[]): Promise<Types.MutationSuccessResponse>;
/**

@@ -114,7 +113,7 @@ * Get Started Button

*/
getGetStarted(options?: Types.AccessTokenOptions): Promise<{
getGetStarted(): Promise<{
payload: string;
} | null>;
setGetStarted(payload: string, options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteGetStarted(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
setGetStarted(payload: string): Promise<Types.MutationSuccessResponse>;
deleteGetStarted(): Promise<Types.MutationSuccessResponse>;
/**

@@ -125,8 +124,7 @@ * Persistent Menu

*/
getPersistentMenu(options?: Types.AccessTokenOptions): Promise<Types.PersistentMenu | null>;
setPersistentMenu(menuItems: Types.MenuItem[] | Types.PersistentMenuItem[], { composerInputDisabled, ...options }?: {
getPersistentMenu(): Promise<Types.PersistentMenu | null>;
setPersistentMenu(menuItems: Types.MenuItem[] | Types.PersistentMenuItem[], { composerInputDisabled, }?: {
composerInputDisabled?: boolean;
accessToken?: string;
}): Promise<Types.MutationSuccessResponse>;
deletePersistentMenu(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deletePersistentMenu(): Promise<Types.MutationSuccessResponse>;
/**

@@ -137,8 +135,7 @@ * User Level Persistent Menu

*/
getUserPersistentMenu(userId: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<Types.PersistentMenu | null>;
setUserPersistentMenu(userId: string, menuItems: Types.MenuItem[] | Types.PersistentMenuItem[], { composerInputDisabled, accessToken: customAccessToken, }?: {
getUserPersistentMenu(userId: string): Promise<Types.PersistentMenu | null>;
setUserPersistentMenu(userId: string, menuItems: Types.MenuItem[] | Types.PersistentMenuItem[], { composerInputDisabled, }?: {
composerInputDisabled?: boolean;
accessToken?: string;
}): Promise<Types.MutationSuccessResponse>;
deleteUserPersistentMenu(userId: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteUserPersistentMenu(userId: string): Promise<Types.MutationSuccessResponse>;
/**

@@ -149,5 +146,5 @@ * Greeting Text

*/
getGreeting(options?: Types.AccessTokenOptions): Promise<Types.GreetingConfig[] | null>;
setGreeting(greeting: string | Types.GreetingConfig[], options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteGreeting(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
getGreeting(): Promise<Types.GreetingConfig[] | null>;
setGreeting(greeting: string | Types.GreetingConfig[]): Promise<Types.MutationSuccessResponse>;
deleteGreeting(): Promise<Types.MutationSuccessResponse>;
/**

@@ -158,5 +155,5 @@ * Ice Breakers

*/
getIceBreakers(options?: Types.AccessTokenOptions): Promise<Types.IceBreaker[] | null>;
setIceBreakers(iceBreakers: Types.IceBreaker[], options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteIceBreakers(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
getIceBreakers(): Promise<Types.IceBreaker[] | null>;
setIceBreakers(iceBreakers: Types.IceBreaker[]): Promise<Types.MutationSuccessResponse>;
deleteIceBreakers(): Promise<Types.MutationSuccessResponse>;
/**

@@ -167,5 +164,5 @@ * Whitelisted Domains

*/
getWhitelistedDomains(options?: Types.AccessTokenOptions): Promise<string[] | null>;
setWhitelistedDomains(whitelistedDomains: string[], options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteWhitelistedDomains(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
getWhitelistedDomains(): Promise<string[] | null>;
setWhitelistedDomains(whitelistedDomains: string[]): Promise<Types.MutationSuccessResponse>;
deleteWhitelistedDomains(): Promise<Types.MutationSuccessResponse>;
/**

@@ -176,29 +173,6 @@ * Account Linking URL

*/
getAccountLinkingURL(options?: Types.AccessTokenOptions): Promise<string | null>;
setAccountLinkingURL(accountLinkingUrl: string, options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteAccountLinkingURL(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
getAccountLinkingURL(): Promise<string | null>;
setAccountLinkingURL(accountLinkingUrl: string): Promise<Types.MutationSuccessResponse>;
deleteAccountLinkingURL(): Promise<Types.MutationSuccessResponse>;
/**
* Chat Extension Home URL
*
* https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api/home-url
*/
getHomeURL(options?: Types.AccessTokenOptions): Promise<{
url: string;
webviewHeightRatio: 'tall';
webviewShareButton?: 'hide' | 'show';
inTest: boolean;
} | null>;
setHomeURL(homeUrl: string, { webviewHeightRatio, webviewShareButton, inTest, }: {
webviewHeightRatio?: 'tall';
webviewShareButton?: 'hide' | 'show';
inTest: boolean;
}, options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
deleteHomeURL(options?: Types.AccessTokenOptions): Promise<Types.MutationSuccessResponse>;
/**
* Message tags
*
* https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
*/
getMessageTags({ accessToken: customAccessToken, }?: Types.AccessTokenOptions): Promise<Types.MessageTagResponse>;
/**
* Send API

@@ -244,6 +218,6 @@ *

*/
sendSenderAction(psidOrRecipient: Types.PsidOrRecipient, senderAction: Types.SenderAction, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<Types.SendSenderActionResponse>;
markSeen(psidOrRecipient: Types.PsidOrRecipient, options?: Record<string, any>): Promise<Types.SendSenderActionResponse>;
typingOn(psidOrRecipient: Types.PsidOrRecipient, options?: Record<string, any>): Promise<Types.SendSenderActionResponse>;
typingOff(psidOrRecipient: Types.PsidOrRecipient, options?: Record<string, any>): Promise<Types.SendSenderActionResponse>;
sendSenderAction(psidOrRecipient: Types.PsidOrRecipient, senderAction: Types.SenderAction): Promise<Types.SendSenderActionResponse>;
markSeen(psidOrRecipient: Types.PsidOrRecipient): Promise<Types.SendSenderActionResponse>;
typingOn(psidOrRecipient: Types.PsidOrRecipient): Promise<Types.SendSenderActionResponse>;
typingOff(psidOrRecipient: Types.PsidOrRecipient): Promise<Types.SendSenderActionResponse>;
/**

@@ -254,3 +228,3 @@ * Send Batch Request

*/
sendBatch(batch: Types.BatchItem[], { includeHeaders, accessToken: customAccessToken, }?: Types.AccessTokenOptions & {
sendBatch(batch: Types.BatchItem[], { includeHeaders }?: {
includeHeaders?: boolean;

@@ -275,3 +249,3 @@ }): Promise<{

*/
createLabel(name: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
createLabel(name: string): Promise<{
id: string;

@@ -284,3 +258,3 @@ }>;

*/
associateLabel(userId: string, labelId: number, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
associateLabel(userId: string, labelId: number): Promise<{
success: true;

@@ -293,3 +267,3 @@ }>;

*/
dissociateLabel(userId: string, labelId: number, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
dissociateLabel(userId: string, labelId: number): Promise<{
success: true;

@@ -354,3 +328,3 @@ }>;

*/
deleteLabel(labelId: number, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
deleteLabel(labelId: number): Promise<{
success: true;

@@ -378,6 +352,6 @@ }>;

*/
passThreadControl(recipientId: string, targetAppId: number, metadata?: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
passThreadControl(recipientId: string, targetAppId: number, metadata?: string): Promise<{
success: true;
}>;
passThreadControlToPageInbox(recipientId: string, metadata?: string, options?: Record<string, any>): Promise<{
passThreadControlToPageInbox(recipientId: string, metadata?: string): Promise<{
success: true;

@@ -390,3 +364,3 @@ }>;

*/
takeThreadControl(recipientId: string, metadata?: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
takeThreadControl(recipientId: string, metadata?: string): Promise<{
success: true;

@@ -399,3 +373,3 @@ }>;

*/
requestThreadControl(recipientId: string, metadata?: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
requestThreadControl(recipientId: string, metadata?: string): Promise<{
success: true;

@@ -408,3 +382,3 @@ }>;

*/
getSecondaryReceivers({ accessToken: customAccessToken, }?: Types.AccessTokenOptions): Promise<{
getSecondaryReceivers(): Promise<{
id: string;

@@ -418,3 +392,3 @@ name: string;

*/
getThreadOwner(recipientId: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
getThreadOwner(recipientId: string): Promise<{
appId: string;

@@ -465,5 +439,5 @@ }>;

*/
setNLPConfigs(config?: Types.MessengerNLPConfig, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<any>;
enableNLP(options?: Types.AccessTokenOptions): Promise<any>;
disableNLP(options?: Types.AccessTokenOptions): Promise<any>;
setNLPConfigs(config?: Types.MessengerNLPConfig): Promise<any>;
enableNLP(): Promise<any>;
disableNLP(): Promise<any>;
/**

@@ -483,3 +457,3 @@ * Logging Custom Events

*/
getUserField({ field, userId, appSecret, app, page, accessToken: customAccessToken, }: {
getUserField({ field, userId, appSecret, app, page, }: {
field: string;

@@ -490,3 +464,2 @@ userId: string;

page?: string;
accessToken?: string;
}): Promise<any>;

@@ -496,3 +469,3 @@ /**

*/
getIdsForApps({ userId, appSecret, app, page, accessToken, }: {
getIdsForApps({ userId, appSecret, app, page, }: {
userId: string;

@@ -502,3 +475,2 @@ appSecret: string;

page?: string;
accessToken?: string;
}): Promise<any>;

@@ -508,3 +480,3 @@ /**

*/
getIdsForPages({ userId, appSecret, app, page, accessToken, }: {
getIdsForPages({ userId, appSecret, app, page, }: {
userId: string;

@@ -514,3 +486,2 @@ appSecret: string;

page?: string;
accessToken?: string;
}): Promise<any>;

@@ -527,3 +498,3 @@ /**

*/
createPersona(persona: Types.Persona, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
createPersona(persona: Types.Persona): Promise<{
id: string;

@@ -536,3 +507,3 @@ }>;

*/
getPersona(personaId: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
getPersona(personaId: string): Promise<{
id: string;

@@ -547,3 +518,3 @@ name: string;

*/
getPersonas(cursor?: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
getPersonas(cursor?: string): Promise<{
data: {

@@ -561,3 +532,3 @@ id: string;

}>;
getAllPersonas({ accessToken: customAccessToken, }?: Types.AccessTokenOptions): Promise<{
getAllPersonas(): Promise<{
id: string;

@@ -572,3 +543,3 @@ name: string;

*/
deletePersona(personaId: string, { accessToken: customAccessToken }?: Types.AccessTokenOptions): Promise<{
deletePersona(personaId: string): Promise<{
success: true;

@@ -575,0 +546,0 @@ }>;

@@ -11,13 +11,2 @@ "use strict";

};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -153,7 +142,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

*/
getPageInfo({ fields, accessToken: customAccessToken, } = {}) {
getPageInfo({ fields } = {}) {
return this.axios
.get('/me', {
params: {
access_token: customAccessToken || this.accessToken,
access_token: this.accessToken,
fields: fields ? fields.join(',') : undefined,

@@ -169,3 +158,3 @@ },

*/
debugToken({ accessToken: customAccessToken, } = {}) {
debugToken() {
ts_invariant_1.default(this.appId, 'App ID is required to debug token');

@@ -177,3 +166,3 @@ ts_invariant_1.default(this.appSecret, 'App Secret is required to debug token');

params: {
input_token: customAccessToken || this.accessToken,
input_token: this.accessToken,
access_token: accessToken,

@@ -244,5 +233,5 @@ },

*/
getMessagingFeatureReview({ accessToken: customAccessToken, } = {}) {
getMessagingFeatureReview() {
return this.axios
.get(`/me/messaging_feature_review?access_token=${customAccessToken || this.accessToken}`)
.get(`/me/messaging_feature_review?access_token=${this.accessToken}`)
.then((res) => res.data.data, handleError);

@@ -256,5 +245,5 @@ }

*/
getUserProfile(userId, { fields = ['id', 'name', 'first_name', 'last_name', 'profile_pic'], accessToken: customAccessToken, } = {}) {
getUserProfile(userId, { fields = ['id', 'name', 'first_name', 'last_name', 'profile_pic'], } = {}) {
return this.axios
.get(`/${userId}?fields=${fields.join(',')}&access_token=${customAccessToken || this.accessToken}`)
.get(`/${userId}?fields=${fields.join(',')}&access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -267,15 +256,15 @@ }

*/
getMessengerProfile(fields, { accessToken: customAccessToken } = {}) {
getMessengerProfile(fields) {
return this.axios
.get(`/me/messenger_profile?fields=${fields.join(',')}&access_token=${customAccessToken || this.accessToken}`)
.get(`/me/messenger_profile?fields=${fields.join(',')}&access_token=${this.accessToken}`)
.then((res) => res.data.data, handleError);
}
setMessengerProfile(profile, { accessToken: customAccessToken } = {}) {
setMessengerProfile(profile) {
return this.axios
.post(`/me/messenger_profile?access_token=${customAccessToken || this.accessToken}`, profile)
.post(`/me/messenger_profile?access_token=${this.accessToken}`, profile)
.then((res) => res.data, handleError);
}
deleteMessengerProfile(fields, { accessToken: customAccessToken } = {}) {
deleteMessengerProfile(fields) {
return this.axios
.delete(`/me/messenger_profile?access_token=${customAccessToken || this.accessToken}`, {
.delete(`/me/messenger_profile?access_token=${this.accessToken}`, {
data: {

@@ -292,8 +281,8 @@ fields,

*/
getGetStarted(options = {}) {
return this.getMessengerProfile(['get_started'], options).then((res) => res[0]
getGetStarted() {
return this.getMessengerProfile(['get_started']).then((res) => res[0]
? res[0].getStarted
: null);
}
setGetStarted(payload, options = {}) {
setGetStarted(payload) {
return this.setMessengerProfile({

@@ -303,6 +292,6 @@ getStarted: {

},
}, options);
});
}
deleteGetStarted(options = {}) {
return this.deleteMessengerProfile(['get_started'], options);
deleteGetStarted() {
return this.deleteMessengerProfile(['get_started']);
}

@@ -314,7 +303,6 @@ /**

*/
getPersistentMenu(options = {}) {
return this.getMessengerProfile(['persistent_menu'], options).then((res) => res[0] ? res[0].persistentMenu : null);
getPersistentMenu() {
return this.getMessengerProfile(['persistent_menu']).then((res) => res[0] ? res[0].persistentMenu : null);
}
setPersistentMenu(menuItems, _a = {}) {
var { composerInputDisabled = false } = _a, options = __rest(_a, ["composerInputDisabled"]);
setPersistentMenu(menuItems, { composerInputDisabled = false, } = {}) {
// locale is in type PersistentMenuItem

@@ -324,3 +312,3 @@ if (menuItems.some((item) => 'locale' in item && item.locale === 'default')) {

persistentMenu: menuItems,
}, options);
});
}

@@ -336,6 +324,6 @@ // menuItems is in type MenuItem[]

],
}, options);
});
}
deletePersistentMenu(options = {}) {
return this.deleteMessengerProfile(['persistent_menu'], options);
deletePersistentMenu() {
return this.deleteMessengerProfile(['persistent_menu']);
}

@@ -347,5 +335,5 @@ /**

*/
getUserPersistentMenu(userId, { accessToken: customAccessToken } = {}) {
getUserPersistentMenu(userId) {
return this.axios
.get(`/me/custom_user_settings?psid=${userId}&access_token=${customAccessToken || this.accessToken}`)
.get(`/me/custom_user_settings?psid=${userId}&access_token=${this.accessToken}`)
.then((res) => res.data.data[0]

@@ -355,7 +343,7 @@ ? res.data.data[0].userLevelPersistentMenu

}
setUserPersistentMenu(userId, menuItems, { composerInputDisabled = false, accessToken: customAccessToken, } = {}) {
setUserPersistentMenu(userId, menuItems, { composerInputDisabled = false, } = {}) {
// locale is in type PersistentMenuItem
if (menuItems.some((item) => 'locale' in item && item.locale === 'default')) {
return this.axios
.post(`/me/custom_user_settings?access_token=${customAccessToken || this.accessToken}`, {
.post(`/me/custom_user_settings?access_token=${this.accessToken}`, {
psid: userId,

@@ -368,3 +356,3 @@ persistentMenu: menuItems,

return this.axios
.post(`/me/custom_user_settings?access_token=${customAccessToken || this.accessToken}`, {
.post(`/me/custom_user_settings?access_token=${this.accessToken}`, {
psid: userId,

@@ -381,5 +369,5 @@ persistentMenu: [

}
deleteUserPersistentMenu(userId, { accessToken: customAccessToken } = {}) {
deleteUserPersistentMenu(userId) {
return this.axios
.delete(`/me/custom_user_settings?psid=${userId}&params=[%22persistent_menu%22]&access_token=${customAccessToken || this.accessToken}`)
.delete(`/me/custom_user_settings?psid=${userId}&params=[%22persistent_menu%22]&access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -392,6 +380,6 @@ }

*/
getGreeting(options = {}) {
return this.getMessengerProfile(['greeting'], options).then((res) => res[0] ? res[0].greeting : null);
getGreeting() {
return this.getMessengerProfile(['greeting']).then((res) => res[0] ? res[0].greeting : null);
}
setGreeting(greeting, options = {}) {
setGreeting(greeting) {
if (typeof greeting === 'string') {

@@ -405,10 +393,10 @@ return this.setMessengerProfile({

],
}, options);
});
}
return this.setMessengerProfile({
greeting,
}, options);
});
}
deleteGreeting(options = {}) {
return this.deleteMessengerProfile(['greeting'], options);
deleteGreeting() {
return this.deleteMessengerProfile(['greeting']);
}

@@ -420,12 +408,12 @@ /**

*/
getIceBreakers(options = {}) {
return this.getMessengerProfile(['ice_breakers'], options).then((res) => res[0] ? res[0].iceBreakers : null);
getIceBreakers() {
return this.getMessengerProfile(['ice_breakers']).then((res) => res[0] ? res[0].iceBreakers : null);
}
setIceBreakers(iceBreakers, options = {}) {
setIceBreakers(iceBreakers) {
return this.setMessengerProfile({
iceBreakers,
}, options);
});
}
deleteIceBreakers(options = {}) {
return this.deleteMessengerProfile(['ice_breakers'], options);
deleteIceBreakers() {
return this.deleteMessengerProfile(['ice_breakers']);
}

@@ -437,12 +425,12 @@ /**

*/
getWhitelistedDomains(options = {}) {
return this.getMessengerProfile(['whitelisted_domains'], options).then((res) => (res[0] ? res[0].whitelistedDomains : null));
getWhitelistedDomains() {
return this.getMessengerProfile(['whitelisted_domains']).then((res) => res[0] ? res[0].whitelistedDomains : null);
}
setWhitelistedDomains(whitelistedDomains, options = {}) {
setWhitelistedDomains(whitelistedDomains) {
return this.setMessengerProfile({
whitelistedDomains,
}, options);
});
}
deleteWhitelistedDomains(options = {}) {
return this.deleteMessengerProfile(['whitelisted_domains'], options);
deleteWhitelistedDomains() {
return this.deleteMessengerProfile(['whitelisted_domains']);
}

@@ -454,47 +442,14 @@ /**

*/
getAccountLinkingURL(options = {}) {
return this.getMessengerProfile(['account_linking_url'], options).then((res) => (res[0] ? res[0] : null));
getAccountLinkingURL() {
return this.getMessengerProfile(['account_linking_url']).then((res) => res[0] ? res[0] : null);
}
setAccountLinkingURL(accountLinkingUrl, options = {}) {
setAccountLinkingURL(accountLinkingUrl) {
return this.setMessengerProfile({
accountLinkingUrl,
}, options);
});
}
deleteAccountLinkingURL(options = {}) {
return this.deleteMessengerProfile(['account_linking_url'], options);
deleteAccountLinkingURL() {
return this.deleteMessengerProfile(['account_linking_url']);
}
/**
* Chat Extension Home URL
*
* https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api/home-url
*/
getHomeURL(options = {}) {
return this.getMessengerProfile(['home_url'], options).then((res) => res[0]
? res[0]
: null);
}
setHomeURL(homeUrl, { webviewHeightRatio = 'tall', webviewShareButton, inTest, }, options = {}) {
return this.setMessengerProfile({
homeUrl: {
url: homeUrl,
webviewHeightRatio,
inTest,
webviewShareButton,
},
}, options);
}
deleteHomeURL(options = {}) {
return this.deleteMessengerProfile(['home_url'], options);
}
/**
* Message tags
*
* https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
*/
getMessageTags({ accessToken: customAccessToken, } = {}) {
return this.axios
.get(`/page_message_tags?access_token=${customAccessToken || this.accessToken}`)
.then((res) => res.data.data, handleError);
}
/**
* Send API

@@ -505,5 +460,4 @@ *

sendRawBody(body) {
const { accessToken: customAccessToken } = body;
return this.axios
.post(`/me/messages?access_token=${customAccessToken || this.accessToken}`, body)
.post(`/me/messages?access_token=${this.accessToken}`, body)
.then((res) => res.data, handleError);

@@ -543,3 +497,3 @@ }

return this.axios
.post(`/me/messages?access_token=${options.accessToken || this.accessToken}`, formdata, {
.post(`/me/messages?access_token=${this.accessToken}`, formdata, {
headers: formdata.getHeaders(),

@@ -641,3 +595,3 @@ })

*/
sendSenderAction(psidOrRecipient, senderAction, { accessToken: customAccessToken } = {}) {
sendSenderAction(psidOrRecipient, senderAction) {
const recipient = typeof psidOrRecipient === 'string'

@@ -651,13 +605,12 @@ ? {

senderAction,
accessToken: customAccessToken,
});
}
markSeen(psidOrRecipient, options = {}) {
return this.sendSenderAction(psidOrRecipient, 'mark_seen', options);
markSeen(psidOrRecipient) {
return this.sendSenderAction(psidOrRecipient, 'mark_seen');
}
typingOn(psidOrRecipient, options = {}) {
return this.sendSenderAction(psidOrRecipient, 'typing_on', options);
typingOn(psidOrRecipient) {
return this.sendSenderAction(psidOrRecipient, 'typing_on');
}
typingOff(psidOrRecipient, options = {}) {
return this.sendSenderAction(psidOrRecipient, 'typing_off', options);
typingOff(psidOrRecipient) {
return this.sendSenderAction(psidOrRecipient, 'typing_off');
}

@@ -669,3 +622,3 @@ /**

*/
sendBatch(batch, { includeHeaders = true, accessToken: customAccessToken, } = {}) {
sendBatch(batch, { includeHeaders = true } = {}) {
ts_invariant_1.default(batch.length <= 50, 'limit the number of requests which can be in a batch to 50');

@@ -689,3 +642,3 @@ const responseAccessPaths = batch.map((item) => item.responseAccessPath);

.post('/', {
accessToken: customAccessToken || this.accessToken,
accessToken: this.accessToken,
includeHeaders,

@@ -716,5 +669,5 @@ batch: bodyEncodedbatch,

*/
createLabel(name, { accessToken: customAccessToken } = {}) {
createLabel(name) {
return this.axios
.post(`/me/custom_labels?access_token=${customAccessToken || this.accessToken}`, {
.post(`/me/custom_labels?access_token=${this.accessToken}`, {
name,

@@ -729,5 +682,5 @@ })

*/
associateLabel(userId, labelId, { accessToken: customAccessToken } = {}) {
associateLabel(userId, labelId) {
return this.axios
.post(`/${labelId}/label?access_token=${customAccessToken || this.accessToken}`, {
.post(`/${labelId}/label?access_token=${this.accessToken}`, {
user: userId,

@@ -742,5 +695,5 @@ })

*/
dissociateLabel(userId, labelId, { accessToken: customAccessToken } = {}) {
dissociateLabel(userId, labelId) {
return this.axios
.delete(`/${labelId}/label?access_token=${customAccessToken || this.accessToken}`, {
.delete(`/${labelId}/label?access_token=${this.accessToken}`, {
data: { user: userId },

@@ -758,3 +711,3 @@ })

return this.axios
.get(`/${userId}/custom_labels?fields=${fields}&access_token=${options.accessToken || this.accessToken}`)
.get(`/${userId}/custom_labels?fields=${fields}&access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -770,3 +723,3 @@ }

return this.axios
.get(`/${labelId}?fields=${fields}&access_token=${options.accessToken || this.accessToken}`)
.get(`/${labelId}?fields=${fields}&access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -782,3 +735,3 @@ }

return this.axios
.get(`/me/custom_labels?fields=${fields}&access_token=${options.accessToken || this.accessToken}`)
.get(`/me/custom_labels?fields=${fields}&access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -791,5 +744,5 @@ }

*/
deleteLabel(labelId, { accessToken: customAccessToken } = {}) {
deleteLabel(labelId) {
return this.axios
.delete(`/${labelId}?access_token=${customAccessToken || this.accessToken}`)
.delete(`/${labelId}?access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -836,3 +789,3 @@ }

return this.axios
.post(`/me/message_attachments?access_token=${options.accessToken || this.accessToken}`, ...args)
.post(`/me/message_attachments?access_token=${this.accessToken}`, ...args)
.then((res) => res.data, handleError);

@@ -866,5 +819,5 @@ }

*/
passThreadControl(recipientId, targetAppId, metadata, { accessToken: customAccessToken } = {}) {
passThreadControl(recipientId, targetAppId, metadata) {
return this.axios
.post(`/me/pass_thread_control?access_token=${customAccessToken || this.accessToken}`, {
.post(`/me/pass_thread_control?access_token=${this.accessToken}`, {
recipient: { id: recipientId },

@@ -876,4 +829,4 @@ targetAppId,

}
passThreadControlToPageInbox(recipientId, metadata, options = {}) {
return this.passThreadControl(recipientId, 263902037430900, metadata, options);
passThreadControlToPageInbox(recipientId, metadata) {
return this.passThreadControl(recipientId, 263902037430900, metadata);
}

@@ -885,5 +838,5 @@ /**

*/
takeThreadControl(recipientId, metadata, { accessToken: customAccessToken } = {}) {
takeThreadControl(recipientId, metadata) {
return this.axios
.post(`/me/take_thread_control?access_token=${customAccessToken || this.accessToken}`, {
.post(`/me/take_thread_control?access_token=${this.accessToken}`, {
recipient: { id: recipientId },

@@ -899,5 +852,5 @@ metadata,

*/
requestThreadControl(recipientId, metadata, { accessToken: customAccessToken } = {}) {
requestThreadControl(recipientId, metadata) {
return this.axios
.post(`/me/request_thread_control?access_token=${customAccessToken || this.accessToken}`, {
.post(`/me/request_thread_control?access_token=${this.accessToken}`, {
recipient: { id: recipientId },

@@ -913,5 +866,5 @@ metadata,

*/
getSecondaryReceivers({ accessToken: customAccessToken, } = {}) {
getSecondaryReceivers() {
return this.axios
.get(`/me/secondary_receivers?fields=id,name&access_token=${customAccessToken || this.accessToken}`)
.get(`/me/secondary_receivers?fields=id,name&access_token=${this.accessToken}`)
.then((res) => res.data.data, handleError);

@@ -924,5 +877,5 @@ }

*/
getThreadOwner(recipientId, { accessToken: customAccessToken } = {}) {
getThreadOwner(recipientId) {
return this.axios
.get(`/me/thread_owner?recipient=${recipientId}&access_token=${customAccessToken || this.accessToken}`)
.get(`/me/thread_owner?recipient=${recipientId}&access_token=${this.accessToken}`)
.then((res) => res.data.data[0].threadOwner, handleError);

@@ -937,3 +890,3 @@ }

return this.axios
.get(`/me/insights/?${querystring_1.default.stringify(Object.assign({ metric: metrics.join(','), access_token: options.accessToken || this.accessToken }, options))}`)
.get(`/me/insights/?${querystring_1.default.stringify(Object.assign({ metric: metrics.join(','), access_token: this.accessToken }, options))}`)
.then((res) => res.data.data, handleError);

@@ -961,16 +914,14 @@ }

// FIXME: [type] return type
setNLPConfigs(config = {}, { accessToken: customAccessToken } = {}) {
setNLPConfigs(config = {}) {
return this.axios
.post(`/me/nlp_configs?${querystring_1.default.stringify(messaging_api_common_1.snakecaseKeysDeep(config))}`, {
accessToken: customAccessToken || this.accessToken,
})
.post(`/me/nlp_configs?${querystring_1.default.stringify(messaging_api_common_1.snakecaseKeysDeep(Object.assign(Object.assign({}, config), { accessToken: this.accessToken })))}`)
.then((res) => res.data, handleError);
}
// FIXME: [type] return type
enableNLP(options = {}) {
return this.setNLPConfigs({ nlpEnabled: true }, options);
enableNLP() {
return this.setNLPConfigs({ nlpEnabled: true });
}
// FIXME: [type] return type
disableNLP(options = {}) {
return this.setNLPConfigs({ nlpEnabled: false }, options);
disableNLP() {
return this.setNLPConfigs({ nlpEnabled: false });
}

@@ -1000,8 +951,7 @@ /**

// FIXME: [type] return type
getUserField({ field, userId, appSecret, app, page, accessToken: customAccessToken, }) {
const accessToken = customAccessToken || this.accessToken;
getUserField({ field, userId, appSecret, app, page, }) {
// $appsecret_proof= hash_hmac('sha256', $access_token, $app_secret);
const appsecretProof = crypto_1.default
.createHmac('sha256', appSecret)
.update(accessToken)
.update(this.accessToken)
.digest('hex');

@@ -1011,3 +961,3 @@ const appQueryString = app ? `&app=${app}` : '';

return this.axios
.get(`/${userId}/${field}?access_token=${accessToken}&appsecret_proof=${appsecretProof}${appQueryString}${pageQueryString}`)
.get(`/${userId}/${field}?access_token=${this.accessToken}&appsecret_proof=${appsecretProof}${appQueryString}${pageQueryString}`)
.then((res) => res.data, handleError);

@@ -1019,3 +969,3 @@ }

// FIXME: [type] return type
getIdsForApps({ userId, appSecret, app, page, accessToken, }) {
getIdsForApps({ userId, appSecret, app, page, }) {
return this.getUserField({

@@ -1027,3 +977,2 @@ field: 'ids_for_apps',

page,
accessToken,
});

@@ -1035,3 +984,3 @@ }

// FIXME: [type] return type
getIdsForPages({ userId, appSecret, app, page, accessToken, }) {
getIdsForPages({ userId, appSecret, app, page, }) {
return this.getUserField({

@@ -1043,3 +992,2 @@ field: 'ids_for_pages',

page,
accessToken,
});

@@ -1057,5 +1005,5 @@ }

*/
createPersona(persona, { accessToken: customAccessToken } = {}) {
createPersona(persona) {
return this.axios
.post(`/me/personas?access_token=${customAccessToken || this.accessToken}`, persona)
.post(`/me/personas?access_token=${this.accessToken}`, persona)
.then((res) => res.data, handleError);

@@ -1068,5 +1016,5 @@ }

*/
getPersona(personaId, { accessToken: customAccessToken } = {}) {
getPersona(personaId) {
return this.axios
.get(`/${personaId}?access_token=${customAccessToken || this.accessToken}`)
.get(`/${personaId}?access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -1079,8 +1027,8 @@ }

*/
getPersonas(cursor, { accessToken: customAccessToken } = {}) {
getPersonas(cursor) {
return this.axios
.get(`/me/personas?access_token=${customAccessToken || this.accessToken}${cursor ? `&after=${cursor}` : ''}`)
.get(`/me/personas?access_token=${this.accessToken}${cursor ? `&after=${cursor}` : ''}`)
.then((res) => res.data, handleError);
}
getAllPersonas({ accessToken: customAccessToken, } = {}) {
getAllPersonas() {
return __awaiter(this, void 0, void 0, function* () {

@@ -1090,5 +1038,3 @@ let allPersonas = [];

do {
const { data, paging, } = yield this.getPersonas(cursor, {
accessToken: customAccessToken,
});
const { data, paging, } = yield this.getPersonas(cursor);
allPersonas = allPersonas.concat(data);

@@ -1105,5 +1051,5 @@ cursor = paging ? paging.cursors.after : null;

*/
deletePersona(personaId, { accessToken: customAccessToken } = {}) {
deletePersona(personaId) {
return this.axios
.delete(`/${personaId}?access_token=${customAccessToken || this.accessToken}`)
.delete(`/${personaId}?access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -1110,0 +1056,0 @@ }

@@ -116,9 +116,5 @@ /// <reference types="node" />

export declare type InsightMetric = 'page_messages_blocked_conversations_unique' | 'page_messages_reported_conversations_unique' | 'page_messages_total_messaging_connections' | 'page_messages_new_conversations_unique';
export declare type AccessTokenOptions = {
accessToken?: string;
};
export declare type InsightOptions = {
since?: number;
until?: number;
accessToken?: string;
};

@@ -129,3 +125,2 @@ export declare type SendOption = {

quickReplies?: QuickReply[];
accessToken?: string;
};

@@ -135,3 +130,2 @@ export declare type UploadOption = {

isReusable?: boolean;
accessToken?: string;
};

@@ -138,0 +132,0 @@ export declare type TemplateButton = {

@@ -9,3 +9,3 @@ {

},
"version": "1.0.0-beta.33",
"version": "1.0.0-beta.34",
"main": "dist/index.js",

@@ -36,3 +36,3 @@ "browser": "lib/browser.js",

},
"gitHead": "a3f7afb4cef3784c3459f6be0810e0518b1bb384"
"gitHead": "dffb3adafba268a22ff08614dcdf9716ff7bb406"
}

@@ -63,41 +63,2 @@ import MockAdapter from 'axios-mock-adapter';

});
it('should call messages api to pass thread control with custom access token', async () => {
const { client, mock } = createMock();
const reply = {
success: true,
};
const options = {
accessToken: '0987654321',
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.passThreadControl(
USER_ID,
123456789,
'free formed text for another app',
options
);
expect(url).toEqual(
`/me/pass_thread_control?access_token=${options.accessToken}`
);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
target_app_id: 123456789,
metadata: 'free formed text for another app',
});
expect(res).toEqual(reply);
});
});

@@ -139,40 +100,2 @@

});
it('should call messages api to pass thread control to page inbox with custom access token', async () => {
const { client, mock } = createMock();
const reply = {
success: true,
};
const options = {
accessToken: '0987654321',
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.passThreadControlToPageInbox(
USER_ID,
'free formed text for another app',
options
);
expect(url).toEqual(
`/me/pass_thread_control?access_token=${options.accessToken}`
);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
target_app_id: 263902037430900,
metadata: 'free formed text for another app',
});
expect(res).toEqual(reply);
});
});

@@ -213,39 +136,2 @@

});
it('should call messages api to take thread control with custom access token', async () => {
const { client, mock } = createMock();
const reply = {
success: true,
};
const options = {
accessToken: '0987654321',
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.takeThreadControl(
USER_ID,
'free formed text for another app',
options
);
expect(url).toEqual(
`/me/take_thread_control?access_token=${options.accessToken}`
);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
metadata: 'free formed text for another app',
});
expect(res).toEqual(reply);
});
});

@@ -286,39 +172,2 @@

});
it('should call messages api to request thread control with custom access token', async () => {
const { client, mock } = createMock();
const reply = {
success: true,
};
const options = {
accessToken: '0987654321',
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.requestThreadControl(
USER_ID,
'free formed text for primary app',
options
);
expect(url).toEqual(
`/me/request_thread_control?access_token=${options.accessToken}`
);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
metadata: 'free formed text for primary app',
});
expect(res).toEqual(reply);
});
});

@@ -385,34 +234,2 @@

});
it('should call messages api to get thread owner with custom access token', async () => {
const { client, mock } = createMock();
const reply = {
data: [
{
thread_owner: {
app_id: '12345678910',
},
},
],
};
const options = {
accessToken: '0987654321',
};
let url;
mock.onGet().reply((config) => {
url = config.url;
return [200, reply];
});
const res = await client.getThreadOwner(USER_ID, options);
expect(url).toEqual(
`/me/thread_owner?recipient=${USER_ID}&access_token=${options.accessToken}`
);
expect(res).toEqual({ appId: '12345678910' });
});
});

@@ -1375,120 +1375,1 @@ import MockAdapter from 'axios-mock-adapter';

});
describe('chat extension home URL', () => {
describe('#getHomeURL', () => {
it('should respond data of home url', async () => {
const { client, mock } = createMock();
const reply = {
data: [
{
url: 'http://petershats.com/send-a-hat',
webview_height_ratio: 'tall',
in_test: true,
},
],
};
let url;
mock.onGet().reply((config) => {
url = config.url;
return [200, reply];
});
const res = await client.getHomeURL();
expect(url).toEqual(
`/me/messenger_profile?fields=home_url&access_token=${ACCESS_TOKEN}`
);
expect(res).toEqual({
url: 'http://petershats.com/send-a-hat',
webviewHeightRatio: 'tall',
inTest: true,
});
});
it('should respond null when data is an empty array', async () => {
const { client, mock } = createMock();
const reply = {
data: [],
};
let url;
mock.onGet().reply((config) => {
url = config.url;
return [200, reply];
});
const res = await client.getHomeURL();
expect(url).toEqual(
`/me/messenger_profile?fields=home_url&access_token=${ACCESS_TOKEN}`
);
expect(res).toEqual(null);
});
});
describe('#setHomeURL', () => {
it('should respond success result', async () => {
const { client, mock } = createMock();
const reply = {
result: 'success',
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.setHomeURL('http://petershats.com/send-a-hat', {
webviewHeightRatio: 'tall',
inTest: true,
});
expect(url).toEqual(`/me/messenger_profile?access_token=${ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
home_url: {
url: 'http://petershats.com/send-a-hat',
webview_height_ratio: 'tall',
in_test: true,
},
});
expect(res).toEqual(reply);
});
});
describe('#deleteHomeURL', () => {
it('should respond success result', async () => {
const { client, mock } = createMock();
const reply = {
result: 'success',
};
let url;
let data;
mock.onDelete().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.deleteHomeURL();
expect(url).toEqual(`/me/messenger_profile?access_token=${ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
fields: ['home_url'],
});
expect(res).toEqual(reply);
});
});
});

@@ -76,47 +76,2 @@ import fs from 'fs';

});
it('should call messages api with custom access token', async () => {
const { client, mock } = createMock();
const reply = {
recipient_id: USER_ID,
message_id: 'mid.1489394984387:3dd22de509',
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.sendRawBody({
messagingType: 'UPDATE',
recipient: {
id: USER_ID,
},
message: {
text: 'Hello!',
},
accessToken: CUSTOM_ACCESS_TOKEN,
});
expect(url).toEqual(`/me/messages?access_token=${CUSTOM_ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
messaging_type: 'UPDATE',
recipient: {
id: USER_ID,
},
message: {
text: 'Hello!',
},
access_token: CUSTOM_ACCESS_TOKEN,
});
expect(res).toEqual({
recipientId: USER_ID,
messageId: 'mid.1489394984387:3dd22de509',
});
});
});

@@ -1335,35 +1290,2 @@

});
it('should call messages api with sender action and custom access token', async () => {
const { client, mock } = createMock();
const reply = {
recipient_id: USER_ID,
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.sendSenderAction(USER_ID, 'typing_on', {
accessToken: CUSTOM_ACCESS_TOKEN,
});
expect(url).toEqual(`/me/messages?access_token=${CUSTOM_ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
sender_action: 'typing_on',
access_token: CUSTOM_ACCESS_TOKEN,
});
expect(res).toEqual({
recipientId: USER_ID,
});
});
});

@@ -1401,35 +1323,2 @@

});
it('should call messages api with mark_seen sender action and options', async () => {
const { client, mock } = createMock();
const reply = {
recipient_id: USER_ID,
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.markSeen(USER_ID, {
accessToken: CUSTOM_ACCESS_TOKEN,
});
expect(url).toEqual(`/me/messages?access_token=${CUSTOM_ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
sender_action: 'mark_seen',
access_token: CUSTOM_ACCESS_TOKEN,
});
expect(res).toEqual({
recipientId: USER_ID,
});
});
});

@@ -1467,35 +1356,2 @@

});
it('should call messages api with typing_on sender action and options', async () => {
const { client, mock } = createMock();
const reply = {
recipient_id: USER_ID,
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.typingOn(USER_ID, {
accessToken: CUSTOM_ACCESS_TOKEN,
});
expect(url).toEqual(`/me/messages?access_token=${CUSTOM_ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
sender_action: 'typing_on',
access_token: CUSTOM_ACCESS_TOKEN,
});
expect(res).toEqual({
recipientId: USER_ID,
});
});
});

@@ -1533,36 +1389,3 @@

});
it('should call messages api with typing_off sender action and options', async () => {
const { client, mock } = createMock();
const reply = {
recipient_id: USER_ID,
};
let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];
});
const res = await client.typingOff(USER_ID, {
accessToken: CUSTOM_ACCESS_TOKEN,
});
expect(url).toEqual(`/me/messages?access_token=${CUSTOM_ACCESS_TOKEN}`);
expect(JSON.parse(data)).toEqual({
recipient: {
id: USER_ID,
},
sender_action: 'typing_off',
access_token: CUSTOM_ACCESS_TOKEN,
});
expect(res).toEqual({
recipientId: USER_ID,
});
});
});
});

@@ -433,48 +433,2 @@ import fs from 'fs';

describe('message tags', () => {
describe('#getMessageTags', () => {
it('should response data of message tags', async () => {
const { client, mock } = createMock();
const reply = {
data: [
{
tag: 'POST_PURCHASE_UPDATE',
description:
'Notify the message recipient of an update on an existing transaction.',
},
{
tag: 'ACCOUNT_UPDATE',
description:
'Notify the message recipient of a change to their account settings.',
},
],
};
let url;
mock.onGet().reply((config) => {
url = config.url;
return [200, reply];
});
const res = await client.getMessageTags();
expect(url).toEqual(`/page_message_tags?access_token=${ACCESS_TOKEN}`);
expect(res).toEqual([
{
tag: 'POST_PURCHASE_UPDATE',
description:
'Notify the message recipient of an update on an existing transaction.',
},
{
tag: 'ACCOUNT_UPDATE',
description:
'Notify the message recipient of a change to their account settings.',
},
]);
});
});
});
describe('upload api', () => {

@@ -769,6 +723,4 @@ describe('#uploadAttachment', () => {

let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];

@@ -783,7 +735,4 @@ });

expect(url).toEqual(
`/me/nlp_configs?nlp_enabled=true&custom_token=1234567890`
`/me/nlp_configs?nlp_enabled=true&custom_token=1234567890&access_token=1234567890`
);
expect(JSON.parse(data)).toEqual({
access_token: ACCESS_TOKEN,
});

@@ -803,6 +752,4 @@ expect(res).toEqual(reply);

let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];

@@ -813,6 +760,5 @@ });

expect(url).toEqual(`/me/nlp_configs?nlp_enabled=true`);
expect(JSON.parse(data)).toEqual({
access_token: ACCESS_TOKEN,
});
expect(url).toEqual(
`/me/nlp_configs?nlp_enabled=true&access_token=1234567890`
);

@@ -832,6 +778,4 @@ expect(res).toEqual(reply);

let url;
let data;
mock.onPost().reply((config) => {
url = config.url;
data = config.data;
return [200, reply];

@@ -842,6 +786,5 @@ });

expect(url).toEqual(`/me/nlp_configs?nlp_enabled=false`);
expect(JSON.parse(data)).toEqual({
access_token: ACCESS_TOKEN,
});
expect(url).toEqual(
`/me/nlp_configs?nlp_enabled=false&access_token=1234567890`
);

@@ -848,0 +791,0 @@ expect(res).toEqual(reply);

@@ -226,12 +226,7 @@ import crypto from 'crypto';

*/
getPageInfo({
fields,
accessToken: customAccessToken,
}: Types.AccessTokenOptions & { fields?: string[] } = {}): Promise<
Types.PageInfo
> {
getPageInfo({ fields }: { fields?: string[] } = {}): Promise<Types.PageInfo> {
return this.axios
.get('/me', {
params: {
access_token: customAccessToken || this.accessToken,
access_token: this.accessToken,
fields: fields ? fields.join(',') : undefined,

@@ -248,5 +243,3 @@ },

*/
debugToken({
accessToken: customAccessToken,
}: Types.AccessTokenOptions = {}): Promise<Types.TokenInfo> {
debugToken(): Promise<Types.TokenInfo> {
invariant(this.appId, 'App ID is required to debug token');

@@ -260,3 +253,3 @@ invariant(this.appSecret, 'App Secret is required to debug token');

params: {
input_token: customAccessToken || this.accessToken,
input_token: this.accessToken,
access_token: accessToken,

@@ -374,11 +367,5 @@ },

*/
getMessagingFeatureReview({
accessToken: customAccessToken,
}: Types.AccessTokenOptions = {}): Promise<Types.MessagingFeatureReview[]> {
getMessagingFeatureReview(): Promise<Types.MessagingFeatureReview[]> {
return this.axios
.get(
`/me/messaging_feature_review?access_token=${
customAccessToken || this.accessToken
}`
)
.get(`/me/messaging_feature_review?access_token=${this.accessToken}`)
.then((res) => res.data.data, handleError);

@@ -397,10 +384,7 @@ }

fields = ['id', 'name', 'first_name', 'last_name', 'profile_pic'],
accessToken: customAccessToken,
}: { fields?: Types.UserProfileField[]; accessToken?: string } = {}
}: { fields?: Types.UserProfileField[] } = {}
): Promise<Types.User> {
return this.axios
.get<Types.User>(
`/${userId}?fields=${fields.join(',')}&access_token=${
customAccessToken || this.accessToken
}`
`/${userId}?fields=${fields.join(',')}&access_token=${this.accessToken}`
)

@@ -415,10 +399,7 @@ .then((res) => res.data, handleError);

*/
getMessengerProfile(
fields: string[],
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<Types.MessengerProfile[]> {
getMessengerProfile(fields: string[]): Promise<Types.MessengerProfile[]> {
return this.axios
.get<{ data: Types.MessengerProfile[] }>(
`/me/messenger_profile?fields=${fields.join(',')}&access_token=${
customAccessToken || this.accessToken
this.accessToken
}`

@@ -430,10 +411,7 @@ )

setMessengerProfile(
profile: Types.MessengerProfile,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
profile: Types.MessengerProfile
): Promise<Types.MutationSuccessResponse> {
return this.axios
.post<Types.MutationSuccessResponse>(
`/me/messenger_profile?access_token=${
customAccessToken || this.accessToken
}`,
`/me/messenger_profile?access_token=${this.accessToken}`,
profile

@@ -445,10 +423,7 @@ )

deleteMessengerProfile(
fields: string[],
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
fields: string[]
): Promise<Types.MutationSuccessResponse> {
return this.axios
.delete<Types.MutationSuccessResponse>(
`/me/messenger_profile?access_token=${
customAccessToken || this.accessToken
}`,
`/me/messenger_profile?access_token=${this.accessToken}`,
{

@@ -468,8 +443,6 @@ data: {

*/
getGetStarted(
options: Types.AccessTokenOptions = {}
): Promise<{
getGetStarted(): Promise<{
payload: string;
} | null> {
return this.getMessengerProfile(['get_started'], options).then((res) =>
return this.getMessengerProfile(['get_started']).then((res) =>
res[0]

@@ -483,20 +456,12 @@ ? (res[0].getStarted as {

setGetStarted(
payload: string,
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.setMessengerProfile(
{
getStarted: {
payload,
},
setGetStarted(payload: string): Promise<Types.MutationSuccessResponse> {
return this.setMessengerProfile({
getStarted: {
payload,
},
options
);
});
}
deleteGetStarted(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['get_started'], options);
deleteGetStarted(): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['get_started']);
}

@@ -509,6 +474,4 @@

*/
getPersistentMenu(
options: Types.AccessTokenOptions = {}
): Promise<Types.PersistentMenu | null> {
return this.getMessengerProfile(['persistent_menu'], options).then((res) =>
getPersistentMenu(): Promise<Types.PersistentMenu | null> {
return this.getMessengerProfile(['persistent_menu']).then((res) =>
res[0] ? (res[0].persistentMenu as Types.PersistentMenu) : null

@@ -522,6 +485,4 @@ );

composerInputDisabled = false,
...options
}: {
composerInputDisabled?: boolean;
accessToken?: string;
} = {}

@@ -536,29 +497,21 @@ ): Promise<Types.MutationSuccessResponse> {

) {
return this.setMessengerProfile(
{
persistentMenu: menuItems as Types.PersistentMenu,
},
options
);
return this.setMessengerProfile({
persistentMenu: menuItems as Types.PersistentMenu,
});
}
// menuItems is in type MenuItem[]
return this.setMessengerProfile(
{
persistentMenu: [
{
locale: 'default',
composerInputDisabled,
callToActions: menuItems as Types.MenuItem[],
},
],
},
options
);
return this.setMessengerProfile({
persistentMenu: [
{
locale: 'default',
composerInputDisabled,
callToActions: menuItems as Types.MenuItem[],
},
],
});
}
deletePersistentMenu(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['persistent_menu'], options);
deletePersistentMenu(): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['persistent_menu']);
}

@@ -571,11 +524,6 @@

*/
getUserPersistentMenu(
userId: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<Types.PersistentMenu | null> {
getUserPersistentMenu(userId: string): Promise<Types.PersistentMenu | null> {
return this.axios
.get(
`/me/custom_user_settings?psid=${userId}&access_token=${
customAccessToken || this.accessToken
}`
`/me/custom_user_settings?psid=${userId}&access_token=${this.accessToken}`
)

@@ -596,6 +544,4 @@ .then(

composerInputDisabled = false,
accessToken: customAccessToken,
}: {
composerInputDisabled?: boolean;
accessToken?: string;
} = {}

@@ -612,5 +558,3 @@ ): Promise<Types.MutationSuccessResponse> {

.post<Types.MutationSuccessResponse>(
`/me/custom_user_settings?access_token=${
customAccessToken || this.accessToken
}`,
`/me/custom_user_settings?access_token=${this.accessToken}`,
{

@@ -626,17 +570,12 @@ psid: userId,

return this.axios
.post(
`/me/custom_user_settings?access_token=${
customAccessToken || this.accessToken
}`,
{
psid: userId,
persistentMenu: [
{
locale: 'default',
composerInputDisabled,
callToActions: menuItems as Types.MenuItem[],
},
],
}
)
.post(`/me/custom_user_settings?access_token=${this.accessToken}`, {
psid: userId,
persistentMenu: [
{
locale: 'default',
composerInputDisabled,
callToActions: menuItems as Types.MenuItem[],
},
],
})
.then((res) => res.data, handleError);

@@ -646,10 +585,7 @@ }

deleteUserPersistentMenu(
userId: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
userId: string
): Promise<Types.MutationSuccessResponse> {
return this.axios
.delete(
`/me/custom_user_settings?psid=${userId}&params=[%22persistent_menu%22]&access_token=${
customAccessToken || this.accessToken
}`
`/me/custom_user_settings?psid=${userId}&params=[%22persistent_menu%22]&access_token=${this.accessToken}`
)

@@ -664,6 +600,4 @@ .then((res) => res.data, handleError);

*/
getGreeting(
options: Types.AccessTokenOptions = {}
): Promise<Types.GreetingConfig[] | null> {
return this.getMessengerProfile(['greeting'], options).then((res) =>
getGreeting(): Promise<Types.GreetingConfig[] | null> {
return this.getMessengerProfile(['greeting']).then((res) =>
res[0] ? (res[0].greeting as Types.GreetingConfig[]) : null

@@ -674,31 +608,22 @@ );

setGreeting(
greeting: string | Types.GreetingConfig[],
options: Types.AccessTokenOptions = {}
greeting: string | Types.GreetingConfig[]
): Promise<Types.MutationSuccessResponse> {
if (typeof greeting === 'string') {
return this.setMessengerProfile(
{
greeting: [
{
locale: 'default',
text: greeting,
},
],
},
options
);
return this.setMessengerProfile({
greeting: [
{
locale: 'default',
text: greeting,
},
],
});
}
return this.setMessengerProfile(
{
greeting,
},
options
);
return this.setMessengerProfile({
greeting,
});
}
deleteGreeting(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['greeting'], options);
deleteGreeting(): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['greeting']);
}

@@ -711,6 +636,4 @@

*/
getIceBreakers(
options: Types.AccessTokenOptions = {}
): Promise<Types.IceBreaker[] | null> {
return this.getMessengerProfile(['ice_breakers'], options).then((res) =>
getIceBreakers(): Promise<Types.IceBreaker[] | null> {
return this.getMessengerProfile(['ice_breakers']).then((res) =>
res[0] ? (res[0].iceBreakers as Types.IceBreaker[]) : null

@@ -721,17 +644,11 @@ );

setIceBreakers(
iceBreakers: Types.IceBreaker[],
options: Types.AccessTokenOptions = {}
iceBreakers: Types.IceBreaker[]
): Promise<Types.MutationSuccessResponse> {
return this.setMessengerProfile(
{
iceBreakers,
},
options
);
return this.setMessengerProfile({
iceBreakers,
});
}
deleteIceBreakers(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['ice_breakers'], options);
deleteIceBreakers(): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['ice_breakers']);
}

@@ -744,27 +661,18 @@

*/
getWhitelistedDomains(
options: Types.AccessTokenOptions = {}
): Promise<string[] | null> {
return this.getMessengerProfile(
['whitelisted_domains'],
options
).then((res) => (res[0] ? (res[0].whitelistedDomains as string[]) : null));
getWhitelistedDomains(): Promise<string[] | null> {
return this.getMessengerProfile(['whitelisted_domains']).then((res) =>
res[0] ? (res[0].whitelistedDomains as string[]) : null
);
}
setWhitelistedDomains(
whitelistedDomains: string[],
options: Types.AccessTokenOptions = {}
whitelistedDomains: string[]
): Promise<Types.MutationSuccessResponse> {
return this.setMessengerProfile(
{
whitelistedDomains,
},
options
);
return this.setMessengerProfile({
whitelistedDomains,
});
}
deleteWhitelistedDomains(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['whitelisted_domains'], options);
deleteWhitelistedDomains(): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['whitelisted_domains']);
}

@@ -777,104 +685,21 @@

*/
getAccountLinkingURL(
options: Types.AccessTokenOptions = {}
): Promise<string | null> {
return this.getMessengerProfile(
['account_linking_url'],
options
).then((res) => (res[0] ? (res[0] as string) : null));
getAccountLinkingURL(): Promise<string | null> {
return this.getMessengerProfile(['account_linking_url']).then((res) =>
res[0] ? (res[0] as string) : null
);
}
setAccountLinkingURL(
accountLinkingUrl: string,
options: Types.AccessTokenOptions = {}
accountLinkingUrl: string
): Promise<Types.MutationSuccessResponse> {
return this.setMessengerProfile(
{
accountLinkingUrl,
},
options
);
return this.setMessengerProfile({
accountLinkingUrl,
});
}
deleteAccountLinkingURL(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['account_linking_url'], options);
deleteAccountLinkingURL(): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['account_linking_url']);
}
/**
* Chat Extension Home URL
*
* https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api/home-url
*/
getHomeURL(
options: Types.AccessTokenOptions = {}
): Promise<{
url: string;
webviewHeightRatio: 'tall';
webviewShareButton?: 'hide' | 'show';
inTest: boolean;
} | null> {
return this.getMessengerProfile(['home_url'], options).then((res) =>
res[0]
? (res[0] as {
url: string;
webviewHeightRatio: 'tall';
webviewShareButton?: 'hide' | 'show';
inTest: boolean;
})
: null
);
}
setHomeURL(
homeUrl: string,
{
webviewHeightRatio = 'tall',
webviewShareButton,
inTest,
}: {
webviewHeightRatio?: 'tall';
webviewShareButton?: 'hide' | 'show';
inTest: boolean;
},
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.setMessengerProfile(
{
homeUrl: {
url: homeUrl,
webviewHeightRatio,
inTest,
webviewShareButton,
},
},
options
);
}
deleteHomeURL(
options: Types.AccessTokenOptions = {}
): Promise<Types.MutationSuccessResponse> {
return this.deleteMessengerProfile(['home_url'], options);
}
/**
* Message tags
*
* https://developers.facebook.com/docs/messenger-platform/send-messages/message-tags
*/
getMessageTags({
accessToken: customAccessToken,
}: Types.AccessTokenOptions = {}): Promise<Types.MessageTagResponse> {
return this.axios
.get<{ data: Types.MessageTagResponse }>(
`/page_message_tags?access_token=${
customAccessToken || this.accessToken
}`
)
.then((res) => res.data.data, handleError);
}
/**
* Send API

@@ -887,7 +712,5 @@ *

): Promise<Types.SendMessageSuccessResponse> {
const { accessToken: customAccessToken } = body;
return this.axios
.post<Types.SendMessageSuccessResponse>(
`/me/messages?access_token=${customAccessToken || this.accessToken}`,
`/me/messages?access_token=${this.accessToken}`,
body

@@ -950,3 +773,3 @@ )

.post<Types.SendMessageSuccessResponse>(
`/me/messages?access_token=${options.accessToken || this.accessToken}`,
`/me/messages?access_token=${this.accessToken}`,
formdata,

@@ -1189,4 +1012,3 @@ {

psidOrRecipient: Types.PsidOrRecipient,
senderAction: Types.SenderAction,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
senderAction: Types.SenderAction
): Promise<Types.SendSenderActionResponse> {

@@ -1202,3 +1024,2 @@ const recipient =

senderAction,
accessToken: customAccessToken,
});

@@ -1208,20 +1029,17 @@ }

markSeen(
psidOrRecipient: Types.PsidOrRecipient,
options: Record<string, any> = {}
psidOrRecipient: Types.PsidOrRecipient
): Promise<Types.SendSenderActionResponse> {
return this.sendSenderAction(psidOrRecipient, 'mark_seen', options);
return this.sendSenderAction(psidOrRecipient, 'mark_seen');
}
typingOn(
psidOrRecipient: Types.PsidOrRecipient,
options: Record<string, any> = {}
psidOrRecipient: Types.PsidOrRecipient
): Promise<Types.SendSenderActionResponse> {
return this.sendSenderAction(psidOrRecipient, 'typing_on', options);
return this.sendSenderAction(psidOrRecipient, 'typing_on');
}
typingOff(
psidOrRecipient: Types.PsidOrRecipient,
options: Record<string, any> = {}
psidOrRecipient: Types.PsidOrRecipient
): Promise<Types.SendSenderActionResponse> {
return this.sendSenderAction(psidOrRecipient, 'typing_off', options);
return this.sendSenderAction(psidOrRecipient, 'typing_off');
}

@@ -1236,6 +1054,3 @@

batch: Types.BatchItem[],
{
includeHeaders = true,
accessToken: customAccessToken,
}: Types.AccessTokenOptions & { includeHeaders?: boolean } = {}
{ includeHeaders = true }: { includeHeaders?: boolean } = {}
): Promise<

@@ -1277,3 +1092,3 @@ {

.post('/', {
accessToken: customAccessToken || this.accessToken,
accessToken: this.accessToken,
includeHeaders,

@@ -1315,11 +1130,6 @@ batch: bodyEncodedbatch,

*/
createLabel(
name: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<{ id: string }> {
createLabel(name: string): Promise<{ id: string }> {
return this.axios
.post<{ id: string }>(
`/me/custom_labels?access_token=${
customAccessToken || this.accessToken
}`,
`/me/custom_labels?access_token=${this.accessToken}`,
{

@@ -1337,12 +1147,6 @@ name,

*/
associateLabel(
userId: string,
labelId: number,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<{ success: true }> {
associateLabel(userId: string, labelId: number): Promise<{ success: true }> {
return this.axios
.post<{ success: true }>(
`/${labelId}/label?access_token=${
customAccessToken || this.accessToken
}`,
`/${labelId}/label?access_token=${this.accessToken}`,
{

@@ -1360,12 +1164,6 @@ user: userId,

*/
dissociateLabel(
userId: string,
labelId: number,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<{ success: true }> {
dissociateLabel(userId: string, labelId: number): Promise<{ success: true }> {
return this.axios
.delete<{ success: true }>(
`/${labelId}/label?access_token=${
customAccessToken || this.accessToken
}`,
`/${labelId}/label?access_token=${this.accessToken}`,
{

@@ -1406,5 +1204,3 @@ data: { user: userId },

}>(
`/${userId}/custom_labels?fields=${fields}&access_token=${
options.accessToken || this.accessToken
}`
`/${userId}/custom_labels?fields=${fields}&access_token=${this.accessToken}`
)

@@ -1426,5 +1222,3 @@ .then((res) => res.data, handleError);

.get<{ name: string; id: string }>(
`/${labelId}?fields=${fields}&access_token=${
options.accessToken || this.accessToken
}`
`/${labelId}?fields=${fields}&access_token=${this.accessToken}`
)

@@ -1460,7 +1254,3 @@ .then((res) => res.data, handleError);

};
}>(
`/me/custom_labels?fields=${fields}&access_token=${
options.accessToken || this.accessToken
}`
)
}>(`/me/custom_labels?fields=${fields}&access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -1474,10 +1264,5 @@ }

*/
deleteLabel(
labelId: number,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<{ success: true }> {
deleteLabel(labelId: number): Promise<{ success: true }> {
return this.axios
.delete<{ success: true }>(
`/${labelId}?access_token=${customAccessToken || this.accessToken}`
)
.delete<{ success: true }>(`/${labelId}?access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -1537,8 +1322,3 @@ }

return this.axios
.post(
`/me/message_attachments?access_token=${
options.accessToken || this.accessToken
}`,
...args
)
.post(`/me/message_attachments?access_token=${this.accessToken}`, ...args)
.then((res) => res.data, handleError);

@@ -1593,10 +1373,7 @@ }

targetAppId: number,
metadata?: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
metadata?: string
): Promise<{ success: true }> {
return this.axios
.post<{ success: true }>(
`/me/pass_thread_control?access_token=${
customAccessToken || this.accessToken
}`,
`/me/pass_thread_control?access_token=${this.accessToken}`,
{

@@ -1613,11 +1390,5 @@ recipient: { id: recipientId },

recipientId: string,
metadata?: string,
options: Record<string, any> = {}
metadata?: string
): Promise<{ success: true }> {
return this.passThreadControl(
recipientId,
263902037430900,
metadata,
options
);
return this.passThreadControl(recipientId, 263902037430900, metadata);
}

@@ -1632,10 +1403,7 @@

recipientId: string,
metadata?: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
metadata?: string
): Promise<{ success: true }> {
return this.axios
.post<{ success: true }>(
`/me/take_thread_control?access_token=${
customAccessToken || this.accessToken
}`,
`/me/take_thread_control?access_token=${this.accessToken}`,
{

@@ -1656,10 +1424,7 @@ recipient: { id: recipientId },

recipientId: string,
metadata?: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
metadata?: string
): Promise<{ success: true }> {
return this.axios
.post<{ success: true }>(
`/me/request_thread_control?access_token=${
customAccessToken || this.accessToken
}`,
`/me/request_thread_control?access_token=${this.accessToken}`,
{

@@ -1678,5 +1443,3 @@ recipient: { id: recipientId },

*/
getSecondaryReceivers({
accessToken: customAccessToken,
}: Types.AccessTokenOptions = {}): Promise<
getSecondaryReceivers(): Promise<
{

@@ -1694,5 +1457,3 @@ id: string;

}>(
`/me/secondary_receivers?fields=id,name&access_token=${
customAccessToken || this.accessToken
}`
`/me/secondary_receivers?fields=id,name&access_token=${this.accessToken}`
)

@@ -1708,4 +1469,3 @@ .then((res) => res.data.data, handleError);

getThreadOwner(
recipientId: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
recipientId: string
): Promise<{

@@ -1724,5 +1484,3 @@ appId: string;

}>(
`/me/thread_owner?recipient=${recipientId}&access_token=${
customAccessToken || this.accessToken
}`
`/me/thread_owner?recipient=${recipientId}&access_token=${this.accessToken}`
)

@@ -1745,3 +1503,3 @@ .then((res) => res.data.data[0].threadOwner, handleError);

metric: metrics.join(','),
access_token: options.accessToken || this.accessToken,
access_token: this.accessToken,
...options,

@@ -1825,14 +1583,11 @@ })}`

// FIXME: [type] return type
setNLPConfigs(
config: Types.MessengerNLPConfig = {},
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<any> {
setNLPConfigs(config: Types.MessengerNLPConfig = {}): Promise<any> {
return this.axios
.post(
`/me/nlp_configs?${querystring.stringify(
snakecaseKeysDeep(config) as Record<string, any>
)}`,
{
accessToken: customAccessToken || this.accessToken,
}
snakecaseKeysDeep({
...config,
accessToken: this.accessToken,
}) as Record<string, any>
)}`
)

@@ -1843,9 +1598,9 @@ .then((res) => res.data, handleError);

// FIXME: [type] return type
enableNLP(options: Types.AccessTokenOptions = {}): Promise<any> {
return this.setNLPConfigs({ nlpEnabled: true }, options);
enableNLP(): Promise<any> {
return this.setNLPConfigs({ nlpEnabled: true });
}
// FIXME: [type] return type
disableNLP(options: Types.AccessTokenOptions = {}): Promise<any> {
return this.setNLPConfigs({ nlpEnabled: false }, options);
disableNLP(): Promise<any> {
return this.setNLPConfigs({ nlpEnabled: false });
}

@@ -1893,3 +1648,2 @@

page,
accessToken: customAccessToken,
}: {

@@ -1901,10 +1655,7 @@ field: string;

page?: string;
accessToken?: string;
}) {
const accessToken = customAccessToken || this.accessToken;
// $appsecret_proof= hash_hmac('sha256', $access_token, $app_secret);
const appsecretProof = crypto
.createHmac('sha256', appSecret)
.update(accessToken)
.update(this.accessToken)
.digest('hex');

@@ -1917,3 +1668,3 @@

.get(
`/${userId}/${field}?access_token=${accessToken}&appsecret_proof=${appsecretProof}${appQueryString}${pageQueryString}`
`/${userId}/${field}?access_token=${this.accessToken}&appsecret_proof=${appsecretProof}${appQueryString}${pageQueryString}`
)

@@ -1932,3 +1683,2 @@ .then((res) => res.data, handleError);

page,
accessToken,
}: {

@@ -1939,3 +1689,2 @@ userId: string;

page?: string;
accessToken?: string;
}) {

@@ -1948,3 +1697,2 @@ return this.getUserField({

page,
accessToken,
});

@@ -1962,3 +1710,2 @@ }

page,
accessToken,
}: {

@@ -1969,3 +1716,2 @@ userId: string;

page?: string;
accessToken?: string;
}) {

@@ -1978,3 +1724,2 @@ return this.getUserField({

page,
accessToken,
});

@@ -1994,9 +1739,6 @@ }

*/
createPersona(
persona: Types.Persona,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<{ id: string }> {
createPersona(persona: Types.Persona): Promise<{ id: string }> {
return this.axios
.post<{ id: string }>(
`/me/personas?access_token=${customAccessToken || this.accessToken}`,
`/me/personas?access_token=${this.accessToken}`,
persona

@@ -2013,4 +1755,3 @@ )

getPersona(
personaId: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
personaId: string
): Promise<{

@@ -2026,3 +1767,3 @@ id: string;

profilePictureUrl: string;
}>(`/${personaId}?access_token=${customAccessToken || this.accessToken}`)
}>(`/${personaId}?access_token=${this.accessToken}`)
.then((res) => res.data, handleError);

@@ -2037,4 +1778,3 @@ }

getPersonas(
cursor?: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
cursor?: string
): Promise<{

@@ -2057,3 +1797,3 @@ data: {

}>(
`/me/personas?access_token=${customAccessToken || this.accessToken}${
`/me/personas?access_token=${this.accessToken}${
cursor ? `&after=${cursor}` : ''

@@ -2065,5 +1805,3 @@ }`

async getAllPersonas({
accessToken: customAccessToken,
}: Types.AccessTokenOptions = {}): Promise<
async getAllPersonas(): Promise<
{

@@ -2094,5 +1832,3 @@ id: string;

// eslint-disable-next-line no-await-in-loop
} = await this.getPersonas(cursor, {
accessToken: customAccessToken,
});
} = await this.getPersonas(cursor);

@@ -2111,9 +1847,6 @@ allPersonas = allPersonas.concat(data);

*/
deletePersona(
personaId: string,
{ accessToken: customAccessToken }: Types.AccessTokenOptions = {}
): Promise<{ success: true }> {
deletePersona(personaId: string): Promise<{ success: true }> {
return this.axios
.delete<{ success: true }>(
`/${personaId}?access_token=${customAccessToken || this.accessToken}`
`/${personaId}?access_token=${this.accessToken}`
)

@@ -2120,0 +1853,0 @@ .then((res) => res.data, handleError);

@@ -179,10 +179,5 @@ import fs from 'fs';

export type AccessTokenOptions = {
accessToken?: string;
};
export type InsightOptions = {
since?: number;
until?: number;
accessToken?: string;
};

@@ -194,3 +189,2 @@

quickReplies?: QuickReply[];
accessToken?: string;
};

@@ -201,3 +195,2 @@

isReusable?: boolean;
accessToken?: string;
};

@@ -204,0 +197,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc