mailchimp_api_v3 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mailchimp_api_v3.rb +1 -1
- data/lib/mailchimp_api_v3/client.rb +1 -1
- data/lib/mailchimp_api_v3/client/remote.rb +3 -3
- data/lib/mailchimp_api_v3/exception.rb +9 -9
- data/lib/mailchimp_api_v3/instance.rb +5 -0
- data/lib/mailchimp_api_v3/interest.rb +1 -1
- data/lib/mailchimp_api_v3/interest_category.rb +3 -3
- data/lib/mailchimp_api_v3/list.rb +1 -1
- data/lib/mailchimp_api_v3/member.rb +1 -1
- data/lib/mailchimp_api_v3/version.rb +1 -1
- data/mailchimp_api_v3.gemspec +1 -1
- data/spec/mailchimp_api_v3/member_spec.rb +1 -1
- data/spec/mailchimp_api_v3/members_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5bd68d37be74e00ba3cc25767c6eb284dacbfb6
|
4
|
+
data.tar.gz: 38fdd51235a7defcdc13a26da6f9a062299cd42b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da6e188a8a5664611e1d78f3dc046455818d204bc4979d5243421825d9844a872b625dd7e1f854c24e822baac9514a59d9134d18b181aab6c894ef4c00e9aaf7
|
7
|
+
data.tar.gz: 497263a595bfeef764a482f809a096d4af6d5b5cc4dd0afdd1a6c85cebe7b8d1c2e25d66c219b68bc73322157494e10318f7a47a081e05a5d31d2c0b7962f0d1
|
data/lib/mailchimp_api_v3.rb
CHANGED
@@ -22,7 +22,7 @@ module Mailchimp
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
RETRY_EXCEPTIONS = [SocketError]
|
25
|
+
RETRY_EXCEPTIONS = [SocketError].freeze
|
26
26
|
|
27
27
|
def managed_remote(path, method = :get, options = {}, payload = nil)
|
28
28
|
headers_and_params = headers.merge params_from(options)
|
@@ -40,11 +40,11 @@ module Mailchimp
|
|
40
40
|
exception_class_name = e.class.to_s
|
41
41
|
|
42
42
|
if Mailchimp::Exception::MAPPED_EXCEPTIONS.key? exception_class_name
|
43
|
-
|
43
|
+
raise Mailchimp::Exception::MAPPED_EXCEPTIONS[exception_class_name], data
|
44
44
|
elsif exception_class_name == 'RestClient::BadRequest'
|
45
45
|
Mailchimp::Exception.parse_invalid_resource_exception data
|
46
46
|
else
|
47
|
-
|
47
|
+
raise e
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -3,13 +3,9 @@ module Mailchimp
|
|
3
3
|
def self.parse_invalid_resource_exception(data)
|
4
4
|
detail = data['detail']
|
5
5
|
|
6
|
-
if detail.include? 'already'
|
7
|
-
|
8
|
-
|
9
|
-
fail MissingField, data
|
10
|
-
else
|
11
|
-
fail BadRequest, data
|
12
|
-
end
|
6
|
+
raise Duplicate, data if detail.include? 'already'
|
7
|
+
raise MissingField, data if detail.include? 'can\'t be blank'
|
8
|
+
raise BadRequest, data
|
13
9
|
end
|
14
10
|
|
15
11
|
class DataException < RuntimeError
|
@@ -19,7 +15,11 @@ module Mailchimp
|
|
19
15
|
end
|
20
16
|
|
21
17
|
def method_missing(symbol)
|
22
|
-
@data[symbol.id2name]
|
18
|
+
symbol.is_a?(Symbol) ? @data[symbol.id2name] : super
|
19
|
+
end
|
20
|
+
|
21
|
+
def respond_to_missing?(symbol)
|
22
|
+
symbol.is_a?(Symbol)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -35,6 +35,6 @@ module Mailchimp
|
|
35
35
|
MAPPED_EXCEPTIONS = {
|
36
36
|
'RestClient::ResourceNotFound' => NotFound,
|
37
37
|
'RestClient::Unauthorized' => APIKeyError
|
38
|
-
}
|
38
|
+
}.freeze
|
39
39
|
end
|
40
40
|
end
|
@@ -59,6 +59,11 @@ module Mailchimp
|
|
59
59
|
super
|
60
60
|
end
|
61
61
|
|
62
|
+
def respond_to_missing?(symbol)
|
63
|
+
key = symbol.id2name
|
64
|
+
@data.key? key
|
65
|
+
end
|
66
|
+
|
62
67
|
def subclass_instance_from(collection_class, id)
|
63
68
|
child_path = "#{path}/#{collection_class::PATH_KEY}"
|
64
69
|
collection_class::CHILD_CLASS.get @client, child_path, id
|
@@ -9,9 +9,9 @@ module Mailchimp
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class InterestCategories < Collection
|
12
|
-
NAME_FIELD = 'title'
|
13
|
-
PATH_KEY = 'interest-categories'
|
14
|
-
DATA_KEY = 'categories'
|
12
|
+
NAME_FIELD = 'title'.freeze
|
13
|
+
PATH_KEY = 'interest-categories'.freeze
|
14
|
+
DATA_KEY = 'categories'.freeze
|
15
15
|
CHILD_CLASS = InterestCategory
|
16
16
|
end
|
17
17
|
end
|
data/mailchimp_api_v3.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = 'A simple gem to interact with Mailchimp through their API v3'
|
11
11
|
spec.summary = 'Example: mailchimp.lists("My first list").member("ann@example.com")'
|
12
12
|
spec.homepage = 'https://github.com/Xenapto/mailchimp_api_v3'
|
13
|
-
spec.license = 'BSD'
|
13
|
+
spec.license = 'BSD-2-Clause'
|
14
14
|
|
15
15
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
16
|
spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
|
@@ -82,12 +82,12 @@ describe Mailchimp::List::Members do
|
|
82
82
|
# Update
|
83
83
|
data = { first_name: 'Catherine', email_address: 'cat@sayers.cc', status: 'subscribed' }
|
84
84
|
expect { members.create_or_update data }.not_to change { list.members.count }
|
85
|
-
expect(members.create_or_update
|
85
|
+
expect(members.create_or_update(data)).to have_attributes name: 'Catherine Sayers'
|
86
86
|
|
87
87
|
# Unless we supply an id or equivalent, we won't end up updating anything
|
88
88
|
data = { name: 'Catherine Sayers' }
|
89
89
|
expect { members.create_or_update data }.not_to change { list.members.count }
|
90
|
-
expect(members.create_or_update
|
90
|
+
expect(members.create_or_update(data)).to have_attributes name: 'Catherine Sayers'
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailchimp_api_v3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xenapto
|
@@ -260,7 +260,7 @@ files:
|
|
260
260
|
- spec/support/vcr_setup.rb
|
261
261
|
homepage: https://github.com/Xenapto/mailchimp_api_v3
|
262
262
|
licenses:
|
263
|
-
- BSD
|
263
|
+
- BSD-2-Clause
|
264
264
|
metadata: {}
|
265
265
|
post_install_message:
|
266
266
|
rdoc_options: []
|