Skip to content

Commit

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

return api.request("/users/me/presence", params);
},

/**
* Retrieve a list of users filtered by the given criteria.
*
* @example
* pnut.searchUsers({
* q: "news",
* types: "feed"
* });
* @param {Object} params
*/
searchUsers(params = {}) {
return api.request("/users/search", { params: params });
}
};
};
8 changes: 8 additions & 0 deletions test/users_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ before(function() {
nock(base)
.put("/users/me/presence", { presence: "A presence message" })
.reply(200, {});

nock(base)
.get("/users/search?q=news&types=feed")
.reply(200, {});
});

after(function() {
Expand Down Expand Up @@ -196,4 +200,8 @@ describe("User endpoints", () => {
it("should be able to update presence with an optional message", () => {
return pnut.updatePresence("A presence message").should.become({});
});

it("should be possible to search for users", () => {
return pnut.searchUsers({ q: "news", types: "feed" });
});
});

0 comments on commit 6999825

Please sign in to comment.