drip-ruby 0.0.12 → 1.0.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -0
  3. data/.rubocop_todo.yml +134 -0
  4. data/README.md +107 -13
  5. data/Rakefile +1 -1
  6. data/drip-ruby.gemspec +2 -2
  7. data/lib/drip/client.rb +23 -7
  8. data/lib/drip/client/accounts.rb +10 -0
  9. data/lib/drip/client/broadcasts.rb +29 -0
  10. data/lib/drip/client/campaign_subscriptions.rb +15 -0
  11. data/lib/drip/client/campaigns.rb +54 -0
  12. data/lib/drip/client/conversions.rb +27 -0
  13. data/lib/drip/client/custom_fields.rb +13 -0
  14. data/lib/drip/client/events.rb +13 -0
  15. data/lib/drip/client/forms.rb +23 -0
  16. data/lib/drip/client/purchases.rb +1 -1
  17. data/lib/drip/client/subscribers.rb +28 -6
  18. data/lib/drip/client/webhooks.rb +59 -0
  19. data/lib/drip/client/workflow_triggers.rb +44 -0
  20. data/lib/drip/client/workflows.rb +80 -0
  21. data/lib/drip/collections.rb +17 -5
  22. data/lib/drip/collections/broadcasts.rb +13 -0
  23. data/lib/drip/collections/campaign_subscriptions.rb +13 -0
  24. data/lib/drip/collections/campaigns.rb +13 -0
  25. data/lib/drip/collections/webhooks.rb +13 -0
  26. data/lib/drip/collections/workflow_triggers.rb +13 -0
  27. data/lib/drip/collections/workflows.rb +13 -0
  28. data/lib/drip/resources.rb +17 -5
  29. data/lib/drip/resources/broadcast.rb +9 -0
  30. data/lib/drip/resources/campaign.rb +9 -0
  31. data/lib/drip/resources/campaign_subscription.rb +9 -0
  32. data/lib/drip/resources/webhook.rb +9 -0
  33. data/lib/drip/resources/workflow.rb +9 -0
  34. data/lib/drip/resources/workflow_trigger.rb +9 -0
  35. data/lib/drip/response.rb +1 -1
  36. data/lib/drip/version.rb +1 -1
  37. data/test/drip/client/accounts_test.rb +17 -0
  38. data/test/drip/client/broadcasts_test.rb +47 -0
  39. data/test/drip/client/campaign_subscriptions_test.rb +31 -0
  40. data/test/drip/client/campaigns_test.rb +68 -0
  41. data/test/drip/client/conversions_test.rb +47 -0
  42. data/test/drip/client/custom_fields_test.rb +30 -0
  43. data/test/drip/client/events_test.rb +21 -5
  44. data/test/drip/client/forms_test.rb +47 -0
  45. data/test/drip/client/purchases_test.rb +0 -1
  46. data/test/drip/client/subscribers_test.rb +52 -9
  47. data/test/drip/client/webhooks_test.rb +91 -0
  48. data/test/drip/client/workflow_triggers_test.rb +85 -0
  49. data/test/drip/client/workflows_test.rb +122 -0
  50. data/test/drip/collection_test.rb +1 -1
  51. data/test/drip/collections_test.rb +8 -1
  52. data/test/drip/resources_test.rb +8 -1
  53. data/test/drip/response_test.rb +2 -2
  54. data/test/test_helper.rb +1 -1
  55. metadata +40 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7bfa63019608f669aab60be61b9771d95ab1666
4
- data.tar.gz: a7708994dd22d0eea312cd3287ec632ea1e91a03
3
+ metadata.gz: 5aafc1c74dbc6f3b1394f304f7d1b9ceb3fe829d
4
+ data.tar.gz: 9a83f650a30e9c127c1a594fcbbd6964af009966
5
5
  SHA512:
6
- metadata.gz: 02f2eaf930c8fe3ab029429b53ea4c2673677ab99b348a3a448d3e5670d1f0a69285c7b1c7b8fdf25fe4cae0d8c35fdc7fbe73bf22000e3c8dfd047f8f48a678
7
- data.tar.gz: c50c9f97d8fd803084222660d162d0a559d26962632d99d5fa783a4d8c7b0907b82dc911600978c2702ca32025659fb7b469ed83daf5327e0e9d9eee308c7f9e
6
+ metadata.gz: 0a36ee1b8ac89b1fb63663e49d383acc3a3d15ff22e6bccf3afe5a5ab6cf17d4c76b5ae5369fe8a44383317d1db63fbda43432e1ad9c41c37ad3569bd9377a58
7
+ data.tar.gz: 64d97aea9e8937326694c91e34abbd8825890dc31476e0efc22403fef440b9569edf4a5b0ddd3b211e32a3e859290aaa4269acd29698c4d8da380cea578c0ffd
@@ -0,0 +1,17 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - 'test/fixtures/**/*'
6
+
7
+ Layout/AlignParameters:
8
+ EnforcedStyle: with_fixed_indentation
9
+
10
+ Layout/ClosingParenthesisIndentation:
11
+ Enabled: false
12
+
13
+ Layout/DotPosition:
14
+ EnforcedStyle: trailing
15
+
16
+ Style/BracesAroundHashParameters:
17
+ Enabled: false
@@ -0,0 +1,134 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-12-22 12:38:29 -0600 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: SupportedStyles, IndentationWidth.
12
+ # SupportedStyles: outdent, indent
13
+ Layout/AccessModifierIndentation:
14
+ EnforcedStyle: outdent
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ Layout/ElseAlignment:
19
+ Exclude:
20
+ - 'lib/drip/response.rb'
21
+
22
+ # Offense count: 1
23
+ # Cop supports --auto-correct.
24
+ Layout/EmptyLineAfterMagicComment:
25
+ Exclude:
26
+ - 'drip-ruby.gemspec'
27
+
28
+ # Offense count: 2
29
+ # Cop supports --auto-correct.
30
+ # Configuration parameters: SupportedStyles, IndentationWidth.
31
+ # SupportedStyles: special_inside_parentheses, consistent, align_braces
32
+ Layout/IndentHash:
33
+ EnforcedStyle: consistent
34
+
35
+ # Offense count: 1
36
+ # Cop supports --auto-correct.
37
+ # Configuration parameters: Width, IgnoredPatterns.
38
+ Layout/IndentationWidth:
39
+ Exclude:
40
+ - 'lib/drip/response.rb'
41
+
42
+ # Offense count: 1
43
+ # Cop supports --auto-correct.
44
+ # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
45
+ # SupportedStyles: aligned, indented, indented_relative_to_receiver
46
+ Layout/MultilineMethodCallIndentation:
47
+ Exclude:
48
+ - 'lib/drip/collection.rb'
49
+
50
+ # Offense count: 1
51
+ # Cop supports --auto-correct.
52
+ # Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
53
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
54
+ Lint/EndAlignment:
55
+ Exclude:
56
+ - 'lib/drip/response.rb'
57
+
58
+ # Offense count: 1
59
+ Lint/ScriptPermission:
60
+ Exclude:
61
+ - 'Rakefile'
62
+
63
+ # Offense count: 1
64
+ # Cop supports --auto-correct.
65
+ # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
66
+ Lint/UnusedBlockArgument:
67
+ Exclude:
68
+ - 'lib/drip/response.rb'
69
+
70
+ # Offense count: 2
71
+ # Cop supports --auto-correct.
72
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
73
+ Lint/UnusedMethodArgument:
74
+ Exclude:
75
+ - 'lib/drip/client.rb'
76
+ - 'lib/drip/collection.rb'
77
+
78
+ # Offense count: 7
79
+ # Configuration parameters: CountComments, ExcludedMethods.
80
+ Metrics/BlockLength:
81
+ Max: 48
82
+
83
+ # Offense count: 2
84
+ # Configuration parameters: CountComments.
85
+ Metrics/ClassLength:
86
+ Max: 189
87
+
88
+ # Offense count: 78
89
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
90
+ # URISchemes: http, https
91
+ Metrics/LineLength:
92
+ Max: 108
93
+
94
+ # Offense count: 4
95
+ # Configuration parameters: CountComments.
96
+ Metrics/MethodLength:
97
+ Max: 16
98
+
99
+ # Offense count: 22
100
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
101
+ # SupportedStyles: nested, compact
102
+ Style/ClassAndModuleChildren:
103
+ Enabled: false
104
+
105
+ # Offense count: 42
106
+ Style/Documentation:
107
+ Enabled: false
108
+
109
+ # Offense count: 2
110
+ Style/MethodMissing:
111
+ Exclude:
112
+ - 'lib/drip/resource.rb'
113
+ - 'lib/drip/response.rb'
114
+
115
+ # Offense count: 9
116
+ # Cop supports --auto-correct.
117
+ # Configuration parameters: Strict.
118
+ Style/NumericLiterals:
119
+ MinDigits: 8
120
+
121
+ # Offense count: 494
122
+ # Cop supports --auto-correct.
123
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
124
+ # SupportedStyles: single_quotes, double_quotes
125
+ Style/StringLiterals:
126
+ Enabled: false
127
+
128
+ # Offense count: 1
129
+ # Cop supports --auto-correct.
130
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
131
+ # SupportedStyles: single_quotes, double_quotes
132
+ Style/StringLiteralsInInterpolation:
133
+ Exclude:
134
+ - 'test/drip/client_test.rb'
data/README.md CHANGED
@@ -4,7 +4,7 @@ A Ruby toolkit for the [Drip](https://www.getdrip.com/) API.
4
4
 
5
5
  [![Build Status](https://travis-ci.org/DripEmail/drip-ruby.svg?branch=master)](https://travis-ci.org/DripEmail/drip-ruby)
6
6
  [![Code Climate](https://codeclimate.com/github/DripEmail/drip-ruby/badges/gpa.svg)](https://codeclimate.com/github/DripEmail/drip-ruby)
7
-
7
+ [![Gem Version](https://badge.fury.io/rb/drip-ruby.svg)](https://badge.fury.io/rb/drip-ruby)
8
8
 
9
9
 
10
10
  ## Installation
@@ -61,30 +61,124 @@ the "list accounts" endpoint.
61
61
  Since the Drip client is a flat API client, most API actions are available
62
62
  as methods on the client object. The following methods are currently available:
63
63
 
64
- | Action | Method |
64
+ #### Accounts
65
+
66
+ | Actions | Methods |
65
67
  | :------------------------- | :--------------------------------------------------- |
66
68
  | List accounts | `#accounts` |
69
+ | Fetch an account | `#account(id)` |
70
+
71
+ #### Broadcasts
72
+
73
+ | Actions | Methods |
74
+ | :------------------------- | :--------------------------------------------------- |
75
+ | List broadcasts | `#broadcasts` |
76
+ | Fetch a broadcast | `#broadcast(id)` |
77
+
78
+ #### Campaigns
79
+
80
+ | Actions | Methods |
81
+ | :------------------------- | :--------------------------------------------------- |
82
+ | List campaigns | `#campaigns(options = {})` |
83
+ | Fetch a campaign | `#campaign(id)` |
84
+ | Activate a campaign | `#activate_campaign(id)` |
85
+ | Pause a campaign | `#pause_campaign(id)` |
86
+ | List campaign subscribers | `#campaign_subscribers(id)` |
87
+ | Subscribe to a campaign | See the `#subscribe` method on "Subscribers" below |
88
+
89
+ #### Campaign Subscriptions
90
+
91
+ | Actions | Methods |
92
+ | :------------------------- | :--------------------------------------------------- |
93
+ | List subscriber subscriptions | `#campaign_subscriptions(subscriber_id)` |
94
+
95
+ #### Conversions
96
+
97
+ | Actions | Methods |
98
+ | :------------------------- | :--------------------------------------------------- |
99
+ | List all conversions | `#conversions(options = {})` |
100
+ | Fetch a conversion | `#conversion(id)` |
101
+
102
+ #### Custom Fields
103
+
104
+ | Actions | Methods |
105
+ | :------------------------- | :--------------------------------------------------- |
106
+ | List all custom fields | `#custom_fields` |
107
+
108
+ #### Events
109
+
110
+ | Actions | Methods |
111
+ | :------------------------- | :--------------------------------------------------- |
112
+ | Track an event | `#track_event(email, action, properties = {})` |
113
+ | Track a batch of events | `#track_events(events)` |
114
+ | List all custom event actions | `#event_actions` |
115
+
116
+ #### Forms
117
+
118
+ | Actions | Methods |
119
+ | :------------------------- | :--------------------------------------------------- |
120
+ | List all forms | `#forms` |
121
+ | Fetch a form | `#form(id)` |
122
+
123
+ #### Purchases
124
+
125
+ | Actions | Methods |
126
+ | :------------------------- | :--------------------------------------------------- |
127
+ | List purchases for a subscriber | `#purchases(email)` |
128
+ | Create a purchase         | `#create_purchase(email, amount, options = {})` |
129
+ | Fetch a purchase | `#purchase(email, id)` |
130
+
131
+ #### Subscribers
132
+
133
+ | Actions | Methods |
134
+ | :------------------------- | :--------------------------------------------------- |
67
135
  | List subscribers | `#subscribers(options = {})` |
68
136
  | Create/update a subscriber | `#create_or_update_subscriber(email, options = {})` |
69
137
  | Create/update a batch of subscribers | `#create_or_update_subscribers(subscribers)` |
138
+ | Unsubscribe a batch of subscribers | `#unsubscribe_subscribers(subscribers)` |
70
139
  | Fetch a subscriber | `#subscriber(id_or_email)` |
140
+ | Delete | `#delete_subscriber(id_or_email)` |
71
141
  | Subscribe to a campaign | `#subscribe(email, campaign_id, options = {})` |
142
+ | Unsubscribe from all mailings | `#unsubscribe_from_all(id_or_email)` |
72
143
  | Unsubscribe | `#unsubscribe(id_or_email, options = {})` |
73
- | Delete | `#delete_subscriber(id_or_email)` |
144
+
145
+ #### Tags
146
+
147
+ | Actions | Methods |
148
+ | :------------------------- | :--------------------------------------------------- |
74
149
  | List tags | `#tags` |
75
150
  | Apply a tag | `#apply_tag(email, tag)` |
76
151
  | Remove a tag | `#remove_tag(email, tag)` |
77
- | Track an event | `#track_event(email, action, properties = {})` |
78
- | Track a batch of events | `#track_events(events)` |
79
- | List campaigns | `#campaigns` |
80
- | Create a purchase         | `#create_purchase(email, amount, options = {})` |
81
- | List purchases for a subscriber | `#purchases(email)` |
82
- | Fetch a purchase | `#purchase(email, id)` |
83
152
 
84
- **Note:** We do not have complete API coverage yet. If we are missing an API method
85
- that you need to use in your application, please file an issue and/or open a
86
- pull request. [See the official REST API docs](https://www.getdrip.com/docs/rest-api)
87
- for a complete API reference.
153
+ #### Webhooks
154
+
155
+ | Actions | Methods |
156
+ | :------------------------- | :--------------------------------------------------- |
157
+ | List webhooks | `#webhooks` |
158
+ | Fetch a webhook | `#webhook(id)` |
159
+ | Create a new webhook | `#create_webhook(post_url, include_received_email, events)` |
160
+ | Delete a webhook | `#delete_webhook(id)` |
161
+
162
+ #### Workflows
163
+
164
+ | Actions | Methods |
165
+ | :------------------------- | :--------------------------------------------------- |
166
+ | List workflows | `#workflows` |
167
+ | Fetch a workflow | `#workflow(id)` |
168
+ | Activate a workflow | `#activate_workflow(id)` |
169
+ | Pause a workflow | `#pause_workflow(id)` |
170
+ | Start a subscriber on a workflow | `#start_subscriber_workflow(id, options = {})` |
171
+ | Remove a subscriber from a workflow | `#remove_subscriber_workflow(workflow_id, id_or_email)` |
172
+
173
+ #### Workflow Triggers
174
+
175
+ | Actions | Methods |
176
+ | :------------------------- | :--------------------------------------------------- |
177
+ | List workflow triggers | `#workflow_triggers(id)` |
178
+ | Create a workflow trigger | `#create_workflow_trigger(id, options = {})` |
179
+ | Update a workflow trigger | `#update_workflow_trigger(id, options = {}` |
180
+
181
+ [See the official REST API docs](https://www.getdrip.com/docs/rest-api) for a complete API reference and explanations.
88
182
 
89
183
  ## Use Cases
90
184
 
data/Rakefile CHANGED
@@ -9,4 +9,4 @@ Rake::TestTask.new do |t|
9
9
  end
10
10
 
11
11
  desc "Run tests"
12
- task :default => :test
12
+ task default: :test
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Drip::VERSION
9
9
  spec.authors = ["Derrick Reimer"]
10
10
  spec.email = ["derrickreimer@gmail.com"]
11
- spec.summary = %q{A Ruby gem for interacting with the Drip API}
12
- spec.description = %q{A simple wrapper for the Drip API}
11
+ spec.summary = 'A Ruby gem for interacting with the Drip API'
12
+ spec.description = 'A simple wrapper for the Drip API'
13
13
  spec.homepage = "http://github.com/DripEmail/drip-ruby"
14
14
  spec.license = "MIT"
15
15
 
@@ -1,10 +1,18 @@
1
1
  require "drip/response"
2
2
  require "drip/client/accounts"
3
- require "drip/client/subscribers"
4
- require "drip/client/tags"
5
- require "drip/client/events"
3
+ require "drip/client/broadcasts"
6
4
  require "drip/client/campaigns"
5
+ require "drip/client/campaign_subscriptions"
6
+ require "drip/client/conversions"
7
+ require "drip/client/custom_fields"
8
+ require "drip/client/events"
9
+ require "drip/client/forms"
7
10
  require "drip/client/purchases"
11
+ require "drip/client/subscribers"
12
+ require "drip/client/tags"
13
+ require "drip/client/webhooks"
14
+ require "drip/client/workflows"
15
+ require "drip/client/workflow_triggers"
8
16
  require "faraday"
9
17
  require "faraday_middleware"
10
18
  require "json"
@@ -12,11 +20,19 @@ require "json"
12
20
  module Drip
13
21
  class Client
14
22
  include Accounts
15
- include Subscribers
16
- include Tags
17
- include Events
23
+ include Broadcasts
18
24
  include Campaigns
25
+ include CampaignSubscriptions
26
+ include Conversions
27
+ include CustomFields
28
+ include Events
29
+ include Forms
19
30
  include Purchases
31
+ include Subscribers
32
+ include Tags
33
+ include Webhooks
34
+ include Workflows
35
+ include WorkflowTriggers
20
36
 
21
37
  attr_accessor :access_token, :api_key, :account_id
22
38
 
@@ -83,7 +99,7 @@ module Drip
83
99
  f.basic_auth api_key, ""
84
100
  end
85
101
 
86
- f.response :json, :content_type => /\bjson$/
102
+ f.response :json, content_type: /\bjson$/
87
103
  f.adapter :net_http
88
104
  end
89
105
  end
@@ -8,6 +8,16 @@ module Drip
8
8
  def accounts
9
9
  get "accounts"
10
10
  end
11
+
12
+ # Public: Fetch an account.
13
+ #
14
+ # id - Required. The String id of the account.
15
+ #
16
+ # Returns a Drip::Response.
17
+ # See https://www.getdrip.com/docs/rest-api#accounts
18
+ def account(id)
19
+ get "accounts/#{id}"
20
+ end
11
21
  end
12
22
  end
13
23
  end
@@ -0,0 +1,29 @@
1
+ module Drip
2
+ class Client
3
+ module Broadcasts
4
+ # Public: Fetch all broadcasts to which the authenticated user has access
5
+ #
6
+ # options - A Hash of options.
7
+ # - status - Optional. Filter by one of the following statuses:
8
+ # draft, or scheduled, or sent. Defaults to all.
9
+ # - sort - Optional. Sort results by one of these fields:
10
+ # `send_at`, `name`. Default sorting is `created_at`
11
+ #
12
+ # Returns a Drip::Response
13
+ # See https://www.getdrip.com/docs/rest-api#broadcasts
14
+ def broadcasts(options = {})
15
+ get "#{account_id}/broadcasts", options
16
+ end
17
+
18
+ # Public: Fetch a broadcast.
19
+ #
20
+ # id - Required. The String id of the broadcast.
21
+ #
22
+ # Returns a Drip::Response.
23
+ # See https://www.getdrip.com/docs/rest-api#broadcasts
24
+ def broadcast(id)
25
+ get "#{account_id}/broadcasts/#{id}"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ module Drip
2
+ class Client
3
+ module CampaignSubscriptions
4
+ # Public: List all of a subscriber's campaign subscriptions
5
+ #
6
+ # subscriber_id - Required. The String subscriber id of the subscriber
7
+ #
8
+ # Returns a Drip::Response.
9
+ # See https://www.getdrip.com/docs.rest-api#campaign_subscriptions
10
+ def campaign_subscriptions(subscriber_id)
11
+ get "#{account_id}/subscribers/#{subscriber_id}/campaign_subscriptions"
12
+ end
13
+ end
14
+ end
15
+ end