mailchimp3 1.3.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailchimp3/endpoint.rb +7 -3
- data/lib/mailchimp3/oauth.rb +7 -2
- data/lib/mailchimp3/version.rb +1 -1
- data/spec/mailchimp3/endpoint_spec.rb +11 -0
- data/spec/mailchimp3/oauth_spec.rb +8 -0
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 564fb3786d7423ea5a754d20a27ebf36fd74d2632dccad2a44519f244f9d9659
|
4
|
+
data.tar.gz: b5c95259d49bcc670e4f8056dd6e095dafa2fb6a65760f379907fef9d0d1f0eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f651eb58e4dd3400ed26a7e5f961e2bfd099b3a169df6cfa35ac5c2f2f812c25d7d8abe4d4ebacab64437882264a9fe8d1e26d395e6c43cbcd12fa77a82dedc4
|
7
|
+
data.tar.gz: 2682cad9d1731968fc2c889454f0c9bb2f8f55212be1e795f227b910ca1c849ab72462f8ca00c6a37e8a618d81212dccd35f744cba273c133a904b2fcbee5a04
|
data/lib/mailchimp3/endpoint.rb
CHANGED
@@ -34,7 +34,11 @@ module MailChimp3
|
|
34
34
|
body[:apikey] = @oauth_access_token || @basic_auth_key if @version == 2
|
35
35
|
req.body = body.to_json
|
36
36
|
end
|
37
|
-
|
37
|
+
if @last_result.status == 204
|
38
|
+
true
|
39
|
+
else
|
40
|
+
_build_response(@last_result)
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def patch(body = {})
|
@@ -126,14 +130,14 @@ module MailChimp3
|
|
126
130
|
|
127
131
|
def _connection
|
128
132
|
@connection ||= Faraday.new(url: url) do |faraday|
|
129
|
-
faraday.adapter :excon
|
130
133
|
if @basic_auth_key
|
131
|
-
faraday.basic_auth '', @basic_auth_key
|
134
|
+
faraday.request :basic_auth, '', @basic_auth_key
|
132
135
|
elsif @oauth_access_token
|
133
136
|
faraday.headers['Authorization'] = "Bearer #{@oauth_access_token}"
|
134
137
|
else
|
135
138
|
fail Errors::AuthRequiredError, "You must specify either HTTP basic auth credentials or an OAuth2 access token."
|
136
139
|
end
|
140
|
+
faraday.adapter :excon
|
137
141
|
end
|
138
142
|
end
|
139
143
|
end
|
data/lib/mailchimp3/oauth.rb
CHANGED
@@ -13,8 +13,13 @@ module MailChimp3
|
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
|
-
def authorize_url(redirect_uri:)
|
17
|
-
|
16
|
+
def authorize_url(redirect_uri:, state: nil)
|
17
|
+
params = {
|
18
|
+
redirect_uri: redirect_uri,
|
19
|
+
state: state,
|
20
|
+
}.compact
|
21
|
+
|
22
|
+
@oauth.auth_code.authorize_url(params)
|
18
23
|
end
|
19
24
|
|
20
25
|
def complete_auth(code, redirect_uri:)
|
data/lib/mailchimp3/version.rb
CHANGED
@@ -167,6 +167,17 @@ describe MailChimp3::Endpoint do
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
170
|
+
|
171
|
+
context 'when the response is 204' do
|
172
|
+
before do
|
173
|
+
stub_request(:post, 'https://us2.api.mailchimp.com/3.0/lists')
|
174
|
+
.to_return(status: 204, body: nil, headers: { 'Content-Type' => 'application/json; charset=utf-8' })
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'returns true' do
|
178
|
+
expect(subject.post(resource)).to eq(true)
|
179
|
+
end
|
180
|
+
end
|
170
181
|
end
|
171
182
|
|
172
183
|
describe '#patch' do
|
@@ -13,6 +13,14 @@ describe MailChimp3::OAuth do
|
|
13
13
|
)
|
14
14
|
expect(url).to eq('https://login.mailchimp.com/oauth2/authorize?client_id=foo&redirect_uri=http%3A%2F%2Fexample.com%2Foauth%2Fcallback&response_type=code')
|
15
15
|
end
|
16
|
+
|
17
|
+
it 'passes through an optional state param' do
|
18
|
+
url = subject.authorize_url(
|
19
|
+
redirect_uri: 'http://example.com/oauth/callback',
|
20
|
+
state: "123456"
|
21
|
+
)
|
22
|
+
expect(url).to eq('https://login.mailchimp.com/oauth2/authorize?client_id=foo&redirect_uri=http%3A%2F%2Fexample.com%2Foauth%2Fcallback&response_type=code&state=123456')
|
23
|
+
end
|
16
24
|
end
|
17
25
|
|
18
26
|
describe '#complete_auth' do
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailchimp3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: excon
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.71.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.71.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: oauth2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,12 +132,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
|
-
rubygems_version: 3.0.1
|
135
|
+
rubygems_version: 3.0.3.1
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: wrapper for MailChimp's 3.0 API
|
139
139
|
test_files:
|
140
140
|
- spec/spec_helper.rb
|
141
141
|
- spec/mailchimp3_spec.rb
|
142
|
-
- spec/mailchimp3/oauth_spec.rb
|
143
142
|
- spec/mailchimp3/endpoint_spec.rb
|
143
|
+
- spec/mailchimp3/oauth_spec.rb
|