drip-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cda94b5bd281db2629d650bd0afad2658f932e1
4
- data.tar.gz: 44ea0b824241015d9cf2304d47d1419fd4e11cc5
3
+ metadata.gz: 20b8acc735371bed7872d258a98d0ff9ce347917
4
+ data.tar.gz: 2ac3d040c408dd94e9265da324168af97fe5952d
5
5
  SHA512:
6
- metadata.gz: 12beec3f311762c42ad50cca8d988502aade1f0f417f7d9bf342fcbbc923a3d12dfa77461916c706f47d51089fcaf6d84b0705cae9b2fc7e537d944a3ec7f0b3
7
- data.tar.gz: b3bf8862794416b6e0bf594118440e63eb17efdc10529f34e66713ac1436ddf927db829c0f6c2fed89ebb1b3533cf1601592a015f8e5469e4a3937c071f0488a
6
+ metadata.gz: 55d9319bfe2d614f8e7f58bbf7dfea07f567617ec588d6dabb86c8e6f64bd0f237f520b0dda6454fcf869272eac3f2db3a1a35ab94c1eb0ea4de840ce27b2291
7
+ data.tar.gz: 3867dd7fa45da8936f023506517377905ddc2e1995b5e93d7ddb906e6306ae4143969e52f3128e4821f636323df1ea9970212598372cb55908cbf00d246d0ae9
data/README.md CHANGED
@@ -6,7 +6,7 @@ A Ruby toolkit for the [Drip](https://www.getdrip.com/) API.
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'drip-ruby', :require => 'drip'
9
+ gem 'drip-ruby', :require => 'drip'
10
10
 
11
11
  And then execute:
12
12
 
@@ -46,12 +46,14 @@ as methods on the client object. The following methods are currently available:
46
46
  | Action | Method |
47
47
  | :------------------------- | :--------------------------------------------------- |
48
48
  | Create/update a subscriber | `#create_or_update_subscriber(email, options = {})` |
49
+ | Create/update a batch of subscribers | `#create_or_update_subscribers(subscribers)` |
49
50
  | Fetch a subscriber | `#subscriber(id_or_email)` |
50
51
  | Subscribe to a campaign | `#subscribe(email, campaign_id, options = {})` |
51
52
  | Unsubscribe | `#unsubscribe(id_or_email, options = {})` |
52
53
  | Apply a tag | `#apply_tag(email, tag)` |
53
54
  | Remove a tag | `#remove_tag(email, tag)` |
54
55
  | Track an event | `#track_event(email, action, properties = {})` |
56
+ | Track a batch of events | `#track_events(events)` |
55
57
 
56
58
 
57
59
  **Note:** We do not have complete API coverage yet. If we are missing an API method
@@ -15,6 +15,20 @@ module Drip
15
15
  data = { "email" => email, "action" => action, "properties" => properties }
16
16
  post "#{account_id}/events", generate_resource("events", data)
17
17
  end
18
+
19
+ # Public: Track a collection of events all at once.
20
+ #
21
+ # events - Required. An Array of between 1 and 1000 Hashes of event data.
22
+ # - email - Required. The String email address of the subscriber.
23
+ # - action - Required. The String event action.
24
+ # - properties - Optional. A Hash of event properties.
25
+ #
26
+ # Returns a Drip::Response.
27
+ # See https://www.getdrip.com/docs/rest-api#event_batches
28
+ def track_events(events)
29
+ url = "#{account_id}/events/batches"
30
+ post url, generate_resource("batches", { "events" => events })
31
+ end
18
32
  end
19
33
  end
20
34
  end
@@ -33,6 +33,26 @@ module Drip
33
33
  post "#{account_id}/subscribers", generate_resource("subscribers", data)
34
34
  end
35
35
 
36
+ # Public: Create or update a collection of subscribers.
37
+ #
38
+ # subscribers - Required. An Array of between 1 and 1000 Hashes of subscriber data.
39
+ # - email - Required. The String subscriber email address.
40
+ # - new_email - Optional. A new email address for the subscriber.
41
+ # If provided and a subscriber with the email above
42
+ # does not exist, this address will be used to
43
+ # create a new subscriber.
44
+ # - time_zone - Optional. The subscriber's time zone (in Olsen
45
+ # format). Defaults to Etc/UTC.
46
+ # - custom_fields - Optional. A Hash of custom field data.
47
+ # - tags - Optional. An Array of tags.
48
+ #
49
+ # Returns a Drip::Response
50
+ # See https://www.getdrip.com/docs/rest-api#subscriber_batches
51
+ def create_or_update_subscribers(subscribers)
52
+ url = "#{account_id}/subscribers/batches"
53
+ post url, generate_resource("batches", { "subscribers" => subscribers })
54
+ end
55
+
36
56
  # Public: Unsubscribe a subscriber globally or from a specific campaign.
37
57
  #
38
58
  # id_or_email - Required. The String id or email address of the subscriber.
data/lib/drip/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Drip
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -39,4 +39,32 @@ class Drip::Client::EventsTest < Drip::TestCase
39
39
  assert_equal expected, @client.track_event(@email, @action, @properties)
40
40
  end
41
41
  end
42
+
43
+ context "#track_events" do
44
+ setup do
45
+ @events = [
46
+ {
47
+ :email => "derrick@getdrip.com",
48
+ :action => "subscribed"
49
+ },
50
+ {
51
+ :email => "darin@getdrip.com",
52
+ :action => "unsubscribed"
53
+ }
54
+ ]
55
+
56
+ @payload = { "batches" => [ { "events" => @events } ] }.to_json
57
+ @response_status = 201
58
+ @response_body = stub
59
+
60
+ @stubs.post "12345/events/batches", @payload do
61
+ [@response_status, {}, @response_body]
62
+ end
63
+ end
64
+
65
+ should "send the right request" do
66
+ expected = Drip::Response.new(@response_status, @response_body)
67
+ assert_equal expected, @client.track_events(@events)
68
+ end
69
+ end
42
70
  end
@@ -50,6 +50,34 @@ class Drip::Client::SubscribersTest < Drip::TestCase
50
50
  end
51
51
  end
52
52
 
53
+ context "#create_or_update_subscribers" do
54
+ setup do
55
+ @subscribers = [
56
+ {
57
+ :email => "derrick@getdrip.com",
58
+ :time_zone => "America/Los_Angeles"
59
+ },
60
+ {
61
+ :email => "darin@getdrip.com",
62
+ :time_zone => "America/Los_Angeles"
63
+ }
64
+ ]
65
+
66
+ @payload = { "batches" => [ { "subscribers" => @subscribers } ] }.to_json
67
+ @response_status = 201
68
+ @response_body = stub
69
+
70
+ @stubs.post "12345/subscribers/batches", @payload do
71
+ [@response_status, {}, @response_body]
72
+ end
73
+ end
74
+
75
+ should "send the right request" do
76
+ expected = Drip::Response.new(@response_status, @response_body)
77
+ assert_equal expected, @client.create_or_update_subscribers(@subscribers)
78
+ end
79
+ end
80
+
53
81
  context "#subscribe" do
54
82
  setup do
55
83
  @email = "derrick@getdrip.com"
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Reimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-12 00:00:00.000000000 Z
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler