Skip to content

Commit

Permalink
Implement channel search
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Wood committed Oct 3, 2017
1 parent b0de277 commit 2e0fcdc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ module.exports = api => {
return api.request(`/channels/${channelId}/mute`, {
httpMethod: "DELETE"
});
},

/**
* Retrieve a list of channels filtered by the given criteria.
*
* @example
* pnut.searchChannels({
* isPublic: 1,
* channelTypes: "io.pnut.core.chat",
* categories: "fun"
* });
* @param {Object} params - Search parameters
* @returns {Promise}
*/
searchChannels(params = {}) {
return api.request("/channels/search", { params: params });
}
};
};
16 changes: 16 additions & 0 deletions test/channels_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ before(function() {
nock(base)
.delete("/channels/1/mute")
.reply(200, {});

nock(base)
.get(
"/channels/search?is_public=1&channel_types=io.pnut.core.chat&categories=fun"
)
.reply(200, {});
});

after(function() {
Expand Down Expand Up @@ -129,4 +135,14 @@ describe("Channels", () => {
it("should be able to unmute a channel (pnut.unmuteChannel)", () => {
return pnut.unmuteChannel(1).should.become({});
});

it("should be possible to search for channels", () => {
return pnut
.searchChannels({
isPublic: 1,
channelTypes: "io.pnut.core.chat",
categories: "fun"
})
.should.become({});
});
});

0 comments on commit 2e0fcdc

Please sign in to comment.