mailchimp3 1.3.0 → 1.5.0

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
- SHA1:
3
- metadata.gz: 3e45026dc2842662fdb63c4157e0eacf8e9130b5
4
- data.tar.gz: a5fab8bb945eed4f6e1fb58376476898840f1131
2
+ SHA256:
3
+ metadata.gz: 9cbd11ed385734e5b3719ce213019557918c9c23d9ab15bfe335fd35e4557a16
4
+ data.tar.gz: 01b3df2167db48a16ea8486b25870912757922f88076802bd96c428d536cc78d
5
5
  SHA512:
6
- metadata.gz: 5e7484201b9482868970ef36a08150ad9be6309d29a8a58f943d9686953a2ed26bbbf1def927e0422031bd548d487fad09ad1db8ba41cb9d0b59ad3ae7b0097a
7
- data.tar.gz: 74e9966c1e0fd770d5dcfacc7674d883444d87deb473919587812fce715968c3275d936a5ac1f69896cd0568ae43296bfa77b305a7ac7f33f22e5961af489d40
6
+ metadata.gz: 1de3e48b29ccd3b6b04c97473e133a106563e6236b2fb1600f3cf0fc50b1c7094b9814fd8d09f61c5e67d3212aab11abb6f8e136711e195a439723f24e329946
7
+ data.tar.gz: 8e919852e61313c847c24e327e1558198945164614fee124144206d12e076db0bfbf672dc3538ed92812c9025ccba8d605927f8611757d7b447afc01fa8835fe
@@ -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
- _build_response(@last_result)
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 = {})
@@ -44,6 +48,13 @@ module MailChimp3
44
48
  _build_response(@last_result)
45
49
  end
46
50
 
51
+ def put(body = {})
52
+ @last_result = _connection.put(@url) do |req|
53
+ req.body = body.to_json
54
+ end
55
+ _build_response(@last_result)
56
+ end
57
+
47
58
  def delete
48
59
  @last_result = _connection.delete(@url)
49
60
  if @last_result.status == 204
@@ -13,8 +13,13 @@ module MailChimp3
13
13
  )
14
14
  end
15
15
 
16
- def authorize_url(redirect_uri:)
17
- @oauth.auth_code.authorize_url(redirect_uri: redirect_uri)
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:)
@@ -1,3 +1,3 @@
1
1
  module MailChimp3
2
- VERSION = '1.3.0'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -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
@@ -197,6 +208,38 @@ describe MailChimp3::Endpoint do
197
208
  end
198
209
  end
199
210
 
211
+ describe '#put' do
212
+ subject { base.lists[list_id].members[md5_hash] }
213
+
214
+ let(:list_id) { 'd3ed40bd7c' }
215
+ let(:member_email) { 'test@email.com' }
216
+ let(:md5_hash) { Digest::MD5.hexdigest(member_email) }
217
+ let(:resource) do
218
+ {
219
+ 'email_address' => member_email,
220
+ 'status_if_new' => 'subscribed'
221
+ }
222
+ end
223
+
224
+ let(:result) do
225
+ {
226
+ 'id' => md5_hash,
227
+ 'list_id' => list_id,
228
+ 'status' => 'subscribed'
229
+ }
230
+ end
231
+
232
+ before do
233
+ stub_request(:put, "https://us2.api.mailchimp.com/3.0/lists/#{list_id}/members/#{md5_hash}")
234
+ .to_return(status: 200, body: result.to_json, headers: { 'Content-Type' => 'application/json; charset=utf-8' })
235
+ @result = subject.put(resource)
236
+ end
237
+
238
+ it 'returns the result of making a PUT request to the endpoint' do
239
+ expect(@result).to eq(result)
240
+ end
241
+ end
242
+
200
243
  describe '#delete' do
201
244
  subject { base.lists['d3ed40bd7c'] }
202
245
 
@@ -210,4 +253,5 @@ describe MailChimp3::Endpoint do
210
253
  expect(@result).to eq(true)
211
254
  end
212
255
  end
256
+
213
257
  end
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailchimp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-15 00:00:00.000000000 Z
11
+ date: 2021-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.1
19
+ version: '0.9'
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: 0.9.1
26
+ version: '0.9'
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: 0.45.3
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: 0.45.3
40
+ version: 0.71.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: oauth2
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.0
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.0
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -132,13 +132,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubyforge_project:
136
- rubygems_version: 2.5.1
135
+ rubygems_version: 3.0.3
137
136
  signing_key:
138
137
  specification_version: 4
139
138
  summary: wrapper for MailChimp's 3.0 API
140
139
  test_files:
140
+ - spec/spec_helper.rb
141
+ - spec/mailchimp3_spec.rb
141
142
  - spec/mailchimp3/endpoint_spec.rb
142
143
  - spec/mailchimp3/oauth_spec.rb
143
- - spec/mailchimp3_spec.rb
144
- - spec/spec_helper.rb