messaging-api-messenger
Advanced tools
Comparing version 0.6.6 to 0.6.9
@@ -183,6 +183,2 @@ 'use strict';Object.defineProperty(exports, "__esModule", { value: true });var _extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;}; | ||
/** | ||
@@ -1638,3 +1634,3 @@ * Get User Profile | ||
* Given a user ID for a Page (associated with a bot), retrieve the IDs for other Pages owned by the same business | ||
*/}exports.default = MessengerClient;MessengerClient.connect = (accessToken, version = '2.11') => new MessengerClient(accessToken, version);var _initialiseProps = function _initialiseProps() {this.getPageInfo = ({ access_token: customAccessToken } = {}) => this._axios.get(`/me?access_token=${customAccessToken || this._accessToken}`).then(res => res.data, handleError);this.createSubscription = ({ app_id: appId, object = 'page', callback_url, fields = ['messages', 'messaging_postbacks', 'messaging_optins', 'messaging_referrals', 'messaging_handovers', 'messaging_policy_enforcement'], include_values, verify_token, access_token: customAccessToken }) => this._axios.post(`/${appId}/subscriptions?access_token=${customAccessToken || this._accessToken}`, { object, callback_url, fields: fields.join(','), include_values, verify_token }).then(res => res.data, handleError);this.getUserProfile = (userId, { access_token: customAccessToken } = {}) => this._axios.get(`/${userId}?access_token=${customAccessToken || this._accessToken}`).then(res => res.data, handleError);this.getMessengerProfile = (fields, { access_token: customAccessToken } = {}) => this._axios.get(`/me/messenger_profile?fields=${fields.join(',')}&access_token=${customAccessToken || this._accessToken}`).then(res => res.data.data, handleError);this.setMessengerProfile = (profile, { access_token: customAccessToken } = {}) => this._axios.post(`/me/messenger_profile?access_token=${customAccessToken || this._accessToken}`, profile).then(res => res.data, handleError);this.deleteMessengerProfile = (fields, { access_token: customAccessToken } = {}) => this._axios.delete(`/me/messenger_profile?access_token=${customAccessToken || this._accessToken}`, { data: { fields } }).then(res => res.data, handleError);this.getGetStarted = (options = {}) => this.getMessengerProfile(['get_started'], options).then(res => res[0] ? res[0].get_started : null);this.setGetStarted = (payload, options = {}) => this.setMessengerProfile({ get_started: { payload } }, options);this.deleteGetStarted = (options = {}) => this.deleteMessengerProfile(['get_started'], options);this.getPersistentMenu = (options = {}) => this.getMessengerProfile(['persistent_menu'], options).then(res => res[0] ? res[0].persistent_menu : null);this.setPersistentMenu = (menuItems, _ref = {}) => {var _ref$composer_input_d = _ref.composer_input_disabled;let composerInputDisabled = _ref$composer_input_d === undefined ? false : _ref$composer_input_d,options = _objectWithoutProperties(_ref, ['composer_input_disabled']); // menuItems is in type PersistentMenu | ||
*/}exports.default = MessengerClient;MessengerClient.connect = (accessToken, version = '2.11') => new MessengerClient(accessToken, version);var _initialiseProps = function _initialiseProps() {this.getPageInfo = ({ access_token: customAccessToken } = {}) => this._axios.get(`/me?access_token=${customAccessToken || this._accessToken}`).then(res => res.data, handleError);this.createSubscription = ({ app_id: appId, object = 'page', callback_url, fields = ['messages', 'messaging_postbacks', 'messaging_optins', 'messaging_referrals', 'messaging_handovers', 'messaging_policy_enforcement'], include_values, verify_token, access_token: appAccessToken }) => this._axios.post(`/${appId}/subscriptions?access_token=${appAccessToken}`, { object, callback_url, fields: fields.join(','), include_values, verify_token }).then(res => res.data, handleError);this.getUserProfile = (userId, { access_token: customAccessToken } = {}) => this._axios.get(`/${userId}?access_token=${customAccessToken || this._accessToken}`).then(res => res.data, handleError);this.getMessengerProfile = (fields, { access_token: customAccessToken } = {}) => this._axios.get(`/me/messenger_profile?fields=${fields.join(',')}&access_token=${customAccessToken || this._accessToken}`).then(res => res.data.data, handleError);this.setMessengerProfile = (profile, { access_token: customAccessToken } = {}) => this._axios.post(`/me/messenger_profile?access_token=${customAccessToken || this._accessToken}`, profile).then(res => res.data, handleError);this.deleteMessengerProfile = (fields, { access_token: customAccessToken } = {}) => this._axios.delete(`/me/messenger_profile?access_token=${customAccessToken || this._accessToken}`, { data: { fields } }).then(res => res.data, handleError);this.getGetStarted = (options = {}) => this.getMessengerProfile(['get_started'], options).then(res => res[0] ? res[0].get_started : null);this.setGetStarted = (payload, options = {}) => this.setMessengerProfile({ get_started: { payload } }, options);this.deleteGetStarted = (options = {}) => this.deleteMessengerProfile(['get_started'], options);this.getPersistentMenu = (options = {}) => this.getMessengerProfile(['persistent_menu'], options).then(res => res[0] ? res[0].persistent_menu : null);this.setPersistentMenu = (menuItems, _ref = {}) => {var _ref$composer_input_d = _ref.composer_input_disabled;let composerInputDisabled = _ref$composer_input_d === undefined ? false : _ref$composer_input_d,options = _objectWithoutProperties(_ref, ['composer_input_disabled']); // menuItems is in type PersistentMenu | ||
if (menuItems.some(item => item.locale === 'default')) {return this.setMessengerProfile({ persistent_menu: menuItems }, options);} // menuItems is in type Array<MenuItem> | ||
@@ -1641,0 +1637,0 @@ return this.setMessengerProfile({ persistent_menu: [{ locale: 'default', composer_input_disabled: composerInputDisabled, call_to_actions: menuItems }] }, options);};this.deletePersistentMenu = (options = {}) => this.deleteMessengerProfile(['persistent_menu'], options);this.getGreeting = (options = {}) => this.getMessengerProfile(['greeting'], options).then(res => res[0] ? res[0].greeting : null);this.setGreeting = (greeting, options = {}) => {if (typeof greeting === 'string') {return this.setMessengerProfile({ greeting: [{ locale: 'default', text: greeting }] }, options);}return this.setMessengerProfile({ greeting }, options);};this.deleteGreeting = (options = {}) => this.deleteMessengerProfile(['greeting'], options);this.getWhitelistedDomains = (options = {}) => this.getMessengerProfile(['whitelisted_domains'], options).then(res => res[0] ? res[0].whitelisted_domains : null);this.setWhitelistedDomains = (domains, options = {}) => this.setMessengerProfile({ whitelisted_domains: domains }, options);this.deleteWhitelistedDomains = (options = {}) => this.deleteMessengerProfile(['whitelisted_domains'], options);this.getAccountLinkingURL = (options = {}) => this.getMessengerProfile(['account_linking_url'], options).then(res => res[0] ? res[0] : null);this.setAccountLinkingURL = (url, options = {}) => this.setMessengerProfile({ account_linking_url: url }, options);this.deleteAccountLinkingURL = (options = {}) => this.deleteMessengerProfile(['account_linking_url'], options);this.getPaymentSettings = (options = {}) => this.getMessengerProfile(['payment_settings'], options).then(res => res[0] ? res[0] : null);this.setPaymentPrivacyPolicyURL = (url, options = {}) => this.setMessengerProfile({ payment_settings: { privacy_url: url } }, options);this.setPaymentPublicKey = (key, options = {}) => this.setMessengerProfile({ payment_settings: { public_key: key } }, options);this.setPaymentTestUsers = (users, options = {}) => this.setMessengerProfile({ payment_settings: { test_users: users } }, options);this.deletePaymentSettings = (options = {}) => this.deleteMessengerProfile(['payment_settings'], options);this.getTargetAudience = (options = {}) => this.getMessengerProfile(['target_audience'], options).then(res => res[0] ? res[0] : null);this.setTargetAudience = (type, whitelist = [], blacklist = [], options = {}) => this.setMessengerProfile({ target_audience: { audience_type: type, countries: { whitelist, blacklist } } }, options);this.deleteTargetAudience = (options = {}) => this.deleteMessengerProfile(['target_audience'], options);this.getHomeURL = (options = {}) => this.getMessengerProfile(['home_url'], options).then(res => res[0] ? res[0] : null);this.setHomeURL = (url, { webview_share_button, in_test }, options = {}) => this.setMessengerProfile({ home_url: { url, webview_height_ratio: 'tall', in_test, webview_share_button } }, options);this.deleteHomeURL = (options = {}) => this.deleteMessengerProfile(['home_url'], options);this.getMessageTags = ({ access_token: customAccessToken } = {}) => this._axios.get(`/page_message_tags?access_token=${customAccessToken || this._accessToken}`).then(res => res.data.data, handleError);this.sendRawBody = body => {const customAccessToken = body.access_token;return this._axios.post(`/me/messages?access_token=${customAccessToken || this._accessToken}`, body).then(res => res.data, handleError);};this.sendMessage = (idOrRecipient, message, options = {}) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;let messageType = 'UPDATE';if (options.messaging_type) {messageType = options.messaging_type;} else if (options.tag) {messageType = 'MESSAGE_TAG';}const quickReplies = options.quick_replies,otherOptions = _objectWithoutProperties(options, ['quick_replies']);if (quickReplies && Array.isArray(quickReplies) && quickReplies.length >= 1) {validateQuickReplies(quickReplies);message.quick_replies = quickReplies; // eslint-disable-line no-param-reassign |
{ | ||
"name": "messaging-api-messenger", | ||
"description": "Messaging API client for Messenger", | ||
"version": "0.6.6", | ||
"version": "0.6.9", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=6" |
@@ -163,3 +163,3 @@ /* @flow */ | ||
verify_token, | ||
access_token: customAccessToken, | ||
access_token: appAccessToken, | ||
}: { | ||
@@ -172,16 +172,12 @@ app_id: string, | ||
verify_token: string, | ||
access_token?: string, | ||
access_token: string, | ||
}): Promise<{ success: boolean }> => | ||
this._axios | ||
.post( | ||
`/${appId}/subscriptions?access_token=${customAccessToken || | ||
this._accessToken}`, | ||
{ | ||
object, | ||
callback_url, | ||
fields: fields.join(','), | ||
include_values, | ||
verify_token, | ||
} | ||
) | ||
.post(`/${appId}/subscriptions?access_token=${appAccessToken}`, { | ||
object, | ||
callback_url, | ||
fields: fields.join(','), | ||
include_values, | ||
verify_token, | ||
}) | ||
.then(res => res.data, handleError); | ||
@@ -188,0 +184,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
349857
2919
7533