mailchimp_api_v3 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/lib/mailchimp_api_v3.rb +16 -0
  4. data/lib/mailchimp_api_v3/account.rb +1 -1
  5. data/lib/mailchimp_api_v3/client.rb +3 -3
  6. data/lib/mailchimp_api_v3/client/remote.rb +3 -3
  7. data/lib/mailchimp_api_v3/collection.rb +1 -1
  8. data/lib/mailchimp_api_v3/collection/paging.rb +1 -1
  9. data/lib/mailchimp_api_v3/exception.rb +1 -1
  10. data/lib/mailchimp_api_v3/instance.rb +2 -2
  11. data/lib/mailchimp_api_v3/interest.rb +1 -1
  12. data/lib/mailchimp_api_v3/interest_categories.rb +1 -1
  13. data/lib/mailchimp_api_v3/interest_category.rb +1 -1
  14. data/lib/mailchimp_api_v3/interests.rb +1 -1
  15. data/lib/mailchimp_api_v3/list.rb +1 -1
  16. data/lib/mailchimp_api_v3/lists.rb +1 -1
  17. data/lib/mailchimp_api_v3/member.rb +1 -1
  18. data/lib/mailchimp_api_v3/members.rb +1 -1
  19. data/lib/mailchimp_api_v3/version.rb +2 -2
  20. data/mailchimp_api_v3.gemspec +1 -1
  21. data/spec/mailchimp_api_v3/account_spec.rb +17 -0
  22. data/spec/{mailchimp → mailchimp_api_v3}/client_spec.rb +9 -9
  23. data/spec/{mailchimp → mailchimp_api_v3}/exception_spec.rb +14 -14
  24. data/spec/{mailchimp → mailchimp_api_v3}/interest_categories_spec.rb +8 -8
  25. data/spec/{mailchimp → mailchimp_api_v3}/interest_category_spec.rb +4 -4
  26. data/spec/{mailchimp → mailchimp_api_v3}/interest_spec.rb +3 -3
  27. data/spec/{mailchimp → mailchimp_api_v3}/interests_spec.rb +7 -7
  28. data/spec/{mailchimp → mailchimp_api_v3}/list_spec.rb +7 -7
  29. data/spec/{mailchimp → mailchimp_api_v3}/lists_spec.rb +3 -3
  30. data/spec/{mailchimp → mailchimp_api_v3}/member_spec.rb +4 -4
  31. data/spec/{mailchimp → mailchimp_api_v3}/members_spec.rb +4 -4
  32. data/spec/mailchimp_spec.rb +4 -4
  33. metadata +24 -23
  34. data/spec/mailchimp/account_spec.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84ec2a80c75ddcdd36c7096af5a44bced1e7104f
4
- data.tar.gz: bac88f5b0e1e56d5a68f8e8efc35c08e43799198
3
+ metadata.gz: fb3dc62663ec203d2d9e0c0a90bead5dd237422c
4
+ data.tar.gz: 152265412ea8717fecf81db4477cd98e133e08c3
5
5
  SHA512:
6
- metadata.gz: f3154cb67c37dfe49e1b967174b159d6c5984737ef609a87876e4d070267d917b713b4622457f7808b7f9b7367d8cd1da3b1cc741317078731b89c6404ecbed9
7
- data.tar.gz: f8bb921863f744878b8b875f8e046beae6a9d9e2e51055b1ac54e8293440497544cb470c9747a1e3c6edfd299253deee726ff696c7282bbfbcdd9f3fc505fb53
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
- MailchimpAPIV3.connect(my_api_key) # Uses the API key in my_api_key
41
- MailchimpAPIV3.connect # Uses ENV['MAILCHIMP_API_KEY']
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
- MailchimpAPIV3.connect.lists
45
+ Mailchimp.connect.lists
46
46
  ```
47
47
 
48
48
  ```ruby
49
- mailchimp = MailchimpAPIV3.connect
49
+ mailchimp = Mailchimp.connect
50
50
  list = mailchimp.lists.find_by name: 'My first list'
51
51
  ```
52
52
 
53
53
  ```ruby
54
- mailchimp = MailchimpAPIV3.connect
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
@@ -1,4 +1,4 @@
1
- module MailchimpAPIV3
1
+ module Mailchimp
2
2
  class Account
3
3
  include Instance::InstanceMethods
4
4
 
@@ -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 MailchimpAPIV3
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 MailchimpAPIV3::Exception::APIKeyError
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
- MailchimpAPIV3::Exception::APIKeyError,
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 MailchimpAPIV3
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 MailchimpAPIV3::Exception::APIKeyError, YAML.load(e.http_body)
37
+ fail Mailchimp::Exception::APIKeyError, YAML.load(e.http_body)
38
38
  when 'RestClient::BadRequest'
39
- MailchimpAPIV3::Exception.parse_invalid_resource_exception YAML.load(e.http_body)
39
+ Mailchimp::Exception.parse_invalid_resource_exception YAML.load(e.http_body)
40
40
  else
41
41
  fail e
42
42
  end
@@ -1,6 +1,6 @@
1
1
  require 'mailchimp_api_v3/collection/paging'
2
2
 
3
- module MailchimpAPIV3
3
+ module Mailchimp
4
4
  module Collection
5
5
  include Paging
6
6
 
@@ -1,4 +1,4 @@
1
- module MailchimpAPIV3
1
+ module Mailchimp
2
2
  module Collection
3
3
  module Paging
4
4
  DEFAULT_PAGE_SIZE = 500
@@ -1,4 +1,4 @@
1
- module MailchimpAPIV3
1
+ module Mailchimp
2
2
  module Exception
3
3
  def self.parse_invalid_resource_exception(data)
4
4
  detail = data['detail']
@@ -1,4 +1,4 @@
1
- module MailchimpAPIV3
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 MailchimpAPIV3::Exception::UnknownAttribute, message
51
+ fail Mailchimp::Exception::UnknownAttribute, message
52
52
  end
53
53
  end
54
54
 
@@ -1,4 +1,4 @@
1
- module MailchimpAPIV3
1
+ module Mailchimp
2
2
  class List
3
3
  class InterestCategory
4
4
  class Interest
@@ -1,6 +1,6 @@
1
1
  require 'mailchimp_api_v3/interest_category'
2
2
 
3
- module MailchimpAPIV3
3
+ module Mailchimp
4
4
  class List
5
5
  class InterestCategories < Array
6
6
  include Collection
@@ -1,6 +1,6 @@
1
1
  require 'mailchimp_api_v3/interests'
2
2
 
3
- module MailchimpAPIV3
3
+ module Mailchimp
4
4
  class List
5
5
  class InterestCategory
6
6
  #- VALID_TYPES = %w(checkboxes dropdown radio hidden)
@@ -1,6 +1,6 @@
1
1
  require 'mailchimp_api_v3/interest'
2
2
 
3
- module MailchimpAPIV3
3
+ module Mailchimp
4
4
  class List
5
5
  class InterestCategory
6
6
  class Interests < Array
@@ -1,7 +1,7 @@
1
1
  require 'mailchimp_api_v3/members'
2
2
  require 'mailchimp_api_v3/interest_categories'
3
3
 
4
- module MailchimpAPIV3
4
+ module Mailchimp
5
5
  class List
6
6
  include Instance::InstanceMethods
7
7
  extend Instance::ClassMethods
@@ -1,6 +1,6 @@
1
1
  require 'mailchimp_api_v3/list'
2
2
 
3
- module MailchimpAPIV3
3
+ module Mailchimp
4
4
  class Lists < Array
5
5
  include Collection
6
6
 
@@ -1,4 +1,4 @@
1
- module MailchimpAPIV3
1
+ module Mailchimp
2
2
  class List
3
3
  class Member
4
4
  include Instance::InstanceMethods
@@ -1,6 +1,6 @@
1
1
  require 'mailchimp_api_v3/member'
2
2
 
3
- module MailchimpAPIV3
3
+ module Mailchimp
4
4
  class List
5
5
  class Members < Array
6
6
  include Collection
@@ -1,3 +1,3 @@
1
- module MailchimpAPIV3
2
- VERSION = '0.0.4'
1
+ module Mailchimp
2
+ VERSION = '0.0.5'
3
3
  end
@@ -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 = MailchimpAPIV3::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 MailchimpAPIV3::Client, vcr: { cassette_name: 'mailchimp' } do
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 { MailchimpAPIV3::Client.new(bad_key).account }.to raise_error MailchimpAPIV3::Exception::APIKeyError
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(MailchimpAPIV3::Client.new(bad_key).connected?).to be_falsey
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(MailchimpAPIV3::Client.new.connected?).to be_truthy
20
+ expect(Mailchimp::Client.new.connected?).to be_truthy
21
21
  end
22
22
 
23
23
  it 'is the expected class' do
24
- expect(MailchimpAPIV3::Client.new).to be_a MailchimpAPIV3::Client
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(MailchimpAPIV3::Client.new.account).to be_a MailchimpAPIV3::Account
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 = MailchimpAPIV3::Client.new.lists
32
+ lists = Mailchimp::Client.new.lists
33
33
  expect(lists).to be_an Array
34
- expect(lists.sample).to be_a MailchimpAPIV3::List
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) { MailchimpAPIV3::Client.new }
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 MailchimpAPIV3::Exception::APIKeyError, vcr: { cassette_name: 'mailchimp' } do
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 { MailchimpAPIV3.connect(bad_key).account }.to raise_error { |e|
10
- expect(e).to be_a MailchimpAPIV3::Exception::APIKeyError
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 { MailchimpAPIV3.connect.account }.not_to raise_error
19
+ expect { Mailchimp.connect.account }.not_to raise_error
20
20
  end
21
21
  end
22
22
 
23
- describe MailchimpAPIV3::Exception::UnknownAttribute, vcr: { cassette_name: 'mailchimp' } do
24
- let(:account) { MailchimpAPIV3.connect.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 MailchimpAPIV3::Exception::UnknownAttribute
31
+ expect { account.blarbleferry }.to raise_error Mailchimp::Exception::UnknownAttribute
32
32
  end
33
33
  end
34
34
 
35
- describe MailchimpAPIV3::Exception::BadRequest do
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 { MailchimpAPIV3::Exception.parse_invalid_resource_exception data }
39
- .to raise_error MailchimpAPIV3::Exception::Duplicate
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 { MailchimpAPIV3::Exception.parse_invalid_resource_exception data }
45
- .to raise_error MailchimpAPIV3::Exception::MissingField
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 { MailchimpAPIV3::Exception.parse_invalid_resource_exception data }
51
- .to raise_error MailchimpAPIV3::Exception::BadRequest
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 MailchimpAPIV3::List::InterestCategories, vcr: { cassette_name: 'mailchimp' } do
6
- let(:list) { MailchimpAPIV3.connect.lists.first }
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 MailchimpAPIV3::List::InterestCategories
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 MailchimpAPIV3::List::InterestCategory
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 MailchimpAPIV3::List::InterestCategory
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 MailchimpAPIV3::Exception::Duplicate
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 MailchimpAPIV3::List::InterestCategory
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 MailchimpAPIV3::List::InterestCategory
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 MailchimpAPIV3::List::InterestCategory, vcr: { cassette_name: 'mailchimp' } do
6
- let(:lists) { MailchimpAPIV3.connect.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 MailchimpAPIV3::List::InterestCategory
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 MailchimpAPIV3::List::InterestCategory::Interest
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 MailchimpAPIV3::List::InterestCategory::Interest, vcr: { cassette_name: 'mailchimp' } do
6
- let(:lists) { MailchimpAPIV3.connect.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 MailchimpAPIV3::List::InterestCategory::Interest
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 MailchimpAPIV3::List::InterestCategory::Interests, vcr: { cassette_name: 'mailchimp' } do
6
- let(:list) { MailchimpAPIV3.connect.lists.first }
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 MailchimpAPIV3::List::InterestCategory::Interests
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 MailchimpAPIV3::List::InterestCategory::Interest
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 MailchimpAPIV3::Exception::Duplicate
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 MailchimpAPIV3::List::InterestCategory::Interest
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 MailchimpAPIV3::List::InterestCategory::Interest
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 MailchimpAPIV3::List, vcr: { cassette_name: 'mailchimp' } do
6
- let(:lists) { MailchimpAPIV3.connect.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 MailchimpAPIV3::List
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 MailchimpAPIV3::List::Member
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 MailchimpAPIV3::List::InterestCategory
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 MailchimpAPIV3::List::Member
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 MailchimpAPIV3::List::Member
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 MailchimpAPIV3::Lists, vcr: { cassette_name: 'mailchimp' } do
6
- let(:lists) { MailchimpAPIV3.connect.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 MailchimpAPIV3::Lists
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 MailchimpAPIV3::List::Member, vcr: { cassette_name: 'mailchimp' } do
6
- let(:lists) { MailchimpAPIV3.connect.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 MailchimpAPIV3::List::Member
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 MailchimpAPIV3::List::Member
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 MailchimpAPIV3::List::Members, vcr: { cassette_name: 'members' } do
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) { MailchimpAPIV3.connect.lists.first }
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 MailchimpAPIV3::List::Members
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 MailchimpAPIV3::List::Member
32
+ expect(members.sample).to be_a Mailchimp::List::Member
33
33
  end
34
34
  end
@@ -2,15 +2,15 @@
2
2
  require 'spec_helper'
3
3
  require 'mailchimp_api_v3'
4
4
 
5
- describe MailchimpAPIV3 do
5
+ describe Mailchimp do
6
6
  it 'does not attempt to connect without an API key in the right format' do
7
- expect { MailchimpAPIV3.connect '' }.to raise_error { |e|
8
- expect(e).to be_a MailchimpAPIV3::Exception::APIKeyError
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 { MailchimpAPIV3.connect }.not_to raise_error
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
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/mailchimp/account_spec.rb
244
- - spec/mailchimp/client_spec.rb
245
- - spec/mailchimp/exception_spec.rb
246
- - spec/mailchimp/interest_categories_spec.rb
247
- - spec/mailchimp/interest_category_spec.rb
248
- - spec/mailchimp/interest_spec.rb
249
- - spec/mailchimp/interests_spec.rb
250
- - spec/mailchimp/list_spec.rb
251
- - spec/mailchimp/lists_spec.rb
252
- - spec/mailchimp/member_spec.rb
253
- - spec/mailchimp/members_spec.rb
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/mailchimp/account_spec.rb
286
- - spec/mailchimp/client_spec.rb
287
- - spec/mailchimp/exception_spec.rb
288
- - spec/mailchimp/interest_categories_spec.rb
289
- - spec/mailchimp/interest_category_spec.rb
290
- - spec/mailchimp/interest_spec.rb
291
- - spec/mailchimp/interests_spec.rb
292
- - spec/mailchimp/list_spec.rb
293
- - spec/mailchimp/lists_spec.rb
294
- - spec/mailchimp/member_spec.rb
295
- - spec/mailchimp/members_spec.rb
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