Skip to content

Commit

Permalink
Add subscribers endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickreimer committed Jul 21, 2015
1 parent 982f417 commit 14aa42e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/drip/client/subscribers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
module Drip
class Client
module Subscribers
# Public: Fetch a subscriber.
#
# options - A Hash of options.
# - status - Optional. Filter by one of the following statuses:
# active, or unsubscribed, or removed. Defaults to all.
# - page - Optional. Use this parameter to paginate through
# your list of subscribers. Each response contains a
# a `meta` object that includes `total_count` and
# `total_pages` attributes.
#
# Returns a Drip::Response.
# See https://www.getdrip.com/docs/rest-api#list_subscribers
def subscribers(options = {})
get "#{account_id}/subscribers", options
end

# Public: Fetch a subscriber.
#
# id_or_email - Required. The String id or email address of the subscriber.
Expand Down
16 changes: 16 additions & 0 deletions test/drip/client/subscribers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ def setup
@client.expects(:connection).at_least_once.returns(@connection)
end

context "#subscribers" do
setup do
@response_status = 200
@response_body = stub

@stubs.get "12345/subscribers" do
[@response_status, {}, @response_body]
end
end

should "send the right request" do
expected = Drip::Response.new(@response_status, @response_body)
assert_equal expected, @client.subscribers
end
end

context "#subscriber" do
setup do
@id = "derrick@getdrip.com"
Expand Down

0 comments on commit 14aa42e

Please sign in to comment.