gibbon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gibbon might be problematic. Click here for more details.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/lib/gibbon.rb +46 -0
- data/test/helper.rb +18 -0
- data/test/test_gibbon.rb +7 -0
- metadata +161 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.1"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.5.1)
|
6
|
+
bundler (~> 1.0.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.8.7)
|
10
|
+
rcov (0.9.9)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.5.1)
|
19
|
+
rcov
|
20
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Amro Mousa
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
= gibbon
|
2
|
+
|
3
|
+
Gibbon is a simple API wrapper for interacting with {MailChimp API}[http://www.mailchimp.com/api] 1.3.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install gibbon
|
8
|
+
|
9
|
+
== Requirements
|
10
|
+
|
11
|
+
A MailChimp account and API key. You can see your API keys {here}[http://admin.mailchimp.com/account/api].
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
|
15
|
+
Create an instance of the API wrapper:
|
16
|
+
|
17
|
+
gb = Gibbon::API.new(api_key)
|
18
|
+
|
19
|
+
Fetching data is as simple as calling API methods directly on the wrapper object.
|
20
|
+
Check the API {documentation}[http://www.mailchimp.com/api/1.3] for details.
|
21
|
+
|
22
|
+
=== Fetching Campaigns
|
23
|
+
|
24
|
+
For example, to fetch your first 100 campaigns (page 0):
|
25
|
+
|
26
|
+
campaigns = gb.campaigns({:start => 0, :limit => 100})
|
27
|
+
|
28
|
+
=== Fetching Lists
|
29
|
+
|
30
|
+
Similarly, to fetch your first 100 lists:
|
31
|
+
|
32
|
+
lists = gb.lists({:start => 0, :limit=> 100})
|
33
|
+
|
34
|
+
=== More Advanced Examples
|
35
|
+
|
36
|
+
Getting batch member information for subscribers looks like this:
|
37
|
+
|
38
|
+
info = gb.list_member_info({:id => list_id, :email_address => email_array})
|
39
|
+
|
40
|
+
or
|
41
|
+
|
42
|
+
info = gb.listMemberInfo({:id => list_id, :email_address => email_array})
|
43
|
+
|
44
|
+
Fetch open and click detail for recipients of a particular campaign:
|
45
|
+
|
46
|
+
email_stats = gb.campaign_email_stats_aim({:cid => campaign_id, :email_address => email_array})
|
47
|
+
|
48
|
+
or
|
49
|
+
|
50
|
+
email_stats = gb.campaignEmailStatsAIM({:cid => campaign_id, :email_address => email_array})
|
51
|
+
|
52
|
+
== Thanks
|
53
|
+
|
54
|
+
* Rails for camelize gsub
|
55
|
+
|
56
|
+
== Copyrights
|
57
|
+
|
58
|
+
* Copyright (c) 2010 Amro Mousa. See LICENSE.txt for details.
|
59
|
+
* MailChimp (c) 2001-2010 The Rocket Science Group
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
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 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "gibbon"
|
16
|
+
gem.homepage = "http://github.com/amro/gibbon"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Gibbon is a simple API wrapper for interacting with MailChimp API 1.3}
|
19
|
+
gem.description = %Q{Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3.}
|
20
|
+
gem.email = "amromousa@gmail.com"
|
21
|
+
gem.authors = ["Amro Mousa"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
gem.add_runtime_dependency 'httparty', '> 0.6.0'
|
25
|
+
gem.add_runtime_dependency 'json', '> 1.4.0'
|
26
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
Rake::TestTask.new(:test) do |test|
|
32
|
+
test.libs << 'lib' << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'rcov/rcovtask'
|
38
|
+
Rcov::RcovTask.new do |test|
|
39
|
+
test.libs << 'test'
|
40
|
+
test.pattern = 'test/**/test_*.rb'
|
41
|
+
test.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "gibbon #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/gibbon.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Gibbon
|
5
|
+
class API
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
attr_accessor :apikey
|
9
|
+
|
10
|
+
def initialize(apikey = nil, extra_params = {})
|
11
|
+
@apikey = apikey
|
12
|
+
@default_params = {:apikey => apikey}.merge(extra_params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def apikey=(value)
|
16
|
+
@apikey = value
|
17
|
+
@default_params = @default_params.merge({:apikey => @apikey})
|
18
|
+
end
|
19
|
+
|
20
|
+
def base_api_url
|
21
|
+
dc = @apikey.blank? ? '' : "#{@apikey.split("-").last}."
|
22
|
+
"https://#{dc}api.mailchimp.com/1.3/?method="
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(method, params = {})
|
26
|
+
url = base_api_url + method
|
27
|
+
params = params.merge(@default_params)
|
28
|
+
response = API.post(url, :query => params)
|
29
|
+
|
30
|
+
begin
|
31
|
+
response = JSON.parse(response.body)
|
32
|
+
rescue
|
33
|
+
response = response.body
|
34
|
+
end
|
35
|
+
response
|
36
|
+
end
|
37
|
+
|
38
|
+
def method_missing(method, *args)
|
39
|
+
method = method.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } #Thanks for the gsub, Rails
|
40
|
+
method = method[0].chr.downcase + method[1..-1].gsub(/aim$/i, 'AIM')
|
41
|
+
args = {} unless args.length > 0
|
42
|
+
args = args[0] if (args.class.to_s == "Array")
|
43
|
+
call(method, args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
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 'gibbon'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_gibbon.rb
ADDED
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gibbon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Amro Mousa
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-15 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: shoulda
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 1
|
42
|
+
- 0
|
43
|
+
- 0
|
44
|
+
version: 1.0.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 5
|
58
|
+
- 1
|
59
|
+
version: 1.5.1
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rcov
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
type: :development
|
74
|
+
prerelease: false
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: httparty
|
78
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
- 6
|
86
|
+
- 0
|
87
|
+
version: 0.6.0
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: json
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
segments:
|
99
|
+
- 1
|
100
|
+
- 4
|
101
|
+
- 0
|
102
|
+
version: 1.4.0
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *id006
|
106
|
+
description: Gibbon is a simple API wrapper for interacting with MailChimp API version 1.3.
|
107
|
+
email: amromousa@gmail.com
|
108
|
+
executables: []
|
109
|
+
|
110
|
+
extensions: []
|
111
|
+
|
112
|
+
extra_rdoc_files:
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.rdoc
|
115
|
+
files:
|
116
|
+
- .document
|
117
|
+
- Gemfile
|
118
|
+
- Gemfile.lock
|
119
|
+
- LICENSE.txt
|
120
|
+
- README.rdoc
|
121
|
+
- Rakefile
|
122
|
+
- VERSION
|
123
|
+
- lib/gibbon.rb
|
124
|
+
- test/helper.rb
|
125
|
+
- test/test_gibbon.rb
|
126
|
+
has_rdoc: true
|
127
|
+
homepage: http://github.com/amro/gibbon
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 1364282506184447290
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
version: "0"
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
version: "0"
|
152
|
+
requirements: []
|
153
|
+
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.3.7
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: Gibbon is a simple API wrapper for interacting with MailChimp API 1.3
|
159
|
+
test_files:
|
160
|
+
- test/helper.rb
|
161
|
+
- test/test_gibbon.rb
|