drip-ruby 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/lib/drip/client/events.rb +5 -2
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/events_test.rb +47 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cbe72d291a23e630224db7a0064e44bdc3be664
|
4
|
+
data.tar.gz: 9c19909fa87866a29693dde808f0286ce2535eec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03bbecdcce3efb18d0209b18a576f612d94749e72f0168f4255bcd3b7490761d7f6c66d856fe331d404d774dbf1b551f1cf678258e41a7ac44671e5f8afcb077
|
7
|
+
data.tar.gz: 4abe3cfdc1a37aa37d607c15eb2728fe5faf839a79ff85308ac9db7edb148ba3abe76d9f7c0a1dcbc60d648c17a445e685d8aafac2d41f69e7b91c2c6e2e1765
|
data/README.md
CHANGED
@@ -62,6 +62,7 @@ as methods on the client object. The following methods are currently available:
|
|
62
62
|
| Action | Method |
|
63
63
|
| :------------------------- | :--------------------------------------------------- |
|
64
64
|
| List accounts | `#accounts` |
|
65
|
+
| List subscribers | `#subscribers(options = {})` |
|
65
66
|
| Create/update a subscriber | `#create_or_update_subscriber(email, options = {})` |
|
66
67
|
| Create/update a batch of subscribers | `#create_or_update_subscribers(subscribers)` |
|
67
68
|
| Fetch a subscriber | `#subscriber(id_or_email)` |
|
@@ -82,6 +83,27 @@ for a complete API reference.
|
|
82
83
|
|
83
84
|
Here are some common use cases for the API client.
|
84
85
|
|
86
|
+
###Fetching user accounts
|
87
|
+
|
88
|
+
Once you have an access token for a Drip user, you can fetch their accounts.
|
89
|
+
|
90
|
+
Initialize your client and pull down the user's accounts. To make further calls, set the account_id
|
91
|
+
on your client to the account you want to access.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
client = Drip::Client.new do |c|
|
95
|
+
c.access_token = "YOUR_ACCESS_TOKEN"
|
96
|
+
end
|
97
|
+
|
98
|
+
resp = client.accounts
|
99
|
+
# => <Drip::Response ...>
|
100
|
+
|
101
|
+
account_id = resp.accounts.first.id
|
102
|
+
# => "9999999"
|
103
|
+
|
104
|
+
client.account_id = account_id
|
105
|
+
```
|
106
|
+
|
85
107
|
### Fetching subscriber data
|
86
108
|
|
87
109
|
Subscribers can be looked up by their email address or by their Drip subscriber
|
data/lib/drip/client/events.rb
CHANGED
@@ -8,11 +8,14 @@ module Drip
|
|
8
8
|
# email - Required. The String email address of the subscriber.
|
9
9
|
# action - Required. The String event action.
|
10
10
|
# properties - Optional. A Hash of event properties.
|
11
|
+
# options - Optional. A Hash of additional options:
|
12
|
+
# - prospect - A Boolean indicating if the subscriber is a prospect.
|
13
|
+
# - occurred_at - A String time at which the event occurred in ISO-8601 format.
|
11
14
|
#
|
12
15
|
# Returns a Drip::Response.
|
13
16
|
# See https://www.getdrip.com/docs/rest-api#record_event
|
14
|
-
def track_event(email, action, properties = {})
|
15
|
-
data = { "email" => email, "action" => action, "properties" => properties }
|
17
|
+
def track_event(email, action, properties = {}, options = {})
|
18
|
+
data = options.merge({ "email" => email, "action" => action, "properties" => properties })
|
16
19
|
post "#{account_id}/events", generate_resource("events", data)
|
17
20
|
end
|
18
21
|
|
data/lib/drip/version.rb
CHANGED
@@ -17,25 +17,58 @@ class Drip::Client::EventsTest < Drip::TestCase
|
|
17
17
|
@email = "derrick@getdrip.com"
|
18
18
|
@action = "Signed up"
|
19
19
|
@properties = { "foo" => "bar" }
|
20
|
-
|
21
|
-
"events" => [{
|
22
|
-
"email" => @email,
|
23
|
-
"action" => @action,
|
24
|
-
"properties" => @properties
|
25
|
-
}]
|
26
|
-
}.to_json
|
20
|
+
end
|
27
21
|
|
28
|
-
|
29
|
-
|
22
|
+
context "without options" do
|
23
|
+
setup do
|
24
|
+
@payload = {
|
25
|
+
"events" => [{
|
26
|
+
"email" => @email,
|
27
|
+
"action" => @action,
|
28
|
+
"properties" => @properties
|
29
|
+
}]
|
30
|
+
}.to_json
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
@response_status = 201
|
33
|
+
@response_body = stub
|
34
|
+
|
35
|
+
@stubs.post "12345/events", @payload do
|
36
|
+
[@response_status, {}, @response_body]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
should "send the right request" do
|
41
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
42
|
+
assert_equal expected, @client.track_event(@email, @action, @properties)
|
33
43
|
end
|
34
44
|
end
|
35
45
|
|
36
|
-
|
37
|
-
|
38
|
-
|
46
|
+
context "with options" do
|
47
|
+
setup do
|
48
|
+
@occurred_at = "2015-09-28T10:00:00Z"
|
49
|
+
@options = { occurred_at: @occurred_at }
|
50
|
+
|
51
|
+
@payload = {
|
52
|
+
"events" => [{
|
53
|
+
"occurred_at" => @occurred_at,
|
54
|
+
"email" => @email,
|
55
|
+
"action" => @action,
|
56
|
+
"properties" => @properties
|
57
|
+
}]
|
58
|
+
}.to_json
|
59
|
+
|
60
|
+
@response_status = 201
|
61
|
+
@response_body = stub
|
62
|
+
|
63
|
+
@stubs.post "12345/events", @payload do
|
64
|
+
[@response_status, {}, @response_body]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
should "send the right request" do
|
69
|
+
expected = Drip::Response.new(@response_status, @response_body)
|
70
|
+
assert_equal expected, @client.track_event(@email, @action, @properties, @options)
|
71
|
+
end
|
39
72
|
end
|
40
73
|
end
|
41
74
|
|
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.5
|
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-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|