drip-ruby 2.0.0 → 3.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.
- checksums.yaml +5 -5
- data/.rubocop.yml +14 -1
- data/.rubocop_todo.yml +51 -85
- data/.travis.yml +1 -0
- data/CHANGELOG.md +62 -0
- data/Rakefile +4 -2
- data/drip-ruby.gemspec +6 -6
- data/lib/drip/client.rb +45 -34
- data/lib/drip/client/orders.rb +4 -4
- data/lib/drip/errors.rb +3 -0
- data/lib/drip/response.rb +5 -5
- data/lib/drip/version.rb +1 -1
- data/test/drip/client/accounts_test.rb +6 -15
- data/test/drip/client/broadcasts_test.rb +6 -15
- data/test/drip/client/campaign_subscriptions_test.rb +3 -11
- data/test/drip/client/campaigns_test.rb +15 -27
- data/test/drip/client/conversions_test.rb +6 -15
- data/test/drip/client/custom_fields_test.rb +3 -11
- data/test/drip/client/events_test.rb +12 -23
- data/test/drip/client/forms_test.rb +6 -15
- data/test/drip/client/orders_test.rb +48 -58
- data/test/drip/client/subscribers_test.rb +33 -51
- data/test/drip/client/tags_test.rb +9 -19
- data/test/drip/client/webhooks_test.rb +12 -23
- data/test/drip/client/workflow_triggers_test.rb +9 -19
- data/test/drip/client/workflows_test.rb +18 -31
- data/test/drip/client_test.rb +70 -3
- data/test/test_helper.rb +1 -8
- metadata +26 -27
- data/lib/drip/client/purchases.rb +0 -23
- data/test/drip/client/purchases_test.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e94a763ab5337f4f242daa28a135553e23969965
|
4
|
+
data.tar.gz: aaa3aa129287f0f640dd03e96dcd441abb362c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f8426121809e826beded4b6715b3d986d5a446d82f02881cf539d0a2393755bd00a03e71437a0e71c631bd2a7417882edfd360f16e52048f6dc4dd0fa50f3a4
|
7
|
+
data.tar.gz: f28420d43b416f076c3f61df6b6da1224983124c7181b96d0e8db142fdcd260704a5c13214f4553b18d493dc3cfdfd56da156b64e6334d6fe5cfac5c0208a952
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
+
TargetRubyVersion: '2.1'
|
4
5
|
Exclude:
|
5
6
|
- 'test/fixtures/**/*'
|
6
7
|
|
@@ -14,4 +15,16 @@ Layout/DotPosition:
|
|
14
15
|
EnforcedStyle: trailing
|
15
16
|
|
16
17
|
Style/BracesAroundHashParameters:
|
17
|
-
Enabled: false
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Layout/AccessModifierIndentation:
|
21
|
+
EnforcedStyle: outdent
|
22
|
+
|
23
|
+
Metrics/LineLength:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Layout/MultilineOperationIndentation:
|
27
|
+
EnforcedStyle: 'indented'
|
28
|
+
|
29
|
+
Layout/MultilineMethodCallIndentation:
|
30
|
+
EnforcedStyle: 'indented'
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-05-24 10:21:33 -0500 using RuboCop version 0.56.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -8,127 +8,93 @@
|
|
8
8
|
|
9
9
|
# Offense count: 2
|
10
10
|
# Cop supports --auto-correct.
|
11
|
-
# Configuration parameters:
|
12
|
-
|
13
|
-
Layout/AccessModifierIndentation:
|
14
|
-
EnforcedStyle: outdent
|
15
|
-
|
16
|
-
# Offense count: 1
|
17
|
-
# Cop supports --auto-correct.
|
18
|
-
Layout/ElseAlignment:
|
11
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
12
|
+
Lint/UnusedMethodArgument:
|
19
13
|
Exclude:
|
20
|
-
- 'lib/drip/
|
14
|
+
- 'lib/drip/client.rb'
|
15
|
+
- 'lib/drip/collection.rb'
|
21
16
|
|
22
17
|
# Offense count: 1
|
23
|
-
|
24
|
-
|
25
|
-
Exclude:
|
26
|
-
- 'drip-ruby.gemspec'
|
18
|
+
Metrics/AbcSize:
|
19
|
+
Max: 26
|
27
20
|
|
28
|
-
# Offense count:
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
# Offense count: 5
|
22
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
23
|
+
Metrics/BlockLength:
|
24
|
+
Max: 46
|
25
|
+
|
26
|
+
# Offense count: 3
|
27
|
+
# Configuration parameters: CountComments.
|
28
|
+
Metrics/ClassLength:
|
29
|
+
Max: 173
|
30
|
+
|
31
|
+
# Offense count: 4
|
32
|
+
# Configuration parameters: CountComments.
|
33
|
+
Metrics/MethodLength:
|
34
|
+
Max: 26
|
34
35
|
|
35
36
|
# Offense count: 1
|
37
|
+
Metrics/PerceivedComplexity:
|
38
|
+
Max: 8
|
39
|
+
|
40
|
+
# Offense count: 4
|
36
41
|
# Cop supports --auto-correct.
|
37
|
-
|
38
|
-
Layout/IndentationWidth:
|
42
|
+
Performance/InefficientHashSearch:
|
39
43
|
Exclude:
|
44
|
+
- 'lib/drip/resource.rb'
|
40
45
|
- 'lib/drip/response.rb'
|
41
46
|
|
42
|
-
# Offense count:
|
47
|
+
# Offense count: 23
|
43
48
|
# Cop supports --auto-correct.
|
44
|
-
# Configuration parameters:
|
45
|
-
# SupportedStyles:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
50
|
+
# SupportedStyles: nested, compact
|
51
|
+
Style/ClassAndModuleChildren:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
# Offense count: 45
|
55
|
+
Style/Documentation:
|
56
|
+
Enabled: false
|
49
57
|
|
50
58
|
# Offense count: 1
|
51
59
|
# Cop supports --auto-correct.
|
52
|
-
|
53
|
-
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
54
|
-
Lint/EndAlignment:
|
60
|
+
Style/Encoding:
|
55
61
|
Exclude:
|
56
|
-
- '
|
62
|
+
- 'drip-ruby.gemspec'
|
57
63
|
|
58
|
-
# Offense count:
|
59
|
-
|
64
|
+
# Offense count: 2
|
65
|
+
# Cop supports --auto-correct.
|
66
|
+
Style/ExpandPathArguments:
|
60
67
|
Exclude:
|
61
|
-
- '
|
68
|
+
- 'drip-ruby.gemspec'
|
69
|
+
- 'test/test_helper.rb'
|
62
70
|
|
63
71
|
# Offense count: 1
|
64
|
-
#
|
65
|
-
|
66
|
-
Lint/UnusedBlockArgument:
|
72
|
+
# Configuration parameters: MinBodyLength.
|
73
|
+
Style/GuardClause:
|
67
74
|
Exclude:
|
68
|
-
- 'lib/drip/
|
75
|
+
- 'lib/drip/client.rb'
|
69
76
|
|
70
77
|
# Offense count: 2
|
71
78
|
# Cop supports --auto-correct.
|
72
|
-
|
73
|
-
Lint/UnusedMethodArgument:
|
79
|
+
Style/IfUnlessModifier:
|
74
80
|
Exclude:
|
75
81
|
- '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
82
|
|
83
83
|
# Offense count: 2
|
84
|
-
|
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:
|
84
|
+
Style/MissingRespondToMissing:
|
111
85
|
Exclude:
|
112
86
|
- 'lib/drip/resource.rb'
|
113
87
|
- 'lib/drip/response.rb'
|
114
88
|
|
115
|
-
# Offense count:
|
89
|
+
# Offense count: 10
|
116
90
|
# Cop supports --auto-correct.
|
117
91
|
# Configuration parameters: Strict.
|
118
92
|
Style/NumericLiterals:
|
119
93
|
MinDigits: 8
|
120
94
|
|
121
|
-
# Offense count:
|
95
|
+
# Offense count: 605
|
122
96
|
# Cop supports --auto-correct.
|
123
|
-
# Configuration parameters: EnforcedStyle,
|
97
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
124
98
|
# SupportedStyles: single_quotes, double_quotes
|
125
99
|
Style/StringLiterals:
|
126
100
|
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/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [3.0.0] - 2018-05-29
|
8
|
+
|
9
|
+
[3.0.0]: https://github.com/DripEmail/drip-ruby/compare/v2.0.0...v3.0.0
|
10
|
+
|
11
|
+
### Added
|
12
|
+
- `Drip::Client#url_prefix` method to enable pointing client at different endpoints (mostly useful for internal testing and mocking).
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Switched from Faraday to Net::HTTP. This also removes the `Drip::Client#connection` method, as it directly exposed Faraday.
|
16
|
+
|
17
|
+
### Removed
|
18
|
+
- Removed deprecated `#create_purchase` call.
|
19
|
+
|
20
|
+
## [2.0.0] - 2018-03-27
|
21
|
+
|
22
|
+
[2.0.0]: https://github.com/DripEmail/drip-ruby/compare/v1.0.0...v2.0.0
|
23
|
+
|
24
|
+
- Purchases endpoint removed and replaced with orders.
|
25
|
+
|
26
|
+
## [1.0.0] - 2017-12-27
|
27
|
+
|
28
|
+
[1.0.0]: https://github.com/DripEmail/drip-ruby/compare/v0.0.12...v1.0.0
|
29
|
+
|
30
|
+
- Add broadcasts endpoints
|
31
|
+
- Add account fetch
|
32
|
+
- Add campaign and campaign subscription endpoints
|
33
|
+
- Add conversion endpoints
|
34
|
+
- Add custom field endpoints
|
35
|
+
- Add event action endpoints
|
36
|
+
- Add form endpoints
|
37
|
+
- Add unsubscribe features
|
38
|
+
- Add webhook api endpoints
|
39
|
+
|
40
|
+
## [0.0.12] - 2017-09-21
|
41
|
+
|
42
|
+
[0.0.12]: https://github.com/DripEmail/drip-ruby/compare/v0.0.11...v0.0.12
|
43
|
+
|
44
|
+
- Update Faraday from 0.9 to 0.13
|
45
|
+
|
46
|
+
## [0.0.11] - 2017-06-20
|
47
|
+
|
48
|
+
[0.0.11]: https://github.com/DripEmail/drip-ruby/compare/v0.0.10...v0.0.11
|
49
|
+
|
50
|
+
- Handle rate limiting
|
51
|
+
|
52
|
+
## [0.0.10] - 2017-02-21
|
53
|
+
|
54
|
+
[0.0.10]: https://github.com/DripEmail/drip-ruby/compare/v0.0.9...v0.0.10
|
55
|
+
|
56
|
+
- Tag initializer bugfix
|
57
|
+
|
58
|
+
## [0.0.9] - 2017-02-21
|
59
|
+
|
60
|
+
[0.0.9]: https://github.com/DripEmail/drip-ruby/compare/v0.0.8...v0.0.9
|
61
|
+
|
62
|
+
- Tag constant name typo bugfix
|
data/Rakefile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
1
|
require "bundler/gem_tasks"
|
3
2
|
require "rake/testtask"
|
4
3
|
|
4
|
+
require "rubocop/rake_task"
|
5
|
+
RuboCop::RakeTask.new
|
6
|
+
|
5
7
|
Rake::TestTask.new do |t|
|
6
8
|
t.libs << "lib"
|
7
9
|
t.pattern = "test/**/*_test.rb"
|
@@ -9,4 +11,4 @@ Rake::TestTask.new do |t|
|
|
9
11
|
end
|
10
12
|
|
11
13
|
desc "Run tests"
|
12
|
-
task default:
|
14
|
+
task default: %i[rubocop test]
|
data/drip-ruby.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'drip/version'
|
@@ -18,14 +19,13 @@ Gem::Specification.new do |spec|
|
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
|
-
spec.required_ruby_version = '>= 1
|
22
|
+
spec.required_ruby_version = '>= 2.1'
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
+
spec.add_development_dependency "mocha", "~> 1.1"
|
24
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rubocop", "~> 0.56.0"
|
25
29
|
spec.add_development_dependency "shoulda-context", "~> 1.0"
|
26
|
-
spec.add_development_dependency "
|
27
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
-
|
29
|
-
spec.add_runtime_dependency "faraday", "~> 0.13"
|
30
|
-
spec.add_runtime_dependency "faraday_middleware", "~> 0.12"
|
30
|
+
spec.add_development_dependency "webmock", "~> 3.4"
|
31
31
|
end
|
data/lib/drip/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "drip/errors"
|
1
2
|
require "drip/response"
|
2
3
|
require "drip/client/accounts"
|
3
4
|
require "drip/client/broadcasts"
|
@@ -8,14 +9,13 @@ require "drip/client/custom_fields"
|
|
8
9
|
require "drip/client/events"
|
9
10
|
require "drip/client/forms"
|
10
11
|
require "drip/client/orders"
|
11
|
-
require "drip/client/purchases"
|
12
12
|
require "drip/client/subscribers"
|
13
13
|
require "drip/client/tags"
|
14
14
|
require "drip/client/webhooks"
|
15
15
|
require "drip/client/workflows"
|
16
16
|
require "drip/client/workflow_triggers"
|
17
|
-
require "
|
18
|
-
require "
|
17
|
+
require "net/http"
|
18
|
+
require "uri"
|
19
19
|
require "json"
|
20
20
|
|
21
21
|
module Drip
|
@@ -29,19 +29,21 @@ module Drip
|
|
29
29
|
include Events
|
30
30
|
include Forms
|
31
31
|
include Orders
|
32
|
-
include Purchases
|
33
32
|
include Subscribers
|
34
33
|
include Tags
|
35
34
|
include Webhooks
|
36
35
|
include Workflows
|
37
36
|
include WorkflowTriggers
|
38
37
|
|
39
|
-
|
38
|
+
REDIRECT_LIMIT = 10
|
39
|
+
|
40
|
+
attr_accessor :access_token, :api_key, :account_id, :url_prefix
|
40
41
|
|
41
42
|
def initialize(options = {})
|
42
43
|
@account_id = options[:account_id]
|
43
44
|
@access_token = options[:access_token]
|
44
45
|
@api_key = options[:api_key]
|
46
|
+
@url_prefix = options[:url_prefix] || "https://api.getdrip.com/v2/"
|
45
47
|
yield(self) if block_given?
|
46
48
|
end
|
47
49
|
|
@@ -54,30 +56,57 @@ module Drip
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def get(url, options = {})
|
57
|
-
make_request(
|
59
|
+
make_request(Net::HTTP::Get, make_uri(url), options)
|
58
60
|
end
|
59
61
|
|
60
62
|
def post(url, options = {})
|
61
|
-
make_request(
|
63
|
+
make_request(Net::HTTP::Post, make_uri(url), options)
|
62
64
|
end
|
63
65
|
|
64
66
|
def put(url, options = {})
|
65
|
-
make_request(
|
67
|
+
make_request(Net::HTTP::Put, make_uri(url), options)
|
66
68
|
end
|
67
69
|
|
68
70
|
def delete(url, options = {})
|
69
|
-
make_request(
|
71
|
+
make_request(Net::HTTP::Delete, make_uri(url), options)
|
70
72
|
end
|
71
73
|
|
72
|
-
|
74
|
+
private
|
75
|
+
|
76
|
+
def make_uri(path)
|
77
|
+
URI(url_prefix) + URI(path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def make_request(verb_klass, uri, options, step = 0)
|
81
|
+
raise TooManyRedirectsError, 'too many HTTP redirects' if step >= REDIRECT_LIMIT
|
82
|
+
|
73
83
|
build_response do
|
74
|
-
|
75
|
-
|
84
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
85
|
+
if verb_klass.is_a? Net::HTTP::Get
|
86
|
+
uri.query = URI.encode_www_form(options)
|
87
|
+
end
|
88
|
+
|
89
|
+
request = verb_klass.new uri
|
90
|
+
|
91
|
+
unless verb_klass.is_a? Net::HTTP::Get
|
92
|
+
request.body = options.to_json
|
93
|
+
end
|
76
94
|
|
77
|
-
|
78
|
-
|
95
|
+
request['User-Agent'] = "Drip Ruby v#{Drip::VERSION}"
|
96
|
+
request['Content-Type'] = content_type
|
97
|
+
request['Accept'] = "*/*"
|
98
|
+
|
99
|
+
if access_token
|
100
|
+
request['Authorization'] = "Bearer #{access_token}"
|
79
101
|
else
|
80
|
-
|
102
|
+
request.basic_auth api_key, ""
|
103
|
+
end
|
104
|
+
|
105
|
+
response = http.request request
|
106
|
+
if response.is_a?(Net::HTTPRedirection)
|
107
|
+
return make_request(verb_klass, URI(response["Location"]), options, step + 1)
|
108
|
+
else
|
109
|
+
response
|
81
110
|
end
|
82
111
|
end
|
83
112
|
end
|
@@ -85,25 +114,7 @@ module Drip
|
|
85
114
|
|
86
115
|
def build_response(&block)
|
87
116
|
response = yield
|
88
|
-
Drip::Response.new(response.
|
89
|
-
end
|
90
|
-
|
91
|
-
def connection
|
92
|
-
@connection ||= Faraday.new do |f|
|
93
|
-
f.url_prefix = "https://api.getdrip.com/v2/"
|
94
|
-
f.headers['User-Agent'] = "Drip Ruby v#{Drip::VERSION}"
|
95
|
-
f.headers['Content-Type'] = content_type
|
96
|
-
f.headers['Accept'] = "*/*"
|
97
|
-
|
98
|
-
if access_token
|
99
|
-
f.headers['Authorization'] = "Bearer #{access_token}"
|
100
|
-
else
|
101
|
-
f.basic_auth api_key, ""
|
102
|
-
end
|
103
|
-
|
104
|
-
f.response :json, content_type: /\bjson$/
|
105
|
-
f.adapter :net_http
|
106
|
-
end
|
117
|
+
Drip::Response.new(response.code.to_i, response.body)
|
107
118
|
end
|
108
119
|
end
|
109
120
|
end
|