mailchimp_api_v3 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +5 -5
- data/lib/mailchimp_api_v3.rb +16 -0
- data/lib/mailchimp_api_v3/account.rb +1 -1
- data/lib/mailchimp_api_v3/client.rb +3 -3
- data/lib/mailchimp_api_v3/client/remote.rb +3 -3
- data/lib/mailchimp_api_v3/collection.rb +1 -1
- data/lib/mailchimp_api_v3/collection/paging.rb +1 -1
- data/lib/mailchimp_api_v3/exception.rb +1 -1
- data/lib/mailchimp_api_v3/instance.rb +2 -2
- data/lib/mailchimp_api_v3/interest.rb +1 -1
- data/lib/mailchimp_api_v3/interest_categories.rb +1 -1
- data/lib/mailchimp_api_v3/interest_category.rb +1 -1
- data/lib/mailchimp_api_v3/interests.rb +1 -1
- data/lib/mailchimp_api_v3/list.rb +1 -1
- data/lib/mailchimp_api_v3/lists.rb +1 -1
- data/lib/mailchimp_api_v3/member.rb +1 -1
- data/lib/mailchimp_api_v3/members.rb +1 -1
- data/lib/mailchimp_api_v3/version.rb +2 -2
- data/mailchimp_api_v3.gemspec +1 -1
- data/spec/mailchimp_api_v3/account_spec.rb +17 -0
- data/spec/{mailchimp → mailchimp_api_v3}/client_spec.rb +9 -9
- data/spec/{mailchimp → mailchimp_api_v3}/exception_spec.rb +14 -14
- data/spec/{mailchimp → mailchimp_api_v3}/interest_categories_spec.rb +8 -8
- data/spec/{mailchimp → mailchimp_api_v3}/interest_category_spec.rb +4 -4
- data/spec/{mailchimp → mailchimp_api_v3}/interest_spec.rb +3 -3
- data/spec/{mailchimp → mailchimp_api_v3}/interests_spec.rb +7 -7
- data/spec/{mailchimp → mailchimp_api_v3}/list_spec.rb +7 -7
- data/spec/{mailchimp → mailchimp_api_v3}/lists_spec.rb +3 -3
- data/spec/{mailchimp → mailchimp_api_v3}/member_spec.rb +4 -4
- data/spec/{mailchimp → mailchimp_api_v3}/members_spec.rb +4 -4
- data/spec/mailchimp_spec.rb +4 -4
- metadata +24 -23
- data/spec/mailchimp/account_spec.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb3dc62663ec203d2d9e0c0a90bead5dd237422c
|
4
|
+
data.tar.gz: 152265412ea8717fecf81db4477cd98e133e08c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1374abb4143591b1eba1e9698fe116360595298b76a89fd257230e5496282a5b429b0d1a90ba62f53188e179efe17107a4677a04b5ea26b821ff20da6db91451
|
7
|
+
data.tar.gz: acd6b8b0ca5bbac91b6e2158ea267d5d82faff46da2d3943a55d8715e3cca9dea4d9dc8f9b2b56d228654f88784ac8ab9609209b601bf41961e9ce58da734e28
|
data/README.md
CHANGED
@@ -37,21 +37,21 @@ To connect to the Mailchimp API you need to supply an API key. You can do this e
|
|
37
37
|
Examples:
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
|
41
|
-
|
40
|
+
Mailchimp.connect(my_api_key) # Uses the API key in my_api_key
|
41
|
+
Mailchimp.connect # Uses ENV['MAILCHIMP_API_KEY']
|
42
42
|
```
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
|
45
|
+
Mailchimp.connect.lists
|
46
46
|
```
|
47
47
|
|
48
48
|
```ruby
|
49
|
-
mailchimp =
|
49
|
+
mailchimp = Mailchimp.connect
|
50
50
|
list = mailchimp.lists.find_by name: 'My first list'
|
51
51
|
```
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
mailchimp =
|
54
|
+
mailchimp = Mailchimp.connect
|
55
55
|
member = mailchimp.lists('e73f5910ca').members('ann@example.com')
|
56
56
|
member.name # => "Ann Example"
|
57
57
|
```
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'mailchimp_api_v3/version'
|
2
|
+
require 'mailchimp_api_v3/client'
|
3
|
+
|
4
|
+
module Mailchimp
|
5
|
+
def self.connect(api_key = nil)
|
6
|
+
Client.new api_key
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Hash
|
11
|
+
def deep_stringify_keys
|
12
|
+
result = {}
|
13
|
+
each { |k, v| result[k.to_s] = v.is_a?(Hash) ? v.deep_stringify_keys : v }
|
14
|
+
result
|
15
|
+
end
|
16
|
+
end
|
@@ -5,7 +5,7 @@ require 'mailchimp_api_v3/account'
|
|
5
5
|
require 'mailchimp_api_v3/lists'
|
6
6
|
require 'mailchimp_api_v3/client/remote'
|
7
7
|
|
8
|
-
module
|
8
|
+
module Mailchimp
|
9
9
|
class Client
|
10
10
|
include Remote
|
11
11
|
|
@@ -19,7 +19,7 @@ module MailchimpAPIV3
|
|
19
19
|
|
20
20
|
def connected?
|
21
21
|
account
|
22
|
-
rescue
|
22
|
+
rescue Mailchimp::Exception::APIKeyError
|
23
23
|
false
|
24
24
|
else
|
25
25
|
true
|
@@ -31,7 +31,7 @@ module MailchimpAPIV3
|
|
31
31
|
@api_key = api_key || ENV['MAILCHIMP_API_KEY']
|
32
32
|
|
33
33
|
fail(
|
34
|
-
|
34
|
+
Mailchimp::Exception::APIKeyError,
|
35
35
|
'title' => "Invalid API key format: #{@api_key}"
|
36
36
|
) unless api_key_valid?
|
37
37
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'restclient'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Mailchimp
|
5
5
|
class Client
|
6
6
|
module Remote
|
7
7
|
def get(path = '', options = {})
|
@@ -34,9 +34,9 @@ module MailchimpAPIV3
|
|
34
34
|
def managed_remote_exception(e)
|
35
35
|
case e.class.to_s # TODO: Find out why this won't match the class except by name string
|
36
36
|
when 'RestClient::Unauthorized'
|
37
|
-
fail
|
37
|
+
fail Mailchimp::Exception::APIKeyError, YAML.load(e.http_body)
|
38
38
|
when 'RestClient::BadRequest'
|
39
|
-
|
39
|
+
Mailchimp::Exception.parse_invalid_resource_exception YAML.load(e.http_body)
|
40
40
|
else
|
41
41
|
fail e
|
42
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Mailchimp
|
2
2
|
module Instance
|
3
3
|
module InstanceMethods
|
4
4
|
def initialize(client, data, collection_path = '')
|
@@ -48,7 +48,7 @@ module MailchimpAPIV3
|
|
48
48
|
def fail_unless_exists(key, options = {})
|
49
49
|
return if @data.key? key
|
50
50
|
message = options == {} ? key : "#{key}: #{options}"
|
51
|
-
fail
|
51
|
+
fail Mailchimp::Exception::UnknownAttribute, message
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '0.0.
|
1
|
+
module Mailchimp
|
2
|
+
VERSION = '0.0.5'
|
3
3
|
end
|
data/mailchimp_api_v3.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'mailchimp_api_v3/version'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'mailchimp_api_v3'
|
7
|
-
spec.version =
|
7
|
+
spec.version = Mailchimp::VERSION
|
8
8
|
spec.authors = ['Xenapto']
|
9
9
|
spec.email = ['developers@xenapto.com']
|
10
10
|
spec.description = 'A simple gem to interact with Mailchimp through their API v3'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'mailchimp_api_v3'
|
4
|
+
|
5
|
+
describe Mailchimp::Account, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
it 'is the expected class' do
|
7
|
+
expect(Mailchimp.connect.account).to be_a Mailchimp::Account
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has a name' do
|
11
|
+
expect(Mailchimp.connect.account.name).to eq 'InSite Arts'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has an id' do
|
15
|
+
expect(Mailchimp.connect.account.id).to eq '1dbca289fd41b54838bcbb501'
|
16
|
+
end
|
17
|
+
end
|
@@ -2,41 +2,41 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Mailchimp::Client, vcr: { cassette_name: 'mailchimp' } do
|
6
6
|
context 'unauthorized API key' do
|
7
7
|
let(:bad_key) { 'xxxxxxxxxx-us11' }
|
8
8
|
|
9
9
|
it 'raises an exception if we try to get data' do
|
10
|
-
expect {
|
10
|
+
expect { Mailchimp::Client.new(bad_key).account }.to raise_error Mailchimp::Exception::APIKeyError
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'says it is not connected' do
|
14
|
-
expect(
|
14
|
+
expect(Mailchimp::Client.new(bad_key).connected?).to be_falsey
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'valid API key' do
|
19
19
|
it 'says it is connected' do
|
20
|
-
expect(
|
20
|
+
expect(Mailchimp::Client.new.connected?).to be_truthy
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'is the expected class' do
|
24
|
-
expect(
|
24
|
+
expect(Mailchimp::Client.new).to be_a Mailchimp::Client
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'has an account method' do
|
28
|
-
expect(
|
28
|
+
expect(Mailchimp::Client.new.account).to be_a Mailchimp::Account
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'has a lists collection' do
|
32
|
-
lists =
|
32
|
+
lists = Mailchimp::Client.new.lists
|
33
33
|
expect(lists).to be_an Array
|
34
|
-
expect(lists.sample).to be_a
|
34
|
+
expect(lists.sample).to be_a Mailchimp::List
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
context 'problems we can retry the request for' do
|
39
|
-
let(:client) {
|
39
|
+
let(:client) { Mailchimp::Client.new }
|
40
40
|
|
41
41
|
it 'eventually raises the exception' do
|
42
42
|
allow(client).to receive(:remote_no_payload).and_raise SocketError.new('test message')
|
@@ -2,12 +2,12 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Mailchimp::Exception::APIKeyError, vcr: { cassette_name: 'mailchimp' } do
|
6
6
|
let(:bad_key) { 'xxxxxxxxxx-us11' }
|
7
7
|
|
8
8
|
it 'raises an exception if the API key is not valid' do
|
9
|
-
expect {
|
10
|
-
expect(e).to be_a
|
9
|
+
expect { Mailchimp.connect(bad_key).account }.to raise_error { |e|
|
10
|
+
expect(e).to be_a Mailchimp::Exception::APIKeyError
|
11
11
|
expect(e.type).to eq 'http://kb.mailchimp.com/api/error-docs/401-api-key-invalid'
|
12
12
|
expect(e.title).to eq 'API Key Invalid'
|
13
13
|
expect(e.status).to eq 401
|
@@ -16,38 +16,38 @@ describe MailchimpAPIV3::Exception::APIKeyError, vcr: { cassette_name: 'mailchim
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'does not raise an exception if the API key is valid' do
|
19
|
-
expect {
|
19
|
+
expect { Mailchimp.connect.account }.not_to raise_error
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
let(:account) {
|
23
|
+
describe Mailchimp::Exception::UnknownAttribute, vcr: { cassette_name: 'mailchimp' } do
|
24
|
+
let(:account) { Mailchimp.connect.account }
|
25
25
|
|
26
26
|
it 'returns a known attribute' do
|
27
27
|
expect { account.name }.not_to raise_error
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'fails if we ask for an unknown attribute' do
|
31
|
-
expect { account.blarbleferry }.to raise_error
|
31
|
+
expect { account.blarbleferry }.to raise_error Mailchimp::Exception::UnknownAttribute
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
35
|
+
describe Mailchimp::Exception::BadRequest do
|
36
36
|
it 'raises a Duplicate exception if the message says so' do
|
37
37
|
data = { 'detail' => 'The thing already exists, idiot' }
|
38
|
-
expect {
|
39
|
-
.to raise_error
|
38
|
+
expect { Mailchimp::Exception.parse_invalid_resource_exception data }
|
39
|
+
.to raise_error Mailchimp::Exception::Duplicate
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'raises a MissingField exception if the message says so' do
|
43
43
|
data = { 'detail' => 'The thing can\'t be blank, idiot' }
|
44
|
-
expect {
|
45
|
-
.to raise_error
|
44
|
+
expect { Mailchimp::Exception.parse_invalid_resource_exception data }
|
45
|
+
.to raise_error Mailchimp::Exception::MissingField
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'raises a BadRequest exception otherwise' do
|
49
49
|
data = { 'detail' => 'The thing is an idiot' }
|
50
|
-
expect {
|
51
|
-
.to raise_error
|
50
|
+
expect { Mailchimp::Exception.parse_invalid_resource_exception data }
|
51
|
+
.to raise_error Mailchimp::Exception::BadRequest
|
52
52
|
end
|
53
53
|
end
|
@@ -2,12 +2,12 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:list) {
|
5
|
+
describe Mailchimp::List::InterestCategories, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:list) { Mailchimp.connect.lists.first }
|
7
7
|
let(:interest_categories) { list.interest_categories }
|
8
8
|
|
9
9
|
it 'is the expected class' do
|
10
|
-
expect(interest_categories).to be_a
|
10
|
+
expect(interest_categories).to be_a Mailchimp::List::InterestCategories
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'has a count' do
|
@@ -17,7 +17,7 @@ describe MailchimpAPIV3::List::InterestCategories, vcr: { cassette_name: 'mailch
|
|
17
17
|
it 'finds a matching instance' do
|
18
18
|
data = { 'title' => 'Colors' }
|
19
19
|
interest_category = interest_categories.find_by data
|
20
|
-
expect(interest_category).to be_a
|
20
|
+
expect(interest_category).to be_a Mailchimp::List::InterestCategory
|
21
21
|
expect(interest_category.id).to eq '2ce011eb68'
|
22
22
|
end
|
23
23
|
|
@@ -26,13 +26,13 @@ describe MailchimpAPIV3::List::InterestCategories, vcr: { cassette_name: 'mailch
|
|
26
26
|
it 'can add a new instance' do
|
27
27
|
data = { 'title' => 'Days', 'type' => 'checkboxes' }
|
28
28
|
interest_category = interest_categories.create data
|
29
|
-
expect(interest_category).to be_a
|
29
|
+
expect(interest_category).to be_a Mailchimp::List::InterestCategory
|
30
30
|
expect(interest_category.title).to eq 'Days'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'fails adding an instance with the same details' do
|
34
34
|
data = { 'title' => 'Colors', 'type' => 'checkboxes' }
|
35
|
-
expect { interest_categories.create data }.to raise_error
|
35
|
+
expect { interest_categories.create data }.to raise_error Mailchimp::Exception::Duplicate
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,14 +40,14 @@ describe MailchimpAPIV3::List::InterestCategories, vcr: { cassette_name: 'mailch
|
|
40
40
|
it 'finds an instance with the same details' do
|
41
41
|
data = { 'title' => 'Colors', 'type' => 'checkboxes' }
|
42
42
|
interest_category = interest_categories.first_or_create data
|
43
|
-
expect(interest_category).to be_a
|
43
|
+
expect(interest_category).to be_a Mailchimp::List::InterestCategory
|
44
44
|
expect(interest_category.title).to eq 'Colors'
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'creates a new instance if one does not yet exist' do
|
48
48
|
data = { 'title' => 'Sex', 'type' => 'radio' }
|
49
49
|
interest_category = interest_categories.first_or_create data
|
50
|
-
expect(interest_category).to be_a
|
50
|
+
expect(interest_category).to be_a Mailchimp::List::InterestCategory
|
51
51
|
expect(interest_category.title).to eq 'Sex'
|
52
52
|
end
|
53
53
|
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:lists) {
|
5
|
+
describe Mailchimp::List::InterestCategory, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:lists) { Mailchimp.connect.lists }
|
7
7
|
let(:list) { lists.first }
|
8
8
|
let(:interest_category) { list.interest_categories.first }
|
9
9
|
|
10
10
|
it 'is the expected class' do
|
11
|
-
expect(interest_category).to be_a
|
11
|
+
expect(interest_category).to be_a Mailchimp::List::InterestCategory
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'has a title' do
|
@@ -22,6 +22,6 @@ describe MailchimpAPIV3::List::InterestCategory, vcr: { cassette_name: 'mailchim
|
|
22
22
|
it 'has an interests collection' do
|
23
23
|
interests = interest_category.interests
|
24
24
|
expect(interests).to be_an Array
|
25
|
-
expect(interests.sample).to be_a
|
25
|
+
expect(interests.sample).to be_a Mailchimp::List::InterestCategory::Interest
|
26
26
|
end
|
27
27
|
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:lists) {
|
5
|
+
describe Mailchimp::List::InterestCategory::Interest, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:lists) { Mailchimp.connect.lists }
|
7
7
|
let(:list) { lists.first }
|
8
8
|
let(:interest_category) { list.interest_categories.first }
|
9
9
|
let(:interest) { interest_category.interests.first }
|
10
10
|
|
11
11
|
it 'is the expected class' do
|
12
|
-
expect(interest).to be_a
|
12
|
+
expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'has a name' do
|
@@ -2,13 +2,13 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:list) {
|
5
|
+
describe Mailchimp::List::InterestCategory::Interests, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:list) { Mailchimp.connect.lists.first }
|
7
7
|
let(:interest_category) { list.interest_categories.first }
|
8
8
|
let(:interests) { interest_category.interests }
|
9
9
|
|
10
10
|
it 'is the expected class' do
|
11
|
-
expect(interests).to be_a
|
11
|
+
expect(interests).to be_a Mailchimp::List::InterestCategory::Interests
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'has a count' do
|
@@ -20,13 +20,13 @@ describe MailchimpAPIV3::List::InterestCategory::Interests, vcr: { cassette_name
|
|
20
20
|
it 'can add a new instance' do
|
21
21
|
data = { 'name' => 'Green' }
|
22
22
|
interest = interests.create data
|
23
|
-
expect(interest).to be_a
|
23
|
+
expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
|
24
24
|
expect(interest.name).to eq 'Green'
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'fails adding an instance with the same details' do
|
28
28
|
data = { 'name' => 'Red' }
|
29
|
-
expect { interests.create data }.to raise_error
|
29
|
+
expect { interests.create data }.to raise_error Mailchimp::Exception::Duplicate
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -34,14 +34,14 @@ describe MailchimpAPIV3::List::InterestCategory::Interests, vcr: { cassette_name
|
|
34
34
|
it 'finds an instance with the same details' do
|
35
35
|
data = { 'name' => 'Red' }
|
36
36
|
interest = interests.first_or_create data
|
37
|
-
expect(interest).to be_a
|
37
|
+
expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
|
38
38
|
expect(interest.name).to eq 'red' # Note case
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'creates a new instance if one does not yet exist' do
|
42
42
|
data = { 'name' => 'Amber' }
|
43
43
|
interest = interests.first_or_create data
|
44
|
-
expect(interest).to be_a
|
44
|
+
expect(interest).to be_a Mailchimp::List::InterestCategory::Interest
|
45
45
|
expect(interest.name).to eq 'Amber'
|
46
46
|
end
|
47
47
|
end
|
@@ -2,12 +2,12 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:lists) {
|
5
|
+
describe Mailchimp::List, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:lists) { Mailchimp.connect.lists }
|
7
7
|
let(:list) { lists.first }
|
8
8
|
|
9
9
|
it 'is the expected class' do
|
10
|
-
expect(list).to be_a
|
10
|
+
expect(list).to be_a Mailchimp::List
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'has a name' do
|
@@ -25,13 +25,13 @@ describe MailchimpAPIV3::List, vcr: { cassette_name: 'mailchimp' } do
|
|
25
25
|
it 'has a members collection' do
|
26
26
|
members = list.members
|
27
27
|
expect(members).to be_an Array
|
28
|
-
expect(members.sample).to be_a
|
28
|
+
expect(members.sample).to be_a Mailchimp::List::Member
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'has a interest_categories collection' do
|
32
32
|
interest_categories = list.interest_categories
|
33
33
|
expect(interest_categories).to be_an Array
|
34
|
-
expect(interest_categories.sample).to be_a
|
34
|
+
expect(interest_categories.sample).to be_a Mailchimp::List::InterestCategory
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'get a specific member' do
|
@@ -40,14 +40,14 @@ describe MailchimpAPIV3::List, vcr: { cassette_name: 'mailchimp' } do
|
|
40
40
|
|
41
41
|
it 'gets a member by id' do
|
42
42
|
member = list.members id
|
43
|
-
expect(member).to be_a
|
43
|
+
expect(member).to be_a Mailchimp::List::Member
|
44
44
|
expect(member.id).to eq id
|
45
45
|
expect(member.email_address).to eq email_address
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'gets a member by email address' do
|
49
49
|
member = list.members email_address
|
50
|
-
expect(member).to be_a
|
50
|
+
expect(member).to be_a Mailchimp::List::Member
|
51
51
|
expect(member.id).to eq id
|
52
52
|
expect(member.email_address).to eq email_address
|
53
53
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:lists) {
|
5
|
+
describe Mailchimp::Lists, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:lists) { Mailchimp.connect.lists }
|
7
7
|
|
8
8
|
it 'is the expected class' do
|
9
|
-
expect(lists).to be_a
|
9
|
+
expect(lists).to be_a Mailchimp::Lists
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'has a count' do
|
@@ -2,13 +2,13 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
6
|
-
let(:lists) {
|
5
|
+
describe Mailchimp::List::Member, vcr: { cassette_name: 'mailchimp' } do
|
6
|
+
let(:lists) { Mailchimp.connect.lists }
|
7
7
|
let(:list) { lists.first }
|
8
8
|
let(:member) { list.members.first }
|
9
9
|
|
10
10
|
it 'is the expected class' do
|
11
|
-
expect(member).to be_a
|
11
|
+
expect(member).to be_a Mailchimp::List::Member
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'has a name' do
|
@@ -22,7 +22,7 @@ describe MailchimpAPIV3::List::Member, vcr: { cassette_name: 'mailchimp' } do
|
|
22
22
|
context 'updates name fields correctly' do
|
23
23
|
it 'uses friendly name fields' do
|
24
24
|
updated_member = member.update name: 'Billy Bonkers'
|
25
|
-
expect(updated_member).to be_a
|
25
|
+
expect(updated_member).to be_a Mailchimp::List::Member
|
26
26
|
expect(updated_member).to have_attributes name: 'Billy Bonkers'
|
27
27
|
|
28
28
|
updated_member = updated_member.update first_name: 'William'
|
@@ -2,14 +2,14 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Mailchimp::List::Members, vcr: { cassette_name: 'members' } do
|
6
6
|
let(:page_size) { 10 }
|
7
7
|
let(:member_count) { 37 }
|
8
|
-
let(:list) {
|
8
|
+
let(:list) { Mailchimp.connect.lists.first }
|
9
9
|
let(:members) { list.members 'page_size' => page_size }
|
10
10
|
|
11
11
|
it 'is the expected class' do
|
12
|
-
expect(members).to be_a
|
12
|
+
expect(members).to be_a Mailchimp::List::Members
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'has a count' do
|
@@ -29,6 +29,6 @@ describe MailchimpAPIV3::List::Members, vcr: { cassette_name: 'members' } do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'has a Member for each item' do
|
32
|
-
expect(members.sample).to be_a
|
32
|
+
expect(members.sample).to be_a Mailchimp::List::Member
|
33
33
|
end
|
34
34
|
end
|
data/spec/mailchimp_spec.rb
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
require 'mailchimp_api_v3'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe Mailchimp do
|
6
6
|
it 'does not attempt to connect without an API key in the right format' do
|
7
|
-
expect {
|
8
|
-
expect(e).to be_a
|
7
|
+
expect { Mailchimp.connect '' }.to raise_error { |e|
|
8
|
+
expect(e).to be_a Mailchimp::Exception::APIKeyError
|
9
9
|
expect(e.message).to eq 'Invalid API key format: '
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'connects with an API key' do
|
14
|
-
expect {
|
14
|
+
expect { Mailchimp.connect }.not_to raise_error
|
15
15
|
end
|
16
16
|
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.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xenapto
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- LICENSE
|
222
222
|
- README.md
|
223
223
|
- circle.yml
|
224
|
+
- lib/mailchimp_api_v3.rb
|
224
225
|
- lib/mailchimp_api_v3/account.rb
|
225
226
|
- lib/mailchimp_api_v3/client.rb
|
226
227
|
- lib/mailchimp_api_v3/client/remote.rb
|
@@ -240,17 +241,17 @@ files:
|
|
240
241
|
- mailchimp_api_v3.gemspec
|
241
242
|
- spec/fixtures/cassettes/mailchimp.yml
|
242
243
|
- spec/fixtures/cassettes/members.yml
|
243
|
-
- spec/
|
244
|
-
- spec/
|
245
|
-
- spec/
|
246
|
-
- spec/
|
247
|
-
- spec/
|
248
|
-
- spec/
|
249
|
-
- spec/
|
250
|
-
- spec/
|
251
|
-
- spec/
|
252
|
-
- spec/
|
253
|
-
- spec/
|
244
|
+
- spec/mailchimp_api_v3/account_spec.rb
|
245
|
+
- spec/mailchimp_api_v3/client_spec.rb
|
246
|
+
- spec/mailchimp_api_v3/exception_spec.rb
|
247
|
+
- spec/mailchimp_api_v3/interest_categories_spec.rb
|
248
|
+
- spec/mailchimp_api_v3/interest_category_spec.rb
|
249
|
+
- spec/mailchimp_api_v3/interest_spec.rb
|
250
|
+
- spec/mailchimp_api_v3/interests_spec.rb
|
251
|
+
- spec/mailchimp_api_v3/list_spec.rb
|
252
|
+
- spec/mailchimp_api_v3/lists_spec.rb
|
253
|
+
- spec/mailchimp_api_v3/member_spec.rb
|
254
|
+
- spec/mailchimp_api_v3/members_spec.rb
|
254
255
|
- spec/mailchimp_spec.rb
|
255
256
|
- spec/spec_helper.rb
|
256
257
|
- spec/support/api_key.rb
|
@@ -282,17 +283,17 @@ summary: 'Example: mailchimp.lists("My first list").member("ann@example.com")'
|
|
282
283
|
test_files:
|
283
284
|
- spec/fixtures/cassettes/mailchimp.yml
|
284
285
|
- spec/fixtures/cassettes/members.yml
|
285
|
-
- spec/
|
286
|
-
- spec/
|
287
|
-
- spec/
|
288
|
-
- spec/
|
289
|
-
- spec/
|
290
|
-
- spec/
|
291
|
-
- spec/
|
292
|
-
- spec/
|
293
|
-
- spec/
|
294
|
-
- spec/
|
295
|
-
- spec/
|
286
|
+
- spec/mailchimp_api_v3/account_spec.rb
|
287
|
+
- spec/mailchimp_api_v3/client_spec.rb
|
288
|
+
- spec/mailchimp_api_v3/exception_spec.rb
|
289
|
+
- spec/mailchimp_api_v3/interest_categories_spec.rb
|
290
|
+
- spec/mailchimp_api_v3/interest_category_spec.rb
|
291
|
+
- spec/mailchimp_api_v3/interest_spec.rb
|
292
|
+
- spec/mailchimp_api_v3/interests_spec.rb
|
293
|
+
- spec/mailchimp_api_v3/list_spec.rb
|
294
|
+
- spec/mailchimp_api_v3/lists_spec.rb
|
295
|
+
- spec/mailchimp_api_v3/member_spec.rb
|
296
|
+
- spec/mailchimp_api_v3/members_spec.rb
|
296
297
|
- spec/mailchimp_spec.rb
|
297
298
|
- spec/spec_helper.rb
|
298
299
|
- spec/support/api_key.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'mailchimp_api_v3'
|
4
|
-
|
5
|
-
describe MailchimpAPIV3::Account, vcr: { cassette_name: 'mailchimp' } do
|
6
|
-
it 'is the expected class' do
|
7
|
-
expect(MailchimpAPIV3.connect.account).to be_a MailchimpAPIV3::Account
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'has a name' do
|
11
|
-
expect(MailchimpAPIV3.connect.account.name).to eq 'InSite Arts'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'has an id' do
|
15
|
-
expect(MailchimpAPIV3.connect.account.id).to eq '1dbca289fd41b54838bcbb501'
|
16
|
-
end
|
17
|
-
end
|