drip-ruby 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +31 -12
- data/drip-ruby.gemspec +1 -0
- data/lib/drip/client.rb +6 -1
- data/lib/drip/client/accounts.rb +97 -0
- data/lib/drip/client/subscribers.rb +16 -0
- data/lib/drip/collections.rb +3 -5
- data/lib/drip/collections/accounts.rb +13 -0
- data/lib/drip/resource.rb +7 -11
- data/lib/drip/resources.rb +3 -5
- data/lib/drip/resources/account.rb +9 -0
- data/lib/drip/resources/error.rb +0 -4
- data/lib/drip/resources/subscriber.rb +0 -6
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +30 -0
- data/test/drip/client/events_test.rb +0 -1
- data/test/drip/client/subscribers_test.rb +16 -1
- data/test/drip/client/tags_test.rb +0 -1
- data/test/drip/client_test.rb +12 -0
- data/test/drip/collections_test.rb +1 -0
- data/test/drip/resource_test.rb +8 -20
- data/test/drip/resources/account_test.rb +7 -0
- data/test/drip/resources/subscriber_test.rb +2 -15
- data/test/drip/response_test.rb +1 -1
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9517d2daf672dbd3ce976aa87445eaba6b13c401
|
4
|
+
data.tar.gz: 32f6963d29532bfb0b051c791d4646e829adef5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9450ed93e3e54dc5c9f412b7eb621bc156d001a2aeedd2ce73b2f680f9ad82d296653d6668c29bae08f853056999644cc251f4f1282ae1acb42c58541dfd09f5
|
7
|
+
data.tar.gz: b79a01d2437d10bfd8baf8a1b787ddc2bffdc2dcd9c0035c0ae515a92c0077e247ee529f6e019d812b19a2f2a78daa4c9149c7c530f5c6c2149437df31695cf4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
# Drip Ruby
|
1
|
+
# Drip Ruby Client
|
2
2
|
|
3
3
|
A Ruby toolkit for the [Drip](https://www.getdrip.com/) API.
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/DripEmail/drip-ruby.svg?branch=master)](https://travis-ci.org/DripEmail/drip-ruby)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/DripEmail/drip-ruby/badges/gpa.svg)](https://codeclimate.com/github/DripEmail/drip-ruby)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
8
11
|
|
9
|
-
gem 'drip-ruby', :
|
12
|
+
gem 'drip-ruby', require: 'drip'
|
10
13
|
|
11
14
|
And then execute:
|
12
15
|
|
@@ -16,9 +19,7 @@ Or install it yourself as:
|
|
16
19
|
|
17
20
|
$ gem install drip-ruby
|
18
21
|
|
19
|
-
##
|
20
|
-
|
21
|
-
Your account ID can be found [here](https://www.getdrip.com/settings/site).
|
22
|
+
## Authentication
|
22
23
|
|
23
24
|
For private integrations, you may use your personal API key (found
|
24
25
|
[here](https://www.getdrip.com/user/edit)) via the `api_key` setting:
|
@@ -40,11 +41,27 @@ client = Drip::Client.new do |c|
|
|
40
41
|
end
|
41
42
|
```
|
42
43
|
|
44
|
+
You may also pass client options in an argument hash:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
client = Drip::Client.new(
|
48
|
+
access_token: "YOUR_ACCESS_TOKEN"
|
49
|
+
account_id: "YOUR_ACCOUNT_ID"
|
50
|
+
)
|
51
|
+
```
|
52
|
+
|
53
|
+
Your account ID can be found [here](https://www.getdrip.com/settings/site).
|
54
|
+
Most API actions require an account ID, with the exception of methods like
|
55
|
+
the "list accounts" endpoint.
|
56
|
+
|
57
|
+
## Usage
|
58
|
+
|
43
59
|
Since the Drip client is a flat API client, most API actions are available
|
44
60
|
as methods on the client object. The following methods are currently available:
|
45
61
|
|
46
62
|
| Action | Method |
|
47
63
|
| :------------------------- | :--------------------------------------------------- |
|
64
|
+
| List accounts | `#accounts` |
|
48
65
|
| Create/update a subscriber | `#create_or_update_subscriber(email, options = {})` |
|
49
66
|
| Create/update a batch of subscribers | `#create_or_update_subscribers(subscribers)` |
|
50
67
|
| Fetch a subscriber | `#subscriber(id_or_email)` |
|
@@ -61,15 +78,17 @@ that you need to use in your application, please file an issue and/or open a
|
|
61
78
|
pull request. [See the official REST API docs](https://www.getdrip.com/docs/rest-api)
|
62
79
|
for a complete API reference.
|
63
80
|
|
64
|
-
##
|
81
|
+
## Use Cases
|
65
82
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
c.account_id = "YOUR_ACCOUNT_ID"
|
70
|
-
end
|
83
|
+
Here are some common use cases for the API client.
|
84
|
+
|
85
|
+
### Fetching subscriber data
|
71
86
|
|
72
|
-
|
87
|
+
Subscribers can be looked up by their email address or by their Drip subscriber
|
88
|
+
ID. Most of the time you will want to look up subscribers by their email address,
|
89
|
+
unless you've already stored this ID in your database.
|
90
|
+
|
91
|
+
```ruby
|
73
92
|
resp = client.subscriber("foo@example.com")
|
74
93
|
# => <Drip::Response ...>
|
75
94
|
|
data/drip-ruby.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "shoulda-context", "~> 1.0"
|
24
24
|
spec.add_development_dependency "mocha", "~> 1.1"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
25
26
|
|
26
27
|
spec.add_runtime_dependency "faraday", "~> 0.9"
|
27
28
|
spec.add_runtime_dependency "faraday_middleware", "~> 0.9"
|
data/lib/drip/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "drip/response"
|
2
|
+
require "drip/client/accounts"
|
2
3
|
require "drip/client/subscribers"
|
3
4
|
require "drip/client/tags"
|
4
5
|
require "drip/client/events"
|
@@ -8,13 +9,17 @@ require "json"
|
|
8
9
|
|
9
10
|
module Drip
|
10
11
|
class Client
|
12
|
+
include Accounts
|
11
13
|
include Subscribers
|
12
14
|
include Tags
|
13
15
|
include Events
|
14
16
|
|
15
17
|
attr_accessor :access_token, :api_key, :account_id
|
16
18
|
|
17
|
-
def initialize
|
19
|
+
def initialize(options = {})
|
20
|
+
@account_id = options[:account_id]
|
21
|
+
@access_token = options[:access_token]
|
22
|
+
@api_key = options[:api_key]
|
18
23
|
yield(self) if block_given?
|
19
24
|
end
|
20
25
|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Drip
|
2
|
+
class Client
|
3
|
+
module Accounts
|
4
|
+
# Public: Fetch all accounts to which the authenticated user has access.
|
5
|
+
#
|
6
|
+
# Returns a Drip::Response.
|
7
|
+
# See https://www.getdrip.com/docs/rest-api#accounts
|
8
|
+
def accounts
|
9
|
+
get "accounts"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: Create or update a subscriber.
|
13
|
+
#
|
14
|
+
# options - A Hash of options.
|
15
|
+
# - email - Required. The String subscriber email address.
|
16
|
+
# - new_email - Optional. A new email address for the subscriber.
|
17
|
+
# If provided and a subscriber with the email above
|
18
|
+
# does not exist, this address will be used to
|
19
|
+
# create a new subscriber.
|
20
|
+
# - time_zone - Optional. The subscriber's time zone (in Olsen
|
21
|
+
# format). Defaults to Etc/UTC.
|
22
|
+
# - custom_fields - Optional. A Hash of custom field data.
|
23
|
+
# - tags - Optional. An Array of tags.
|
24
|
+
#
|
25
|
+
# Returns a Drip::Response.
|
26
|
+
# See https://www.getdrip.com/docs/rest-api#create_or_update_subscriber
|
27
|
+
def create_or_update_subscriber(email, options = {})
|
28
|
+
data = options.merge(:email => email)
|
29
|
+
post "#{account_id}/subscribers", generate_resource("subscribers", data)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Public: Create or update a collection of subscribers.
|
33
|
+
#
|
34
|
+
# subscribers - Required. An Array of between 1 and 1000 Hashes of subscriber data.
|
35
|
+
# - email - Required. The String subscriber email address.
|
36
|
+
# - new_email - Optional. A new email address for the subscriber.
|
37
|
+
# If provided and a subscriber with the email above
|
38
|
+
# does not exist, this address will be used to
|
39
|
+
# create a new subscriber.
|
40
|
+
# - time_zone - Optional. The subscriber's time zone (in Olsen
|
41
|
+
# format). Defaults to Etc/UTC.
|
42
|
+
# - custom_fields - Optional. A Hash of custom field data.
|
43
|
+
# - tags - Optional. An Array of tags.
|
44
|
+
#
|
45
|
+
# Returns a Drip::Response
|
46
|
+
# See https://www.getdrip.com/docs/rest-api#subscriber_batches
|
47
|
+
def create_or_update_subscribers(subscribers)
|
48
|
+
url = "#{account_id}/subscribers/batches"
|
49
|
+
post url, generate_resource("batches", { "subscribers" => subscribers })
|
50
|
+
end
|
51
|
+
|
52
|
+
# Public: Unsubscribe a subscriber globally or from a specific campaign.
|
53
|
+
#
|
54
|
+
# id_or_email - Required. The String id or email address of the subscriber.
|
55
|
+
# options - A Hash of options.
|
56
|
+
# - campaign_id - Optional. The campaign from which to
|
57
|
+
# unsubscribe the subscriber. Defaults to all.
|
58
|
+
#
|
59
|
+
# Returns a Drip::Response.
|
60
|
+
# See https://www.getdrip.com/docs/rest-api#unsubscribe
|
61
|
+
def unsubscribe(id_or_email, options = {})
|
62
|
+
url = "#{account_id}/subscribers/#{CGI.escape id_or_email}/unsubscribe"
|
63
|
+
url += options[:campaign_id] ? "?campaign_id=#{options[:campaign_id]}" : ""
|
64
|
+
post url
|
65
|
+
end
|
66
|
+
|
67
|
+
# Public: Subscribe to a campaign.
|
68
|
+
#
|
69
|
+
# email - Required. The String email address of the subscriber.
|
70
|
+
# campaign_id - Required. The String campaign id.
|
71
|
+
# options - Optional. A Hash of options.
|
72
|
+
# - double_optin - Optional. If true, the double opt-in confirmation
|
73
|
+
# email is sent; if false, the confirmation
|
74
|
+
# email is skipped. Defaults to the value set
|
75
|
+
# on the campaign.
|
76
|
+
# - starting_email_index - Optional. The index (zero-based) of
|
77
|
+
# the email to send first. Defaults to 0.
|
78
|
+
# - time_zone - Optional. The subscriber's time zone (in Olsen
|
79
|
+
# format). Defaults to Etc/UTC.
|
80
|
+
# - custom_fields - Optional. A Hash of custom field data.
|
81
|
+
# - tags - Optional. An Array of tags.
|
82
|
+
# - reactivate_if_removed - Optional. If true, re-subscribe
|
83
|
+
# the subscriber to the campaign if there
|
84
|
+
# is a removed subscriber in Drip with the same
|
85
|
+
# email address; otherwise, respond with
|
86
|
+
# 422 Unprocessable Entity. Defaults to true.
|
87
|
+
#
|
88
|
+
# Returns a Drip::Response.
|
89
|
+
# See https://www.getdrip.com/docs/rest-api#subscribe
|
90
|
+
def subscribe(email, campaign_id, options = {})
|
91
|
+
data = options.merge("email" => email)
|
92
|
+
url = "#{account_id}/campaigns/#{campaign_id}/subscribers"
|
93
|
+
post url, generate_resource("subscribers", data)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -3,6 +3,22 @@ require "cgi"
|
|
3
3
|
module Drip
|
4
4
|
class Client
|
5
5
|
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
|
+
|
6
22
|
# Public: Fetch a subscriber.
|
7
23
|
#
|
8
24
|
# id_or_email - Required. The String id or email address of the subscriber.
|
data/lib/drip/collections.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "drip/collections/accounts"
|
1
2
|
require "drip/collections/subscribers"
|
2
3
|
require "drip/collections/errors"
|
3
4
|
|
@@ -5,17 +6,14 @@ module Drip
|
|
5
6
|
module Collections
|
6
7
|
def self.classes
|
7
8
|
[
|
9
|
+
Drip::Accounts,
|
8
10
|
Drip::Subscribers,
|
9
11
|
Drip::Errors
|
10
12
|
]
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.find_class(name)
|
14
|
-
|
15
|
-
c.collection_name == name
|
16
|
-
end
|
17
|
-
|
18
|
-
matches.first || Drip::Collection
|
16
|
+
self.classes.find { |c| c.collection_name == name } || Drip::Collection
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
data/lib/drip/resource.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "time"
|
2
|
+
|
1
3
|
module Drip
|
2
4
|
class Resource
|
3
5
|
attr_reader :raw_attributes, :attributes
|
@@ -11,36 +13,30 @@ module Drip
|
|
11
13
|
"resource"
|
12
14
|
end
|
13
15
|
|
14
|
-
def attribute_keys
|
15
|
-
[]
|
16
|
-
end
|
17
|
-
|
18
16
|
def singular?
|
19
17
|
true
|
20
18
|
end
|
21
19
|
|
22
20
|
def respond_to?(method_name, include_private = false)
|
23
|
-
|
21
|
+
attributes.keys.include?(method_name.to_s) || super
|
24
22
|
end
|
25
23
|
|
26
24
|
def method_missing(method_name, *args, &block)
|
27
|
-
|
25
|
+
attributes.keys.include?(method_name.to_s) ? attributes[method_name.to_s] : super
|
28
26
|
end
|
29
27
|
|
30
28
|
private
|
31
29
|
|
32
30
|
def process(attributes)
|
33
31
|
{}.tap do |attrs|
|
34
|
-
|
35
|
-
|
36
|
-
attrs[key] = process_attribute(key, raw_value)
|
32
|
+
attributes.keys.each do |key|
|
33
|
+
attrs[key] = process_attribute(key, attributes[key])
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
38
|
def process_attribute(key, raw_value)
|
42
|
-
|
43
|
-
when :created_at, :updated_at
|
39
|
+
if key.to_s =~ /_at$/ # auto-coerce times
|
44
40
|
raw_value ? Time.parse(raw_value) : nil
|
45
41
|
else
|
46
42
|
raw_value
|
data/lib/drip/resources.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "drip/resources/account"
|
1
2
|
require "drip/resources/subscriber"
|
2
3
|
require "drip/resources/error"
|
3
4
|
|
@@ -5,17 +6,14 @@ module Drip
|
|
5
6
|
module Resources
|
6
7
|
def self.classes
|
7
8
|
[
|
9
|
+
Drip::Account,
|
8
10
|
Drip::Subscriber,
|
9
11
|
Drip::Error
|
10
12
|
]
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.find_class(name)
|
14
|
-
|
15
|
-
c.resource_name == name
|
16
|
-
end
|
17
|
-
|
18
|
-
matches.first || Drip::Resource
|
16
|
+
self.classes.find { |c| c.resource_name == name } || Drip::Resource
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
data/lib/drip/resources/error.rb
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
require "drip/resource"
|
2
|
-
require "time"
|
3
2
|
|
4
3
|
module Drip
|
5
4
|
class Subscriber < Resource
|
6
5
|
def self.resource_name
|
7
6
|
"subscriber"
|
8
7
|
end
|
9
|
-
|
10
|
-
def attribute_keys
|
11
|
-
%i{id status email custom_fields tags time_zone
|
12
|
-
utc_offset visitor_uuid created_at href}
|
13
|
-
end
|
14
8
|
end
|
15
9
|
end
|
data/lib/drip/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
2
|
+
|
3
|
+
class Drip::Client::AccountsTest < Drip::TestCase
|
4
|
+
def setup
|
5
|
+
@stubs = Faraday::Adapter::Test::Stubs.new
|
6
|
+
|
7
|
+
@connection = Faraday.new do |builder|
|
8
|
+
builder.adapter :test, @stubs
|
9
|
+
end
|
10
|
+
|
11
|
+
@client = Drip::Client.new
|
12
|
+
@client.expects(:connection).at_least_once.returns(@connection)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "#accounts" do
|
16
|
+
setup do
|
17
|
+
@response_status = 200
|
18
|
+
@response_body = stub
|
19
|
+
|
20
|
+
@stubs.get "accounts" 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.accounts
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
2
|
-
require "faraday"
|
3
2
|
|
4
3
|
class Drip::Client::SubscribersTest < Drip::TestCase
|
5
4
|
def setup
|
@@ -13,6 +12,22 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
13
12
|
@client.expects(:connection).at_least_once.returns(@connection)
|
14
13
|
end
|
15
14
|
|
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
|
+
|
16
31
|
context "#subscriber" do
|
17
32
|
setup do
|
18
33
|
@id = "derrick@getdrip.com"
|
data/test/drip/client_test.rb
CHANGED
@@ -26,6 +26,18 @@ class Drip::ClientTest < Drip::TestCase
|
|
26
26
|
|
27
27
|
assert_equal "1234567", client.account_id
|
28
28
|
end
|
29
|
+
|
30
|
+
should "accept options via arguments" do
|
31
|
+
client = Drip::Client.new(
|
32
|
+
account_id: "1234567",
|
33
|
+
api_key: "aaaa",
|
34
|
+
access_token: "bbbb"
|
35
|
+
)
|
36
|
+
|
37
|
+
assert_equal "1234567", client.account_id
|
38
|
+
assert_equal "aaaa", client.api_key
|
39
|
+
assert_equal "bbbb", client.access_token
|
40
|
+
end
|
29
41
|
end
|
30
42
|
|
31
43
|
context "#generate_resource" do
|
@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
3
3
|
class Drip::CollectionsTest < Drip::TestCase
|
4
4
|
should "find collections" do
|
5
5
|
assert_equal Drip::Subscribers, Drip::Collections.find_class("subscribers")
|
6
|
+
assert_equal Drip::Accounts, Drip::Collections.find_class("accounts")
|
6
7
|
assert_equal Drip::Errors, Drip::Collections.find_class("errors")
|
7
8
|
end
|
8
9
|
|
data/test/drip/resource_test.rb
CHANGED
@@ -2,33 +2,21 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
2
2
|
|
3
3
|
class Drip::ResourceTest < Drip::TestCase
|
4
4
|
class TestResource < Drip::Resource
|
5
|
-
def attribute_keys
|
6
|
-
%i{id name}
|
7
|
-
end
|
8
|
-
|
9
|
-
def process_attribute(key, value)
|
10
|
-
case key
|
11
|
-
when :id
|
12
|
-
value.to_i
|
13
|
-
else
|
14
|
-
value
|
15
|
-
end
|
16
|
-
end
|
17
5
|
end
|
18
6
|
|
19
|
-
should "respond to
|
20
|
-
resource = TestResource.new
|
7
|
+
should "respond to attributes passed in" do
|
8
|
+
resource = TestResource.new("id" => "1234")
|
21
9
|
assert resource.respond_to?(:id)
|
22
|
-
|
10
|
+
assert_equal "1234", resource.id
|
23
11
|
end
|
24
12
|
|
25
|
-
should "
|
13
|
+
should "not respond to non-existant attributes" do
|
26
14
|
resource = TestResource.new("id" => "1234")
|
27
|
-
|
15
|
+
assert !resource.respond_to?(:first_name)
|
28
16
|
end
|
29
17
|
|
30
|
-
should "
|
31
|
-
resource = TestResource.new("
|
32
|
-
assert_equal
|
18
|
+
should "coerce times" do
|
19
|
+
resource = TestResource.new("created_at" => "2015-06-15T10:00:00Z")
|
20
|
+
assert_equal Time.utc(2015, 6, 15, 10, 0, 0), resource.created_at
|
33
21
|
end
|
34
22
|
end
|
@@ -1,20 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
2
2
|
|
3
3
|
class Drip::SubscriberTest < Drip::TestCase
|
4
|
-
should "
|
5
|
-
|
6
|
-
|
7
|
-
data = load_json_fixture("resources/subscriber.json")
|
8
|
-
data["created_at"] = created_at.iso8601
|
9
|
-
|
10
|
-
resource = Drip::Subscriber.new(data)
|
11
|
-
|
12
|
-
assert_equal created_at, resource.created_at
|
13
|
-
end
|
14
|
-
|
15
|
-
context ".resource_name" do
|
16
|
-
should "be subscriber" do
|
17
|
-
assert_equal "subscriber", Drip::Subscriber.resource_name
|
18
|
-
end
|
4
|
+
should "have a resource name" do
|
5
|
+
assert_equal "subscriber", Drip::Subscriber.resource_name
|
19
6
|
end
|
20
7
|
end
|
data/test/drip/response_test.rb
CHANGED
@@ -28,7 +28,7 @@ class Drip::ResponseTest < Drip::TestCase
|
|
28
28
|
context "#==" do
|
29
29
|
should "be true if status and body are equal" do
|
30
30
|
status = 200
|
31
|
-
body = { "foo" => "bar" }
|
31
|
+
body = { "subscribers" => [{ "foo" => "bar" }] }
|
32
32
|
|
33
33
|
subject1 = Drip::Response.new(status, body.clone)
|
34
34
|
subject2 = Drip::Response.new(status, body.clone)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drip-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: faraday
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,19 +138,23 @@ files:
|
|
124
138
|
- drip-ruby.gemspec
|
125
139
|
- lib/drip.rb
|
126
140
|
- lib/drip/client.rb
|
141
|
+
- lib/drip/client/accounts.rb
|
127
142
|
- lib/drip/client/events.rb
|
128
143
|
- lib/drip/client/subscribers.rb
|
129
144
|
- lib/drip/client/tags.rb
|
130
145
|
- lib/drip/collection.rb
|
131
146
|
- lib/drip/collections.rb
|
147
|
+
- lib/drip/collections/accounts.rb
|
132
148
|
- lib/drip/collections/errors.rb
|
133
149
|
- lib/drip/collections/subscribers.rb
|
134
150
|
- lib/drip/resource.rb
|
135
151
|
- lib/drip/resources.rb
|
152
|
+
- lib/drip/resources/account.rb
|
136
153
|
- lib/drip/resources/error.rb
|
137
154
|
- lib/drip/resources/subscriber.rb
|
138
155
|
- lib/drip/response.rb
|
139
156
|
- lib/drip/version.rb
|
157
|
+
- test/drip/client/accounts_test.rb
|
140
158
|
- test/drip/client/events_test.rb
|
141
159
|
- test/drip/client/subscribers_test.rb
|
142
160
|
- test/drip/client/tags_test.rb
|
@@ -144,6 +162,7 @@ files:
|
|
144
162
|
- test/drip/collection_test.rb
|
145
163
|
- test/drip/collections_test.rb
|
146
164
|
- test/drip/resource_test.rb
|
165
|
+
- test/drip/resources/account_test.rb
|
147
166
|
- test/drip/resources/subscriber_test.rb
|
148
167
|
- test/drip/resources_test.rb
|
149
168
|
- test/drip/response_test.rb
|
@@ -175,6 +194,7 @@ signing_key:
|
|
175
194
|
specification_version: 4
|
176
195
|
summary: A Ruby gem for interacting with the Drip API
|
177
196
|
test_files:
|
197
|
+
- test/drip/client/accounts_test.rb
|
178
198
|
- test/drip/client/events_test.rb
|
179
199
|
- test/drip/client/subscribers_test.rb
|
180
200
|
- test/drip/client/tags_test.rb
|
@@ -182,6 +202,7 @@ test_files:
|
|
182
202
|
- test/drip/collection_test.rb
|
183
203
|
- test/drip/collections_test.rb
|
184
204
|
- test/drip/resource_test.rb
|
205
|
+
- test/drip/resources/account_test.rb
|
185
206
|
- test/drip/resources/subscriber_test.rb
|
186
207
|
- test/drip/resources_test.rb
|
187
208
|
- test/drip/response_test.rb
|