messaging-api-messenger
Advanced tools
Comparing version 0.4.4 to 0.4.7
@@ -1,2 +0,4 @@ | ||
'use strict';var _Messenger = require('./Messenger');var _Messenger2 = _interopRequireDefault(_Messenger); | ||
'use strict'; | ||
var _Messenger = require('./Messenger');var _Messenger2 = _interopRequireDefault(_Messenger); | ||
var _MessengerClient = require('./MessengerClient');var _MessengerClient2 = _interopRequireDefault(_MessengerClient);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
@@ -3,0 +5,0 @@ |
@@ -9,2 +9,4 @@ '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;}; | ||
function createRequest(body) { | ||
@@ -11,0 +13,0 @@ return { |
@@ -1,3 +0,5 @@ | ||
'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;};var _querystring = require('querystring');var _querystring2 = _interopRequireDefault(_querystring); | ||
'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;}; | ||
var _querystring = require('querystring');var _querystring2 = _interopRequireDefault(_querystring); | ||
var _axios = require('axios');var _axios2 = _interopRequireDefault(_axios); | ||
@@ -50,2 +52,3 @@ var _formData = require('form-data');var _formData2 = _interopRequireDefault(_formData); | ||
class MessengerClient { | ||
@@ -532,2 +535,6 @@ | ||
/** | ||
@@ -768,2 +775,3 @@ * Templates | ||
/** | ||
@@ -884,11 +892,11 @@ * Upload API | ||
if (menuItems.some(item => item.locale === 'default')) {return this.setMessengerProfile({ persistent_menu: menuItems });} // menuItems is in type Array<MenuItem> | ||
return this.setMessengerProfile({ persistent_menu: [{ locale: 'default', composer_input_disabled: composerInputDisabled, call_to_actions: menuItems }] });};this.deletePersistentMenu = () => this.deleteMessengerProfile(['persistent_menu']);this.getGreetingText = () => this.getMessengerProfile(['greeting']).then(res => res[0].greeting);this.setGreetingText = greeting => {if (typeof greeting === 'string') {return this.setMessengerProfile({ greeting: [{ locale: 'default', text: greeting }] });}return this.setMessengerProfile({ greeting });};this.deleteGreetingText = () => this.deleteMessengerProfile(['greeting']);this.getDomainWhitelist = () => {(0, _warning2.default)(false, '`getDomainWhitelist` is deprecated. use `getWhitelistedDomains` instead.');return this.getWhitelistedDomains();};this.setDomainWhitelist = domains => {(0, _warning2.default)(false, '`setDomainWhitelist` is deprecated. use `setWhitelistedDomains` instead.');return this.setWhitelistedDomains(domains);};this.deleteDomainWhitelist = () => {(0, _warning2.default)(false, '`deleteDomainWhitelist` is deprecated. use `deleteWhitelistedDomains` instead.');return this.deleteWhitelistedDomains();};this.getWhitelistedDomains = () => this.getMessengerProfile(['whitelisted_domains']).then(res => res[0].whitelisted_domains);this.setWhitelistedDomains = domains => this.setMessengerProfile({ whitelisted_domains: domains });this.deleteWhitelistedDomains = () => this.deleteMessengerProfile(['whitelisted_domains']);this.getAccountLinkingURL = () => this.getMessengerProfile(['account_linking_url']).then(res => res[0]);this.setAccountLinkingURL = url => this.setMessengerProfile({ account_linking_url: url });this.deleteAccountLinkingURL = () => this.deleteMessengerProfile(['account_linking_url']);this.getPaymentSettings = () => this.getMessengerProfile(['payment_settings']).then(res => res[0]);this.setPaymentPrivacyPolicyURL = url => this.setMessengerProfile({ payment_settings: { privacy_url: url } });this.setPaymentPublicKey = key => this.setMessengerProfile({ payment_settings: { public_key: key } });this.setPaymentTestUsers = users => this.setMessengerProfile({ payment_settings: { test_users: users } });this.deletePaymentSettings = () => this.deleteMessengerProfile(['payment_settings']);this.getTargetAudience = () => this.getMessengerProfile(['target_audience']).then(res => res[0]);this.setTargetAudience = (type, whitelist = [], blacklist = []) => this.setMessengerProfile({ target_audience: { audience_type: type, countries: { whitelist, blacklist } } });this.deleteTargetAudience = () => this.deleteMessengerProfile(['target_audience']);this.getChatExtensionHomeURL = () => this.getMessengerProfile(['home_url']).then(res => res[0]);this.setChatExtensionHomeURL = (url, { webview_height_ratio, webview_share_button, in_test }) => this.setMessengerProfile({ home_url: { url, webview_height_ratio, in_test, webview_share_button } });this.deleteChatExtensionHomeURL = () => this.deleteMessengerProfile(['home_url']);this.getMessageTags = () => this._http.get(`/page_message_tags?access_token=${this._accessToken}`).then(res => res.data.data);this.sendRawBody = body => this._http.post(`/me/messages?access_token=${this._accessToken}`, body).then(res => res.data);this.sendMessage = (idOrRecipient, message, options) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody(_extends({ recipient, message }, options));};this.sendMessageFormData = (recipient, message, filedata) => {const form = new _formData2.default();const recipientObject = typeof recipient === 'string' ? { id: recipient } : recipient;form.append('recipient', JSON.stringify(recipientObject));form.append('message', JSON.stringify(message));form.append('filedata', filedata);return this._http.post(`/me/messages?access_token=${this._accessToken}`, form, { headers: form.getHeaders() }).then(res => res.data);};this.sendAttachment = (recipient, attachment, options) => this.sendMessage(recipient, { attachment }, options);this.sendAttachmentFormData = (recipient, attachment, filedata) => this.sendMessageFormData(recipient, { attachment }, filedata);this.sendText = (recipient, text, options) => this.sendMessage(recipient, { text }, options);this.sendAudio = (recipient, audio) => {const attachment = { type: 'audio', payload: {} };if (typeof audio === 'string') {attachment.payload.url = audio;return this.sendAttachment(recipient, attachment);} else if (audio && (0, _isPlainObject2.default)(audio)) {attachment.payload = audio;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, audio);};this.sendImage = (recipient, image) => {const attachment = { type: 'image', payload: {} };if (typeof image === 'string') {attachment.payload.url = image;return this.sendAttachment(recipient, attachment);} else if (image && (0, _isPlainObject2.default)(image)) {attachment.payload = image;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, image);};this.sendVideo = (recipient, video) => {const attachment = { type: 'video', payload: {} };if (typeof video === 'string') {attachment.payload.url = video;return this.sendAttachment(recipient, attachment);} else if (video && (0, _isPlainObject2.default)(video)) {attachment.payload = video;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, video);};this.sendFile = (recipient, file) => {const attachment = { type: 'file', payload: {} };if (typeof file === 'string') {attachment.payload.url = file;return this.sendAttachment(recipient, attachment);} else if (file && (0, _isPlainObject2.default)(file)) {attachment.payload = file;return this.sendAttachment(recipient, attachment);}return this.sendAttachmentFormData(recipient, attachment, file);};this.sendTemplate = (recipient, payload, options) => this.sendAttachment(recipient, { type: 'template', payload }, options);this.sendButtonTemplate = (recipient, text, buttons) => this.sendTemplate(recipient, { template_type: 'button', text, buttons });this.sendGenericTemplate = (recipient, elements, options = {}) => this.sendTemplate(recipient, { template_type: 'generic', elements, image_aspect_ratio: options.image_aspect_ratio || 'horizontal' }, (0, _lodash2.default)(options, ['image_aspect_ratio']));this.sendListTemplate = (recipient, elements, buttons, options = {}) => this.sendTemplate(recipient, { template_type: 'list', elements, buttons, top_element_style: options.top_element_style || 'large' });this.sendOpenGraphTemplate = (recipient, elements) => this.sendTemplate(recipient, { template_type: 'open_graph', elements });this.sendReceiptTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'receipt' }, attrs));this.sendAirlineBoardingPassTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_boardingpass' }, attrs));this.sendAirlineCheckinTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_checkin' }, attrs));this.sendAirlineItineraryTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_itinerary' }, attrs));this.sendAirlineFlightUpdateTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_update' }, attrs));this.sendQuickReplies = (recipient, textOrAttachment, quickReplies) => {// quick_replies is limited to 11 | ||
return this.setMessengerProfile({ persistent_menu: [{ locale: 'default', composer_input_disabled: composerInputDisabled, call_to_actions: menuItems }] });};this.deletePersistentMenu = () => this.deleteMessengerProfile(['persistent_menu']);this.getGreetingText = () => this.getMessengerProfile(['greeting']).then(res => res[0].greeting);this.setGreetingText = greeting => {if (typeof greeting === 'string') {return this.setMessengerProfile({ greeting: [{ locale: 'default', text: greeting }] });}return this.setMessengerProfile({ greeting });};this.deleteGreetingText = () => this.deleteMessengerProfile(['greeting']);this.getDomainWhitelist = () => {(0, _warning2.default)(false, '`getDomainWhitelist` is deprecated. use `getWhitelistedDomains` instead.');return this.getWhitelistedDomains();};this.setDomainWhitelist = domains => {(0, _warning2.default)(false, '`setDomainWhitelist` is deprecated. use `setWhitelistedDomains` instead.');return this.setWhitelistedDomains(domains);};this.deleteDomainWhitelist = () => {(0, _warning2.default)(false, '`deleteDomainWhitelist` is deprecated. use `deleteWhitelistedDomains` instead.');return this.deleteWhitelistedDomains();};this.getWhitelistedDomains = () => this.getMessengerProfile(['whitelisted_domains']).then(res => res[0].whitelisted_domains);this.setWhitelistedDomains = domains => this.setMessengerProfile({ whitelisted_domains: domains });this.deleteWhitelistedDomains = () => this.deleteMessengerProfile(['whitelisted_domains']);this.getAccountLinkingURL = () => this.getMessengerProfile(['account_linking_url']).then(res => res[0]);this.setAccountLinkingURL = url => this.setMessengerProfile({ account_linking_url: url });this.deleteAccountLinkingURL = () => this.deleteMessengerProfile(['account_linking_url']);this.getPaymentSettings = () => this.getMessengerProfile(['payment_settings']).then(res => res[0]);this.setPaymentPrivacyPolicyURL = url => this.setMessengerProfile({ payment_settings: { privacy_url: url } });this.setPaymentPublicKey = key => this.setMessengerProfile({ payment_settings: { public_key: key } });this.setPaymentTestUsers = users => this.setMessengerProfile({ payment_settings: { test_users: users } });this.deletePaymentSettings = () => this.deleteMessengerProfile(['payment_settings']);this.getTargetAudience = () => this.getMessengerProfile(['target_audience']).then(res => res[0]);this.setTargetAudience = (type, whitelist = [], blacklist = []) => this.setMessengerProfile({ target_audience: { audience_type: type, countries: { whitelist, blacklist } } });this.deleteTargetAudience = () => this.deleteMessengerProfile(['target_audience']);this.getChatExtensionHomeURL = () => this.getMessengerProfile(['home_url']).then(res => res[0]);this.setChatExtensionHomeURL = (url, { webview_height_ratio, webview_share_button, in_test }) => this.setMessengerProfile({ home_url: { url, webview_height_ratio, in_test, webview_share_button } });this.deleteChatExtensionHomeURL = () => this.deleteMessengerProfile(['home_url']);this.getMessageTags = () => this._http.get(`/page_message_tags?access_token=${this._accessToken}`).then(res => res.data.data);this.sendRawBody = body => this._http.post(`/me/messages?access_token=${this._accessToken}`, body).then(res => res.data);this.sendMessage = (idOrRecipient, message, options) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody(_extends({ recipient, message }, options));};this.sendMessageFormData = (recipient, message, filedata) => {const form = new _formData2.default();const recipientObject = typeof recipient === 'string' ? { id: recipient } : recipient;form.append('recipient', JSON.stringify(recipientObject));form.append('message', JSON.stringify(message));form.append('filedata', filedata);return this._http.post(`/me/messages?access_token=${this._accessToken}`, form, { headers: form.getHeaders() }).then(res => res.data);};this.sendAttachment = (recipient, attachment, options) => this.sendMessage(recipient, { attachment }, options);this.sendAttachmentFormData = (recipient, attachment, filedata) => this.sendMessageFormData(recipient, { attachment }, filedata);this.sendText = (recipient, text, options) => this.sendMessage(recipient, { text }, options);this.sendAudio = (recipient, audio) => {const attachment = { type: 'audio', payload: {} };if (typeof audio === 'string') {attachment.payload.url = audio;return this.sendAttachment(recipient, attachment);} else if (audio && (0, _isPlainObject2.default)(audio)) {attachment.payload = audio;return this.sendAttachment(recipient, attachment);} // $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, audio);};this.sendImage = (recipient, image) => {const attachment = { type: 'image', payload: {} };if (typeof image === 'string') {attachment.payload.url = image;return this.sendAttachment(recipient, attachment);} else if (image && (0, _isPlainObject2.default)(image)) {attachment.payload = image;return this.sendAttachment(recipient, attachment);} // $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, image);};this.sendVideo = (recipient, video) => {const attachment = { type: 'video', payload: {} };if (typeof video === 'string') {attachment.payload.url = video;return this.sendAttachment(recipient, attachment);} else if (video && (0, _isPlainObject2.default)(video)) {attachment.payload = video;return this.sendAttachment(recipient, attachment);} // $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, video);};this.sendFile = (recipient, file) => {const attachment = { type: 'file', payload: {} };if (typeof file === 'string') {attachment.payload.url = file;return this.sendAttachment(recipient, attachment);} else if (file && (0, _isPlainObject2.default)(file)) {attachment.payload = file;return this.sendAttachment(recipient, attachment);} // $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, file);};this.sendTemplate = (recipient, payload, options) => this.sendAttachment(recipient, { type: 'template', payload }, options);this.sendButtonTemplate = (recipient, text, buttons) => this.sendTemplate(recipient, { template_type: 'button', text, buttons });this.sendGenericTemplate = (recipient, elements, options = {}) => this.sendTemplate(recipient, { template_type: 'generic', elements, image_aspect_ratio: options.image_aspect_ratio || 'horizontal' }, (0, _lodash2.default)(options, ['image_aspect_ratio']));this.sendListTemplate = (recipient, elements, buttons, options = {}) => this.sendTemplate(recipient, { template_type: 'list', elements, buttons, top_element_style: options.top_element_style || 'large' });this.sendOpenGraphTemplate = (recipient, elements) => this.sendTemplate(recipient, { template_type: 'open_graph', elements });this.sendReceiptTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'receipt' }, attrs));this.sendAirlineBoardingPassTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_boardingpass' }, attrs));this.sendAirlineCheckinTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_checkin' }, attrs));this.sendAirlineItineraryTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_itinerary' }, attrs));this.sendAirlineFlightUpdateTemplate = (recipient, attrs) => this.sendTemplate(recipient, _extends({ template_type: 'airline_update' }, attrs));this.sendQuickReplies = (recipient, textOrAttachment, quickReplies) => {// quick_replies is limited to 11 | ||
(0, _invariant2.default)(Array.isArray(quickReplies) && quickReplies.length <= 11, 'quickReplies is an array and limited to 11');quickReplies.forEach(quickReply => {if (quickReply.content_type === 'text') {// title has a 20 character limit, after that it gets truncated | ||
(0, _invariant2.default)(quickReply.title.trim().length <= 20, 'title of quickReply has a 20 character limit, after that it gets truncated'); // payload has a 1000 character limit | ||
(0, _invariant2.default)(quickReply.payload.length <= 1000, 'payload of quickReply has a 1000 character limit');}});return this.sendMessage(recipient, _extends({}, textOrAttachment, { quick_replies: quickReplies }));};this.sendSenderAction = (idOrRecipient, action) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody({ recipient, sender_action: action });};this.markSeen = recipient => this.sendSenderAction(recipient, 'mark_seen');this.typingOn = recipient => this.sendSenderAction(recipient, 'typing_on');this.typingOff = recipient => this.sendSenderAction(recipient, 'typing_off');this.sendBatch = batch => {(0, _invariant2.default)(batch.length <= 50, 'limit the number of requests which can be in a batch to 50');const bodyEncodedbatch = batch.map(item => {if (item.body) {return _extends({}, item, { body: Object.keys(item.body).map(key => {const val = item.body[key];return `${encodeURIComponent(key)}=${encodeURIComponent(typeof val === 'object' ? JSON.stringify(val) : val)}`;}).join('&') });}return item;});return _axios2.default.post('https://graph.facebook.com/', { access_token: this._accessToken, batch: bodyEncodedbatch }).then(res => res.data);};this.uploadAttachment = (type, url) => this._http.post(`/me/message_attachments?access_token=${this._accessToken}`, { message: { attachment: { type, payload: { url, is_reusable: true } } } }).then(res => res.data);this.uploadAudio = url => this.uploadAttachment('audio', url);this.uploadImage = url => this.uploadAttachment('image', url);this.uploadVideo = url => this.uploadAttachment('video', url);this.uploadFile = url => this.uploadAttachment('file', url);this.generateMessengerCode = (options = {}) => this._http.post(`/me/messenger_codes?access_token=${this._accessToken}`, _extends({ type: 'standard' }, options)).then(res => res.data);this.passThreadControl = (recipientId, targetAppId, metadata) => this._http.post(`/me/pass_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, target_app_id: targetAppId, metadata }).then(res => res.data);this.takeThreadControl = (recipientId, metadata) => this._http.post(`/me/take_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, metadata }).then(res => res.data);this.getSecondaryReceivers = () => this._http.get(`/me/secondary_receivers?fields=id,name&access_token=${this._accessToken}`).then(res => res.data.data);this.getDailyUniqueActiveThreadCounts = () => this._http.get(`/me/insights/page_messages_active_threads_unique&access_token=${this._accessToken}`).then(res => res.data.data);this.getDailyUniqueConversationCounts = () => this._http.get(`/me/insights/page_messages_feedback_by_action_unique&access_token=${this._accessToken}`).then(res => res.data.data);this.setNLPConfigs = (config = {}) => {const query = { nlp_enabled: config.nlp_enabled ? 'true' : 'false' };if (config.custom_token) { | ||
query.custom_token = config.custom_token; | ||
} | ||
return this._http. | ||
post(`/me/nlp_configs?${_querystring2.default.stringify(query)}`, { | ||
(0, _invariant2.default)(quickReply.payload.length <= 1000, 'payload of quickReply has a 1000 character limit');}});return this.sendMessage(recipient, _extends({}, textOrAttachment, { quick_replies: quickReplies }));};this.sendSenderAction = (idOrRecipient, action) => {const recipient = typeof idOrRecipient === 'string' ? { id: idOrRecipient } : idOrRecipient;return this.sendRawBody({ recipient, sender_action: action });};this.markSeen = recipient => this.sendSenderAction(recipient, 'mark_seen');this.typingOn = recipient => this.sendSenderAction(recipient, 'typing_on');this.typingOff = recipient => this.sendSenderAction(recipient, 'typing_off');this.sendBatch = batch => {(0, _invariant2.default)(batch.length <= 50, 'limit the number of requests which can be in a batch to 50');const bodyEncodedbatch = batch.map(item => {if (item.body) {return _extends({}, item, { body: Object.keys(item.body).map(key => {// $FlowFixMe item.body should not possible as undefined. | ||
const val = item.body[key];return `${encodeURIComponent(key)}=${encodeURIComponent(typeof val === 'object' ? JSON.stringify(val) : val)}`;}).join('&') });}return item;});return _axios2.default.post('https://graph.facebook.com/', { access_token: this._accessToken, batch: bodyEncodedbatch }).then(res => res.data);};this.uploadAttachment = (type, url) => this._http.post(`/me/message_attachments?access_token=${this._accessToken}`, { message: { attachment: { type, payload: { url, is_reusable: true } } } }).then(res => res.data);this.uploadAudio = url => this.uploadAttachment('audio', url);this.uploadImage = url => this.uploadAttachment('image', url);this.uploadVideo = url => this.uploadAttachment('video', url);this.uploadFile = url => this.uploadAttachment('file', url);this.generateMessengerCode = (options = {}) => this._http.post(`/me/messenger_codes?access_token=${this._accessToken}`, _extends({ type: 'standard' }, options)).then(res => res.data);this.passThreadControl = (recipientId, targetAppId, metadata) => this._http.post(`/me/pass_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, target_app_id: targetAppId, metadata }).then(res => res.data);this.takeThreadControl = (recipientId, metadata) => this._http.post(`/me/take_thread_control?access_token=${this._accessToken}`, { recipient: { id: recipientId }, metadata }).then(res => res.data);this.getSecondaryReceivers = () => this._http.get(`/me/secondary_receivers?fields=id,name&access_token=${this._accessToken}`).then(res => res.data.data);this.getDailyUniqueActiveThreadCounts = () => this._http.get(`/me/insights/page_messages_active_threads_unique&access_token=${this._accessToken}`).then(res => res.data.data);this.getDailyUniqueConversationCounts = () => this._http.get(`/me/insights/page_messages_feedback_by_action_unique&access_token=${this._accessToken}`).then(res => res.data.data);this.setNLPConfigs = (config = {}) => {const query = { nlp_enabled: config.nlp_enabled ? 'true' : 'false' };if (config.custom_token) {query.custom_token = config.custom_token;}return this._http.post(`/me/nlp_configs?${_querystring2.default.stringify(query)}`, { | ||
access_token: this._accessToken }). | ||
@@ -895,0 +903,0 @@ |
'use strict'; | ||
var _fs = require('fs');var _fs2 = _interopRequireDefault(_fs);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} |
{ | ||
"name": "messaging-api-messenger", | ||
"description": "Messaging API client for Messenger", | ||
"version": "0.4.4", | ||
"version": "0.4.7", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=6" |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
import Messenger from './Messenger'; | ||
@@ -2,0 +4,0 @@ import MessengerClient from './MessengerClient'; |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
import type { | ||
@@ -2,0 +4,0 @@ UserID, |
@@ -0,1 +1,3 @@ | ||
/* @flow */ | ||
import querystring from 'querystring'; | ||
@@ -40,2 +42,3 @@ | ||
BatchItem, | ||
MessengerNLPConfig, | ||
} from './MessengerTypes'; | ||
@@ -153,5 +156,5 @@ | ||
// menuItems is in type PersistentMenu | ||
if (menuItems.some(item => item.locale === 'default')) { | ||
if (menuItems.some((item: Object) => item.locale === 'default')) { | ||
return this.setMessengerProfile({ | ||
persistent_menu: menuItems, | ||
persistent_menu: ((menuItems: any): PersistentMenu), | ||
}); | ||
@@ -166,3 +169,3 @@ } | ||
composer_input_disabled: composerInputDisabled, | ||
call_to_actions: menuItems, | ||
call_to_actions: ((menuItems: any): Array<MenuItem>), | ||
}, | ||
@@ -471,2 +474,3 @@ ], | ||
// $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, audio); | ||
@@ -492,2 +496,3 @@ }; | ||
// $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, image); | ||
@@ -513,2 +518,3 @@ }; | ||
// $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, video); | ||
@@ -534,2 +540,3 @@ }; | ||
// $FlowFixMe | ||
return this.sendAttachmentFormData(recipient, attachment, file); | ||
@@ -755,2 +762,3 @@ }; | ||
.map(key => { | ||
// $FlowFixMe item.body should not possible as undefined. | ||
const val = item.body[key]; | ||
@@ -804,3 +812,3 @@ return `${encodeURIComponent(key)}=${encodeURIComponent( | ||
*/ | ||
generateMessengerCode = (options = {}) => | ||
generateMessengerCode = (options: Object = {}) => | ||
this._http | ||
@@ -889,4 +897,4 @@ .post(`/me/messenger_codes?access_token=${this._accessToken}`, { | ||
*/ | ||
setNLPConfigs = (config = {}) => { | ||
const query = { | ||
setNLPConfigs = (config: MessengerNLPConfig = {}) => { | ||
const query: Object = { | ||
nlp_enabled: config.nlp_enabled ? 'true' : 'false', | ||
@@ -893,0 +901,0 @@ }; |
/* @flow */ | ||
import fs from 'fs'; | ||
@@ -289,3 +290,8 @@ | ||
name?: string, | ||
body?: string, | ||
body?: Object, | ||
}; | ||
export type MessengerNLPConfig = { | ||
nlp_enabled?: boolean, | ||
custom_token?: string, | ||
}; |
231929
4989