hominid 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/.travis.yml +1 -0
- data/Gemfile +6 -9
- data/Guardfile +21 -0
- data/README.rdoc +55 -13
- data/Rakefile +7 -12
- data/VERSION +1 -1
- data/lib/hominid.rb +5 -59
- data/lib/hominid/api.rb +59 -0
- data/lib/hominid/export.rb +63 -0
- data/lib/hominid/sts.rb +19 -0
- data/spec/hominid/hominid_spec.rb +24 -0
- data/spec/spec_helper.rb +13 -0
- metadata +84 -103
- data/Gemfile.lock +0 -23
- data/hominid.gemspec +0 -69
- data/test/helper.rb +0 -18
- data/test/test_hominid.rb +0 -29
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm: 1.9.2
|
data/Gemfile
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
#gem "json"
|
4
2
|
|
5
|
-
# Add dependencies to develop your gem here.
|
6
|
-
# Include everything needed to run rake, tests, features, etc.
|
7
3
|
group :development do
|
8
|
-
gem
|
9
|
-
|
10
|
-
gem
|
11
|
-
|
12
|
-
gem
|
4
|
+
gem 'bundler', '~> 1.0.0'
|
5
|
+
gem 'fakeweb'
|
6
|
+
gem 'guard-rspec'
|
7
|
+
gem 'jeweler', '~> 1.6.4'
|
8
|
+
gem 'simplecov'
|
9
|
+
gem 'rspec'
|
13
10
|
end
|
data/Guardfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2 do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^spec/.+_spec\.rb$})
|
11
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
14
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
15
|
+
watch('spec/spec_helper.rb') { "spec" }
|
16
|
+
watch('config/routes.rb') { "spec/routing" }
|
17
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
18
|
+
# Capybara request specs
|
19
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
20
|
+
end
|
21
|
+
|
data/README.rdoc
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
= Hominid
|
2
2
|
|
3
|
-
Hominid is a Ruby gem that provides a wrapper for interacting with
|
3
|
+
Hominid is a Ruby gem that provides a wrapper for interacting with {Mailchimp's}[http://eepurl.com/ew8J] MC, STS and Export API's.
|
4
4
|
|
5
5
|
== Requirements
|
6
6
|
|
7
|
-
You will need a {Mailchimp}[http://eepurl.com/ew8J] account. Once you have your Mailchimp account set up, you will need to {generate an API key}[http://admin.mailchimp.com/account/api/] in order to get started using Hominid.
|
7
|
+
You will need a {Mailchimp}[http://eepurl.com/ew8J] account. Once you have your Mailchimp account set up, you will need to {generate an API key}[http://admin.mailchimp.com/account/api/] in order to get started using Hominid (or you can use OAuth2 as well).
|
8
8
|
|
9
9
|
== Installation
|
10
10
|
|
@@ -12,7 +12,9 @@ You will need a {Mailchimp}[http://eepurl.com/ew8J] account. Once you have your
|
|
12
12
|
|
13
13
|
== Usage
|
14
14
|
|
15
|
-
|
15
|
+
=== MCAPI
|
16
|
+
|
17
|
+
Please refer to the {Mailchimp API Documentation}[http://apidocs.mailchimp.com/api/1.3/] for information about what methods are available, the arguments that can be passed to each method, and the output that the API will return. Start by creating a Hominid object:
|
16
18
|
|
17
19
|
h = Hominid::API.new('your_api_key')
|
18
20
|
|
@@ -24,26 +26,32 @@ Finally, and we're not sure why you would want to, but you can use the older ver
|
|
24
26
|
|
25
27
|
h = Hominid::API.new('your_api_key', {:api_version => '1.2'})
|
26
28
|
|
27
|
-
You can then run any of the methods that you find in the {Mailchimp API Documentation}[http://
|
29
|
+
You can then run any of the methods that you find in the {Mailchimp API Documentation}[http://apidocs.mailchimp.com/api/1.3/] against it. Simply convert the names to the more Ruby-like underscored versions (e.g. listUpdateMember becomes list_update_member).
|
30
|
+
|
31
|
+
MailChimp's API documentation states that several API methods (e.g. listUpdateMember, list_subscribe) require 'array' parameters. Hominid requires many (all?) of these parameters to be passed as **hashes**, not arrays -- the examples below should all work as-is.
|
32
|
+
|
33
|
+
You do not need to pass your api_key to each method, as that is done automatically for you:
|
28
34
|
|
35
|
+
# list_id is a short hex string used internally by MailChimp to identify your lists (e.g. 'eceeae8b22')
|
36
|
+
# it's returned as the "id" member of the structure returned by the 'lists' call.
|
29
37
|
h.get_account_details
|
38
|
+
# Get all lists associated with this API key
|
30
39
|
h.lists
|
31
|
-
|
32
|
-
h.
|
33
|
-
h.
|
40
|
+
# Subscribe 'joe@public.com', with merge variables 'FNAME' and 'LNAME', to the list identified by list_id
|
41
|
+
h.list_subscribe(list_id, 'joe@public.com', {'FNAME' => 'Joe', 'LNAME' => 'Public'}, 'html', false, true, true, false)
|
42
|
+
h.list_batch_subscribe(list_id, [{:EMAIL => 'joe@public.com', :EMAIL_TYPE => 'html'}, {:EMAIL => 'jane@doe.com', :EMAIL_TYPE => 'html'}])
|
43
|
+
h.campaign_create('regular', {:list_id => list_id, ...}, {:html => 'Campaign HTML content', ...})
|
34
44
|
h.template_add('template_name', 'Template HTML Code')
|
35
|
-
h.list_interest_grouping_add(
|
45
|
+
h.list_interest_grouping_add(list_id, 'Grouping Title', 'hidden', ['First Group', 'Second Group', 'Third Group'])
|
36
46
|
h.list_static_segment_add('Sample Static Segment')
|
37
47
|
|
38
|
-
The {Mailchimp API}[http://
|
48
|
+
The {Mailchimp API}[http://apidocs.mailchimp.com/api/1.3/] supports pagination for some methods, so certain methods will have the following response:
|
39
49
|
|
40
50
|
h.lists['total'] => 4
|
41
51
|
h.lists['data'] => outputs an array of your mailing lists
|
42
52
|
h.lists['data'].first => {"id" => "XXXXXXX", "web_id" => 1234567, "name" => "My Mailing List", ...}
|
43
53
|
|
44
|
-
|
45
|
-
|
46
|
-
== Examples
|
54
|
+
==== Finder Methods
|
47
55
|
|
48
56
|
Hominid includes some finder methods for campaigns (see Hominid::Campaign) and lists (see Hominid::List) to help with finding each of these resources:
|
49
57
|
|
@@ -51,7 +59,41 @@ Hominid includes some finder methods for campaigns (see Hominid::Campaign) and l
|
|
51
59
|
h.find_list_id_by_name('my_mailing_list')
|
52
60
|
h.find_campaigns_by_list_name('my_mailing_list')
|
53
61
|
|
54
|
-
|
62
|
+
=== STS API
|
63
|
+
|
64
|
+
Please refer to the {Mailchimp STS API Documentation}[http://apidocs.mailchimp.com/sts/1.0/] for information about what methods are available, the arguments that can be passed to each method, and the output that the API will return. Start by creating a Hominid object:
|
65
|
+
|
66
|
+
s = Hominid::STS.new('your_api_key', {:secure => true})
|
67
|
+
|
68
|
+
You can then run any of the methods that you find in the {Mailchimp STS API Documentation}[http://apidocs.mailchimp.com/sts/1.0/] against it. Simply convert the names to the more Ruby-like underscored versions (e.g. listVerifiedEmailAddresses becomes list_verified_email_addresses).
|
69
|
+
|
70
|
+
s.list_verified_email_addresses
|
71
|
+
s.verify_email_address('joe@public.com')
|
72
|
+
s.send_email({:to_email => ['joe@public.com'], :text => 'Hello World!'}, false, true)
|
73
|
+
s.get_send_quota
|
74
|
+
|
75
|
+
Note that MailChimp will return an error if you attempt to make STS API calls on an account without Amazon SES integration.
|
76
|
+
|
77
|
+
=== Export API
|
78
|
+
|
79
|
+
Please refer to the {Mailchimp Export API Documentation}[http://apidocs.mailchimp.com/export/1.0/] for information about what methods are available, the arguments that can be passed to each method, and the output that the API will return. Start by creating a Hominid object:
|
80
|
+
|
81
|
+
e = Hominid::Export.new('your_api_key', {:secure => true})
|
82
|
+
|
83
|
+
You can then run the following methods:
|
84
|
+
|
85
|
+
e.list('list_id')
|
86
|
+
e.campaign_subscriber_activit('campaign_id')
|
87
|
+
|
88
|
+
== Submitting an Issue
|
89
|
+
|
90
|
+
We use the {GitHub issue tracker}[https://github.com/terra-firma/hominid/issues] to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate support for an existing issue by voting it up. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and operating system. Ideally, a bug report should include a pull request with failing specs.
|
91
|
+
|
92
|
+
== Travis Build Status
|
93
|
+
|
94
|
+
{<img src="http://travis-ci.org/terra-firma/hominid.png" />}[http://travis-ci.org/terra-firma/hominid]
|
95
|
+
|
96
|
+
== Contributing to Hominid
|
55
97
|
|
56
98
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
57
99
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
data/Rakefile
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'rubygems'
|
2
3
|
require 'bundler'
|
4
|
+
|
3
5
|
begin
|
4
6
|
Bundler.setup(:default, :development)
|
5
7
|
rescue Bundler::BundlerError => e
|
@@ -15,10 +17,11 @@ Jeweler::Tasks.new do |gem|
|
|
15
17
|
gem.name = "hominid"
|
16
18
|
gem.homepage = "http://github.com/terra-firma/hominid"
|
17
19
|
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{
|
19
|
-
gem.description = %Q{Hominid is a Ruby gem that provides a wrapper for interacting with the Mailchimp email marketing service API.}
|
20
|
+
gem.summary = %Q{Ruby gem for interacting with the Mailchimp API's.}
|
21
|
+
gem.description = %Q{Hominid is a Ruby gem that provides a wrapper for interacting with the Mailchimp email marketing service MC, STS and Export API's.}
|
20
22
|
gem.email = "brian@terra-firma-design.com"
|
21
23
|
gem.authors = ["Brian Getting"]
|
24
|
+
# dependencies defined in Gemfile
|
22
25
|
end
|
23
26
|
Jeweler::RubygemsDotOrgTasks.new
|
24
27
|
|
@@ -29,21 +32,13 @@ Rake::TestTask.new(:test) do |test|
|
|
29
32
|
test.verbose = true
|
30
33
|
end
|
31
34
|
|
32
|
-
require 'rcov/rcovtask'
|
33
|
-
Rcov::RcovTask.new do |test|
|
34
|
-
test.libs << 'test'
|
35
|
-
test.pattern = 'test/**/test_*.rb'
|
36
|
-
test.verbose = true
|
37
|
-
end
|
38
|
-
|
39
35
|
task :default => :test
|
40
36
|
|
41
|
-
require '
|
37
|
+
require 'rdoc/task'
|
42
38
|
Rake::RDocTask.new do |rdoc|
|
43
39
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
40
|
rdoc.rdoc_dir = 'rdoc'
|
46
41
|
rdoc.title = "hominid #{version}"
|
47
42
|
rdoc.rdoc_files.include('README*')
|
48
43
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
end
|
44
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.4
|
data/lib/hominid.rb
CHANGED
@@ -1,65 +1,11 @@
|
|
1
|
-
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
2
3
|
require 'openssl'
|
3
4
|
require 'xmlrpc/client'
|
4
5
|
|
5
6
|
require 'hominid/campaign'
|
6
7
|
require 'hominid/list'
|
7
8
|
require 'hominid/security'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# Blank Slate
|
12
|
-
instance_methods.each do |m|
|
13
|
-
undef_method m unless m.to_s =~ /^__|object_id|method_missing|respond_to?|to_s|inspect/
|
14
|
-
end
|
15
|
-
|
16
|
-
include Hominid::Campaign
|
17
|
-
include Hominid::List
|
18
|
-
include Hominid::Security
|
19
|
-
|
20
|
-
# MailChimp API Documentation: http://www.mailchimp.com/api/1.3/
|
21
|
-
MAILCHIMP_API_VERSION = "1.3"
|
22
|
-
|
23
|
-
# Initialize with an API key and config options
|
24
|
-
def initialize(api_key, config = {})
|
25
|
-
raise ArgumentError.new('Your Mailchimp API key appears to be malformed') unless api_key.include?('-')
|
26
|
-
dc = api_key.split('-').last
|
27
|
-
defaults = {
|
28
|
-
:api_version => MAILCHIMP_API_VERSION,
|
29
|
-
:secure => false,
|
30
|
-
:timeout => nil
|
31
|
-
}
|
32
|
-
@config = defaults.merge(config).freeze
|
33
|
-
protocol = @config[:secure] ? 'https' : 'http'
|
34
|
-
@api_key = api_key
|
35
|
-
@chimpApi = XMLRPC::Client.new2("#{protocol}://#{dc}.api.mailchimp.com/#{@config[:api_version]}/", nil, @config[:timeout])
|
36
|
-
end
|
37
|
-
|
38
|
-
def method_missing(api_method, *args) # :nodoc:
|
39
|
-
@chimpApi.call(api_method.to_s.camelize_api_method_name, @api_key, *args)
|
40
|
-
rescue XMLRPC::FaultException => error
|
41
|
-
super if error.faultCode == -32601
|
42
|
-
raise APIError.new(error)
|
43
|
-
end
|
44
|
-
|
45
|
-
def respond_to?(api_method)
|
46
|
-
@chimpApi.call(api_method, @api_key)
|
47
|
-
rescue XMLRPC::FaultException => error
|
48
|
-
error.faultCode == -32601 ? false : true
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
class APIError < StandardError
|
54
|
-
def initialize(error)
|
55
|
-
super("<#{error.faultCode}> #{error.message}")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
class String
|
62
|
-
def camelize_api_method_name
|
63
|
-
self.to_s[0].chr.downcase + self.gsub(/(?:^|_)(.)/) { $1.upcase }[1..self.size]
|
64
|
-
end
|
65
|
-
end
|
9
|
+
require 'hominid/api'
|
10
|
+
require 'hominid/export'
|
11
|
+
require 'hominid/sts'
|
data/lib/hominid/api.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Hominid
|
2
|
+
class API
|
3
|
+
# Blank Slate
|
4
|
+
instance_methods.each do |m|
|
5
|
+
undef_method m unless m.to_s =~ /^__|object_id|method_missing|respond_to?|to_s|inspect|kind_of?|should|should_not/
|
6
|
+
end
|
7
|
+
|
8
|
+
include Hominid::Campaign
|
9
|
+
include Hominid::List
|
10
|
+
include Hominid::Security
|
11
|
+
|
12
|
+
# MailChimp API Documentation: http://apidocs.mailchimp.com/api/1.3/
|
13
|
+
MAILCHIMP_API_VERSION = "1.3"
|
14
|
+
|
15
|
+
# Initialize with an API key and config options
|
16
|
+
def initialize(api_key, config = {})
|
17
|
+
raise ArgumentError.new('Your Mailchimp API key appears to be malformed.') unless api_key.include?('-')
|
18
|
+
dc = api_key.split('-').last
|
19
|
+
defaults = {
|
20
|
+
:api_version => MAILCHIMP_API_VERSION,
|
21
|
+
:domain => 'api.mailchimp.com',
|
22
|
+
:secure => false,
|
23
|
+
:timeout => nil
|
24
|
+
}
|
25
|
+
@config = defaults.merge(config).freeze
|
26
|
+
protocol = @config[:secure] ? 'https' : 'http'
|
27
|
+
@api_key = api_key
|
28
|
+
@chimpApi = XMLRPC::Client.new2("#{protocol}://#{dc}.#{@config[:domain]}/#{@config[:api_version]}/", nil, @config[:timeout])
|
29
|
+
end
|
30
|
+
|
31
|
+
def method_missing(api_method, *args) # :nodoc:
|
32
|
+
@chimpApi.call(camelize_api_method_name(api_method.to_s), @api_key, *args)
|
33
|
+
rescue XMLRPC::FaultException => error
|
34
|
+
super if error.faultCode == -32601
|
35
|
+
raise APIError.new(error)
|
36
|
+
end
|
37
|
+
|
38
|
+
def respond_to?(api_method) # :nodoc:
|
39
|
+
@chimpApi.call(api_method, @api_key)
|
40
|
+
rescue XMLRPC::FaultException => error
|
41
|
+
error.faultCode == -32601 ? false : true
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def camelize_api_method_name(str)
|
47
|
+
str.to_s[0].chr.downcase + str.gsub(/(?:^|_)(.)/) { $1.upcase }[1..str.size]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class APIError < StandardError
|
52
|
+
attr_accessor :fault_code
|
53
|
+
def initialize(error)
|
54
|
+
self.fault_code = error.faultCode
|
55
|
+
super("<#{error.faultCode}> #{error.message}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Hominid
|
2
|
+
class Export
|
3
|
+
|
4
|
+
# MailChimp Export API Documentation: http://apidocs.mailchimp.com/export/1.0/
|
5
|
+
MAILCHIMP_EXPORT_VERSION = "1.0"
|
6
|
+
|
7
|
+
# Initialize with an API key and config options
|
8
|
+
def initialize(api_key, config = {})
|
9
|
+
raise ArgumentError.new('Your Mailchimp API key appears to be malformed.') unless api_key.include?('-')
|
10
|
+
dc = api_key.split('-').last
|
11
|
+
defaults = {
|
12
|
+
:api_version => MAILCHIMP_EXPORT_VERSION,
|
13
|
+
:secure => false
|
14
|
+
}
|
15
|
+
@config = defaults.merge(config).freeze
|
16
|
+
protocol = @config[:secure] ? 'https' : 'http'
|
17
|
+
@api_key = api_key
|
18
|
+
@api_base = "#{protocol}://#{dc}.api.mailchimp.com/export/#{@config[:api_version]}"
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO: We'll have to see how this progresses with regard to Mailchimp
|
22
|
+
# adding methods to the Export API. It would be nice to have this
|
23
|
+
# model follow the "method_missing" style of the others, but it
|
24
|
+
# would require passing arguments in as a hash:
|
25
|
+
#
|
26
|
+
# hominid_export.list({:id => 123, :status => 'unsubscribed'})
|
27
|
+
#
|
28
|
+
# It's the only way to get the *args to map over to the params hash
|
29
|
+
# if we use the "method_missing" approach. For now, this way seems
|
30
|
+
# more intuitive to the end user.
|
31
|
+
|
32
|
+
def list(id, status = 'subscribed', segment = [], since = '1900-01-01 00:00:00')
|
33
|
+
post_data = {
|
34
|
+
:apikey => @api_key,
|
35
|
+
:id => id,
|
36
|
+
:status => status,
|
37
|
+
:since => since
|
38
|
+
}
|
39
|
+
call('list', post_data)
|
40
|
+
end
|
41
|
+
|
42
|
+
def campaign_subscriber_activity(id, include_empty = false)
|
43
|
+
post_data = {
|
44
|
+
:apikey => @api_key,
|
45
|
+
:id => id,
|
46
|
+
:include_empty => include_empty,
|
47
|
+
}
|
48
|
+
call('campaignSubscriberActivity', post_data)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def call(list_method, post_data)
|
54
|
+
uri = URI.parse("#{@api_base}/#{list_method}/")
|
55
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
56
|
+
http.use_ssl = true if @config[:secure]
|
57
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
58
|
+
request.set_form_data(post_data)
|
59
|
+
response = http.request(request)
|
60
|
+
response.body
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/hominid/sts.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hominid
|
2
|
+
class STS < API
|
3
|
+
|
4
|
+
# MailChimp STS API Documentation: http://apidocs.mailchimp.com/sts/1.0/
|
5
|
+
MAILCHIMP_STS_VERSION = "1.0"
|
6
|
+
|
7
|
+
# Initialize with an API key and config options
|
8
|
+
def initialize(api_key, config = {})
|
9
|
+
defaults = {
|
10
|
+
:api_version => MAILCHIMP_STS_VERSION,
|
11
|
+
:domain => 'sts.mailchimp.com',
|
12
|
+
:secure => false,
|
13
|
+
:timeout => nil
|
14
|
+
}
|
15
|
+
super(api_key, defaults.merge(config))
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Hominid
|
4
|
+
describe API do
|
5
|
+
it "requires an API key" do
|
6
|
+
expect {Hominid::API.new}.should raise_error(ArgumentError)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "requires a valid API key" do
|
10
|
+
expect {Hominid::API.new(@invalid_api_key)}.should raise_error(ArgumentError)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "also accepts config options" do
|
14
|
+
expect {Hominid::API.new(@valid_api_key, {:secure => true})}.should_not raise_error(ArgumentError)
|
15
|
+
end
|
16
|
+
# TODO: Need a way to mock XMLRPC requests.
|
17
|
+
end
|
18
|
+
|
19
|
+
describe STS do
|
20
|
+
it "returns an instance of API" do
|
21
|
+
Hominid::STS.new(@valid_api_key).should be_kind_of(Hominid::API)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'fakeweb'
|
3
|
+
require 'hominid'
|
4
|
+
|
5
|
+
FakeWeb.allow_net_connect = false
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.before(:each) do
|
9
|
+
FakeWeb.clean_registry
|
10
|
+
@valid_api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us1'
|
11
|
+
@invalid_api_key = 'not_a_valid_api_key'
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,153 +1,134 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hominid
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 3
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 3.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.4
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Brian Getting
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: bundler
|
22
|
-
requirement: &
|
16
|
+
requirement: &2153641620 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 0
|
30
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 1.0.0
|
32
22
|
type: :development
|
33
23
|
prerelease: false
|
34
|
-
version_requirements: *
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
37
|
-
requirement: &
|
24
|
+
version_requirements: *2153641620
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fakeweb
|
27
|
+
requirement: &2153641060 !ruby/object:Gem::Requirement
|
38
28
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
- 1
|
44
|
-
- 5
|
45
|
-
- 2
|
46
|
-
version: 1.5.2
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
47
33
|
type: :development
|
48
34
|
prerelease: false
|
49
|
-
version_requirements: *
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name:
|
52
|
-
requirement: &
|
35
|
+
version_requirements: *2153641060
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: guard-rspec
|
38
|
+
requirement: &2153640200 !ruby/object:Gem::Requirement
|
53
39
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
- 0
|
59
|
-
- 9
|
60
|
-
- 10
|
61
|
-
version: 0.9.10
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
62
44
|
type: :development
|
63
45
|
prerelease: false
|
64
|
-
version_requirements: *
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name:
|
67
|
-
requirement: &
|
46
|
+
version_requirements: *2153640200
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jeweler
|
49
|
+
requirement: &2153638460 !ruby/object:Gem::Requirement
|
68
50
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
- 0
|
74
|
-
- 9
|
75
|
-
- 9
|
76
|
-
version: 0.9.9
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.4
|
77
55
|
type: :development
|
78
56
|
prerelease: false
|
79
|
-
version_requirements: *
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
82
|
-
requirement: &
|
57
|
+
version_requirements: *2153638460
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: simplecov
|
60
|
+
requirement: &2153634900 !ruby/object:Gem::Requirement
|
83
61
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
- 2
|
89
|
-
- 11
|
90
|
-
- 3
|
91
|
-
version: 2.11.3
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
92
66
|
type: :development
|
93
67
|
prerelease: false
|
94
|
-
version_requirements: *
|
95
|
-
|
68
|
+
version_requirements: *2153634900
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &2153633520 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2153633520
|
80
|
+
description: Hominid is a Ruby gem that provides a wrapper for interacting with the
|
81
|
+
Mailchimp email marketing service MC, STS and Export API's.
|
96
82
|
email: brian@terra-firma-design.com
|
97
83
|
executables: []
|
98
|
-
|
99
84
|
extensions: []
|
100
|
-
|
101
|
-
extra_rdoc_files:
|
85
|
+
extra_rdoc_files:
|
102
86
|
- LICENSE.txt
|
103
87
|
- README.rdoc
|
104
|
-
files:
|
88
|
+
files:
|
89
|
+
- .rspec
|
90
|
+
- .travis.yml
|
105
91
|
- Gemfile
|
106
|
-
-
|
92
|
+
- Guardfile
|
107
93
|
- LICENSE.txt
|
108
94
|
- README.rdoc
|
109
95
|
- Rakefile
|
110
96
|
- VERSION
|
111
|
-
- hominid.gemspec
|
112
97
|
- lib/hominid.rb
|
98
|
+
- lib/hominid/api.rb
|
113
99
|
- lib/hominid/campaign.rb
|
100
|
+
- lib/hominid/export.rb
|
114
101
|
- lib/hominid/list.rb
|
115
102
|
- lib/hominid/security.rb
|
116
|
-
-
|
117
|
-
-
|
118
|
-
|
103
|
+
- lib/hominid/sts.rb
|
104
|
+
- spec/hominid/hominid_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
119
106
|
homepage: http://github.com/terra-firma/hominid
|
120
|
-
licenses:
|
107
|
+
licenses:
|
121
108
|
- MIT
|
122
109
|
post_install_message:
|
123
110
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
111
|
+
require_paths:
|
126
112
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
114
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
segments:
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
segments:
|
134
120
|
- 0
|
135
|
-
|
136
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
hash: 661678545776857612
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
123
|
none: false
|
138
|
-
requirements:
|
139
|
-
- -
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
- 0
|
143
|
-
version: "0"
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
144
128
|
requirements: []
|
145
|
-
|
146
129
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.
|
130
|
+
rubygems_version: 1.8.8
|
148
131
|
signing_key:
|
149
132
|
specification_version: 3
|
150
|
-
summary:
|
151
|
-
test_files:
|
152
|
-
- test/helper.rb
|
153
|
-
- test/test_hominid.rb
|
133
|
+
summary: Ruby gem for interacting with the Mailchimp API's.
|
134
|
+
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
git (1.2.5)
|
5
|
-
jeweler (1.5.2)
|
6
|
-
bundler (~> 1.0.0)
|
7
|
-
git (>= 1.2.5)
|
8
|
-
rake
|
9
|
-
mocha (0.9.10)
|
10
|
-
rake
|
11
|
-
rake (0.8.7)
|
12
|
-
rcov (0.9.9)
|
13
|
-
shoulda (2.11.3)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
ruby
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
bundler (~> 1.0.0)
|
20
|
-
jeweler (~> 1.5.2)
|
21
|
-
mocha (>= 0.9.10)
|
22
|
-
rcov (>= 0.9.9)
|
23
|
-
shoulda (>= 2.11.3)
|
data/hominid.gemspec
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{hominid}
|
8
|
-
s.version = "3.0.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Brian Getting"]
|
12
|
-
s.date = %q{2010-12-24}
|
13
|
-
s.description = %q{Hominid is a Ruby gem that provides a wrapper for interacting with the Mailchimp email marketing service API.}
|
14
|
-
s.email = %q{brian@terra-firma-design.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"LICENSE.txt",
|
23
|
-
"README.rdoc",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"hominid.gemspec",
|
27
|
-
"lib/hominid.rb",
|
28
|
-
"lib/hominid/campaign.rb",
|
29
|
-
"lib/hominid/list.rb",
|
30
|
-
"lib/hominid/security.rb",
|
31
|
-
"test/helper.rb",
|
32
|
-
"test/test_hominid.rb"
|
33
|
-
]
|
34
|
-
s.homepage = %q{http://github.com/terra-firma/hominid}
|
35
|
-
s.licenses = ["MIT"]
|
36
|
-
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.7}
|
38
|
-
s.summary = %q{Hominid is a Ruby wrapper for the Mailchimp API}
|
39
|
-
s.test_files = [
|
40
|
-
"test/helper.rb",
|
41
|
-
"test/test_hominid.rb"
|
42
|
-
]
|
43
|
-
|
44
|
-
if s.respond_to? :specification_version then
|
45
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
-
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
51
|
-
s.add_development_dependency(%q<mocha>, [">= 0.9.10"])
|
52
|
-
s.add_development_dependency(%q<rcov>, [">= 0.9.9"])
|
53
|
-
s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
|
54
|
-
else
|
55
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
57
|
-
s.add_dependency(%q<mocha>, [">= 0.9.10"])
|
58
|
-
s.add_dependency(%q<rcov>, [">= 0.9.9"])
|
59
|
-
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
60
|
-
end
|
61
|
-
else
|
62
|
-
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
64
|
-
s.add_dependency(%q<mocha>, [">= 0.9.10"])
|
65
|
-
s.add_dependency(%q<rcov>, [">= 0.9.9"])
|
66
|
-
s.add_dependency(%q<shoulda>, [">= 2.11.3"])
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'hominid'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
data/test/test_hominid.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestHominid < Test::Unit::TestCase
|
4
|
-
|
5
|
-
VALID_API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us1'
|
6
|
-
INVALID_API_KEY = 'not_a_valid_api_key'
|
7
|
-
|
8
|
-
should "not raise an error if the API key is valid" do
|
9
|
-
assert_nothing_raised do
|
10
|
-
Hominid::API.new(VALID_API_KEY)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
should "raise an error if the API key is not provided" do
|
15
|
-
assert_raise(ArgumentError) do
|
16
|
-
Hominid::API.new()
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
should "raise an error if the API key is malformed" do
|
21
|
-
assert_raise(ArgumentError) do
|
22
|
-
Hominid::API.new(INVALID_API_KEY)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# TODO: Tests that mock API calls so that it is not hitting the actual
|
27
|
-
# Mailchimp API during testing.
|
28
|
-
|
29
|
-
end
|