Skip to content

Commit 14aa42e

Browse files
committed
Add subscribers endpoint
1 parent 982f417 commit 14aa42e

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

lib/drip/client/subscribers.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
module Drip
44
class Client
55
module Subscribers
6+
# Public: Fetch a subscriber.
7+
#
8+
# options - A Hash of options.
9+
# - status - Optional. Filter by one of the following statuses:
10+
# active, or unsubscribed, or removed. Defaults to all.
11+
# - page - Optional. Use this parameter to paginate through
12+
# your list of subscribers. Each response contains a
13+
# a `meta` object that includes `total_count` and
14+
# `total_pages` attributes.
15+
#
16+
# Returns a Drip::Response.
17+
# See https://www.getdrip.com/docs/rest-api#list_subscribers
18+
def subscribers(options = {})
19+
get "#{account_id}/subscribers", options
20+
end
21+
622
# Public: Fetch a subscriber.
723
#
824
# id_or_email - Required. The String id or email address of the subscriber.

test/drip/client/subscribers_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ def setup
1212
@client.expects(:connection).at_least_once.returns(@connection)
1313
end
1414

15+
context "#subscribers" do
16+
setup do
17+
@response_status = 200
18+
@response_body = stub
19+
20+
@stubs.get "12345/subscribers" do
21+
[@response_status, {}, @response_body]
22+
end
23+
end
24+
25+
should "send the right request" do
26+
expected = Drip::Response.new(@response_status, @response_body)
27+
assert_equal expected, @client.subscribers
28+
end
29+
end
30+
1531
context "#subscriber" do
1632
setup do
1733
@id = "derrick@getdrip.com"

0 commit comments

Comments
 (0)