messaging-api-slack
Advanced tools
Comparing version 0.5.16 to 0.6.0
@@ -6,4 +6,3 @@ '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 _axios = require('axios');var _axios2 = _interopRequireDefault(_axios); | ||
var _axiosError = require('axios-error');var _axiosError2 = _interopRequireDefault(_axiosError); | ||
var _warning = require('warning');var _warning2 = _interopRequireDefault(_warning);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | ||
var _axiosError = require('axios-error');var _axiosError2 = _interopRequireDefault(_axiosError);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _asyncToGenerator(fn) {return function () {var gen = fn.apply(this, arguments);return new Promise(function (resolve, reject) {function step(key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {return Promise.resolve(value).then(function (value) {step("next", value);}, function (err) {step("throw", err);});}}return step("next");});};} | ||
@@ -109,10 +108,2 @@ | ||
/** | ||
@@ -290,3 +281,3 @@ * Gets information about a public channel. | ||
* FIXME: [breaking] support include_locale, limit, presence | ||
*/}exports.default = SlackOAuthClient;SlackOAuthClient.connect = token => new SlackOAuthClient(token);var _initialiseProps = function _initialiseProps() {var _this = this;this.getHTTPClient = () => {(0, _warning2.default)(false, '`.getHTTPClient` method is deprecated. use `.axios` getter instead.');return this._axios;};this.callMethod = (() => {var _ref = _asyncToGenerator(function* (method, body = {}) {body.token = _this._token; // eslint-disable-line no-param-reassign | ||
*/}exports.default = SlackOAuthClient;SlackOAuthClient.connect = token => new SlackOAuthClient(token);var _initialiseProps = function _initialiseProps() {var _this = this;this.callMethod = (() => {var _ref = _asyncToGenerator(function* (method, body = {}) {body.token = _this._token; // eslint-disable-line no-param-reassign | ||
const response = yield _this._axios.post(method, _querystring2.default.stringify(body));const data = response.data,config = response.config,request = response.request;if (!data.ok) {throw new _axiosError2.default(`Slack API - ${data.error}`, { config, request, response });}return data;});return function (_x) {return _ref.apply(this, arguments);};})();this.getChannelInfo = (channelId, options = {}) => this.callMethod('channels.info', _extends({ channel: channelId }, options)).then(data => data.channel);this.getChannelList = () => this.callMethod('channels.list').then(data => data.channels);this.getConversationInfo = (channelId, options = {}) => this.callMethod('conversations.info', _extends({ channel: channelId }, options)).then(data => data.channel);this.getConversationMembers = (channelId, options = {}) => this.callMethod('conversations.members', _extends({ channel: channelId }, options)).then(data => ({ members: data.members, next: data.response_metadata && data.response_metadata.next_cursor }));this.getAllConversationMembers = (() => {var _ref2 = _asyncToGenerator(function* (channelId) {let allMembers = [];let continuationCursor;do {var _ref3 = yield _this.getConversationMembers(channelId, { cursor: continuationCursor });const members = _ref3.members,next = _ref3.next;allMembers = allMembers.concat(members);continuationCursor = next;} while (continuationCursor);return allMembers;});return function (_x2) {return _ref2.apply(this, arguments);};})();this.getConversationList = (options = {}) => this.callMethod('conversations.list', options).then(data => ({ channels: data.channels, next: data.response_metadata && data.response_metadata.next_cursor }));this.getAllConversationList = (() => {var _ref4 = _asyncToGenerator(function* (options = {}) {let allChannels = [];let continuationCursor;do {var _ref5 = yield _this.getConversationList(_extends({}, options, { cursor: continuationCursor }));const channels = _ref5.channels,next = _ref5.next;allChannels = allChannels.concat(channels);continuationCursor = next;} while (continuationCursor);return allChannels;});return function () {return _ref4.apply(this, arguments);};})();this.postMessage = (channel, message, options = {}) => {if (options.attachments && typeof options.attachments !== 'string') {// A JSON-based array of structured attachments, presented as a URL-encoded string. | ||
@@ -293,0 +284,0 @@ // eslint-disable-next-line no-param-reassign |
'use strict';Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _axios = require('axios');var _axios2 = _interopRequireDefault(_axios); | ||
var _warning = require('warning');var _warning2 = _interopRequireDefault(_warning);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
var _axios = require('axios');var _axios2 = _interopRequireDefault(_axios);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
@@ -43,10 +42,2 @@ | ||
/** | ||
@@ -56,3 +47,3 @@ * Attachments | ||
* https://api.slack.com/docs/message-attachments | ||
*/}exports.default = SlackWebhookClient;SlackWebhookClient.connect = url => new SlackWebhookClient(url);var _initialiseProps = function _initialiseProps() {this.getHTTPClient = () => {(0, _warning2.default)(false, '`.getHTTPClient` method is deprecated. use `.axios` getter instead.');return this._axios;};this.sendRawBody = body => this._axios.post('', body).then(res => res.data);this.sendText = text => this.sendRawBody({ text });this. | ||
*/}exports.default = SlackWebhookClient;SlackWebhookClient.connect = url => new SlackWebhookClient(url);var _initialiseProps = function _initialiseProps() {this.sendRawBody = body => this._axios.post('', body).then(res => res.data);this.sendText = text => this.sendRawBody({ text });this. | ||
@@ -59,0 +50,0 @@ sendAttachments = |
{ | ||
"name": "messaging-api-slack", | ||
"description": "Messaging API client for Slack", | ||
"version": "0.5.16", | ||
"version": "0.6.0", | ||
"engines": { | ||
@@ -22,5 +22,3 @@ "node": ">=6" | ||
"axios": "^0.17.0", | ||
"axios-error": "^0.5.4", | ||
"invariant": "^2.2.2", | ||
"warning": "^3.0.0" | ||
"axios-error": "^0.5.4" | ||
}, | ||
@@ -27,0 +25,0 @@ "devDependencies": { |
@@ -9,3 +9,3 @@ import MockAdapter from 'axios-mock-adapter'; | ||
const client = new SlackWebhookClient(URL); | ||
const mock = new MockAdapter(client.getHTTPClient()); | ||
const mock = new MockAdapter(client.axios); | ||
return { client, mock }; | ||
@@ -60,13 +60,2 @@ }; | ||
describe('#getHTTPClient', () => { | ||
it('should return underlying http client', () => { | ||
const client = new SlackWebhookClient(URL); | ||
const http = client.getHTTPClient(); | ||
expect(http.get).toBeDefined(); | ||
expect(http.post).toBeDefined(); | ||
expect(http.put).toBeDefined(); | ||
expect(http.delete).toBeDefined(); | ||
}); | ||
}); | ||
describe('#axios', () => { | ||
@@ -73,0 +62,0 @@ it('should return underlying http client', () => { |
@@ -7,3 +7,2 @@ /* @flow */ | ||
import AxiosError from 'axios-error'; | ||
import warning from 'warning'; | ||
@@ -86,10 +85,2 @@ import type { | ||
getHTTPClient: () => Axios = () => { | ||
warning( | ||
false, | ||
'`.getHTTPClient` method is deprecated. use `.axios` getter instead.' | ||
); | ||
return this._axios; | ||
}; | ||
callMethod = async ( | ||
@@ -96,0 +87,0 @@ method: SlackAvailableMethod, |
/* @flow */ | ||
import axios from 'axios'; | ||
import warning from 'warning'; | ||
@@ -37,10 +36,2 @@ import type { SlackAttachment, SendMessageSucessResponse } from './SlackTypes'; | ||
getHTTPClient: () => Axios = () => { | ||
warning( | ||
false, | ||
'`.getHTTPClient` method is deprecated. use `.axios` getter instead.' | ||
); | ||
return this._axios; | ||
}; | ||
sendRawBody = (body: Object): Promise<SendMessageSucessResponse> => | ||
@@ -47,0 +38,0 @@ this._axios.post('', body).then(res => res.data); |
2
73638
2045
- Removedinvariant@^2.2.2
- Removedwarning@^3.0.0
- Removedinvariant@2.2.4(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedwarning@3.0.0(transitive)