Skip to content

Commit

Permalink
Implement posts search
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Wood committed Oct 3, 2017
1 parent b2d6f88 commit a82ae25
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ module.exports = api => {
return api.request(`/posts/${postId}/bookmark`, {
httpMethod: "DELETE"
});
},

/**
* Retrieve a list of posts filtered by the given criteria.
*
* @example
* pnut.searchPosts({
* tags: ["mndp", "MondayNightDanceParty"]
* });
* @param {Object} params
* @returns {Promise}
*/
searchPosts(params = {}) {
return api.request("/posts/search", { params: params });
}
};
};
10 changes: 10 additions & 0 deletions test/posts_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ before(function() {
nock(base)
.get("/posts/streams/unified")
.reply(200, {});

nock(base)
.get("/posts/search?tags=mndp,MondayNightDanceParty")
.reply(200, {});
});

after(function() {
Expand Down Expand Up @@ -222,4 +226,10 @@ describe("Posts", () => {
it("should be able to delete a bookmark", () => {
return pnut.deleteBookmark(1000).should.become({});
});

it("should be possbible to search for posts", () => {
return pnut
.searchPosts({ tags: ["mndp", "MondayNightDanceParty"] })
.should.become({});
});
});

0 comments on commit a82ae25

Please sign in to comment.