Skip to content

Commit

Permalink
Implement message search
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Wood committed Oct 3, 2017
1 parent 74877f7 commit 62a531a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ module.exports = api => {
httpMethod: "DELETE"
}
);
},

/**
* Retrieve a list of messages filtered by the given criteria.
*
* @example
* pnut.searchMessages({
* channelIds: [600, 18]
* });
* @param {Object} params
* @returns {Promise}
*/
searchMessages(params = {}) {
return api.request("/channels/messages/search", { params: params });
}
};
};
8 changes: 8 additions & 0 deletions test/messages_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ before(function() {
text: "A new PM to multiple users"
})
.reply(200, {});

nock(base)
.get("/channels/messages/search?channel_ids=600,18")
.reply(200, {});
});

after(function() {
Expand Down Expand Up @@ -126,4 +130,8 @@ describe("Messages", () => {
.sendMessage([1, 5, "@kwood"], "A new PM to multiple users")
.should.become({});
});

it("should be possible to search for messages", () => {
return pnut.searchMessages({ channelIds: [600, 18] }).should.become({});
});
});

0 comments on commit 62a531a

Please sign in to comment.