gibbon 1.1.1 → 1.1.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/README.markdown +13 -9
- data/gibbon.gemspec +1 -1
- data/lib/gibbon.rb +1 -0
- data/lib/gibbon/api_category.rb +11 -0
- data/lib/gibbon/export.rb +11 -0
- data/lib/gibbon/gibbon_error.rb +3 -0
- data/spec/gibbon/gibbon_spec.rb +4 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5863ce163571867687599035a3efb7ae64f0be27
|
4
|
+
data.tar.gz: bc2afd9c27b43999b3fae7e20332af73945305f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cd38d270b357e015498fb881e2556efb4ea89e1926ef1c81dbb6072eb825d0632b51cd3ce6877465e9daa330f412bcb5f67246185c28e6b05141a898abedb8a
|
7
|
+
data.tar.gz: 3c3f56bdbb3654b366ed4ea557f07a7ed986611638a4e679cd312778f461938d3c65478b7fdadcd8e41cc92dd0b020eaed28cc1d1d34c36f36098b1c611843c5
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@ Gibbon now targets MailChimp API 2.0, which is substantially different from API
|
|
11
11
|
* Supports MailChimp API 2.0 and Export API 1.0
|
12
12
|
* Errors are raised by default since 0.4.x
|
13
13
|
* Timeouts can be specified per request during initialization
|
14
|
-
* Ruby 1.9.
|
14
|
+
* Ruby 1.9.3+ for now. A future version may be Ruby 2.0 only to take advantage of lazy iteration when using the Export API.
|
15
15
|
|
16
16
|
##Installation
|
17
17
|
|
@@ -34,13 +34,13 @@ You can set `api_key`, `timeout` and `throws_exceptions` globally:
|
|
34
34
|
Gibbon::API.api_key = "your_api_key"
|
35
35
|
Gibbon::API.timeout = 15
|
36
36
|
Gibbon::API.throws_exceptions = false
|
37
|
-
|
37
|
+
|
38
38
|
similarly
|
39
39
|
|
40
40
|
Gibbon::Export.api_key = "your_api_key"
|
41
41
|
Gibbon::Export.timeout = 15
|
42
42
|
Gibbon::Export.throws_exceptions = false
|
43
|
-
|
43
|
+
|
44
44
|
For example, you could set the values above in an `initializer` file in your `Rails` app (e.g. your\_app/config/initializers/gibbon.rb).
|
45
45
|
|
46
46
|
Assuming you've set an `api_key` on Gibbon, you can conveniently make API calls on the class itself:
|
@@ -97,6 +97,10 @@ Subscribe a member to a list:
|
|
97
97
|
|
98
98
|
> Note: This will send a welcome email to the new subscriber
|
99
99
|
|
100
|
+
Here's an example showing pagination. The following code fetches the first page of 100 members subscribed to your list:
|
101
|
+
|
102
|
+
gb.lists.members({:id => list_id, :opts => {:start => 0, :limit => 100}})
|
103
|
+
|
100
104
|
or
|
101
105
|
|
102
106
|
Batch subscribe members to a list:
|
@@ -108,15 +112,15 @@ Batch subscribe members to a list:
|
|
108
112
|
If you want to update the existing members you need to send the boolean update_existing in true
|
109
113
|
|
110
114
|
gb.lists.batch_subscribe(:id => list_id, :batch => [{:email => {:email => "email1"}, :merge_vars => {:FNAME => "FirstName1", :LNAME => "LastName1"}}], :update_existing => true)
|
111
|
-
|
115
|
+
|
112
116
|
> Note: The `email` hash can also accept either a unique email id or a list email id. Please see the [lists/batch-subscribe](http://apidocs.mailchimp.com/api/2.0/lists/batch-subscribe.php) documentation for more information.
|
113
117
|
|
114
118
|
You can also unsubscribe a member from a list:
|
115
119
|
|
116
120
|
gb.lists.unsubscribe(:id => list_id, :email => {:email => "user_email"}, :delete_member => true, :send_notify => true)
|
117
|
-
|
118
|
-
> Note: :delete_member defaults to false, meaning the member stays on your mailchimp list as "unsubscribed". See [Api Docs](http://apidocs.mailchimp.com/api/2.0/lists/unsubscribe.php) for details of options.
|
119
|
-
|
121
|
+
|
122
|
+
> Note: :delete_member defaults to false, meaning the member stays on your mailchimp list as "unsubscribed". See [Api Docs](http://apidocs.mailchimp.com/api/2.0/lists/unsubscribe.php) for details of options.
|
123
|
+
|
120
124
|
Fetch recipients who opened particular campaign:
|
121
125
|
|
122
126
|
email_stats = gb.reports.opened({:cid => campaign_id})
|
@@ -164,8 +168,8 @@ at the bottom of each page. Here's how you might do that:
|
|
164
168
|
|
165
169
|
Some API endpoints, like `[lists/batch-subscribe](http://apidocs.mailchimp.com/api/2.0/lists/batch-subscribe.php)`
|
166
170
|
return errors to let you know that some of your actions failed, but some suceeded. Gibbon will not
|
167
|
-
raise Gibbon::MailChimpError for these endpoints because the key for the success count varies from endpoint to endpoint.
|
168
|
-
This makes it difficult to determine whether all of your actions failed in a generic way. **Because of this, you're responsible
|
171
|
+
raise Gibbon::MailChimpError for these endpoints because the key for the success count varies from endpoint to endpoint.
|
172
|
+
This makes it difficult to determine whether all of your actions failed in a generic way. **Because of this, you're responsible
|
169
173
|
for checking the response body for the `errors` array in these cases.**
|
170
174
|
|
171
175
|
> Note: In an effort to make Gibbon easier to use, errors are raised automatically as of version 0.4.0.
|
data/gibbon.gemspec
CHANGED
data/lib/gibbon.rb
CHANGED
data/lib/gibbon/api_category.rb
CHANGED
@@ -20,6 +20,8 @@ module Gibbon
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def call(method, params = {})
|
23
|
+
ensure_api_key params
|
24
|
+
|
23
25
|
api_url = base_api_url + method
|
24
26
|
params = @default_params.merge(params).merge({:apikey => @api_key})
|
25
27
|
headers = params.delete(:headers) || {}
|
@@ -88,5 +90,14 @@ module Gibbon
|
|
88
90
|
|
89
91
|
data_center
|
90
92
|
end
|
93
|
+
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def ensure_api_key(params)
|
98
|
+
unless @api_key || @default_params[:apikey] || params[:apikey]
|
99
|
+
raise Gibbon::GibbonError, "You must set an api_key prior to making a call"
|
100
|
+
end
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
data/lib/gibbon/export.rb
CHANGED
@@ -15,6 +15,8 @@ module Gibbon
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(method, params = {})
|
18
|
+
ensure_api_key params
|
19
|
+
|
18
20
|
api_url = export_api_url + method + "/"
|
19
21
|
params = @default_params.merge(params).merge({:apikey => @api_key})
|
20
22
|
response = self.class.post(api_url, :body => MultiJson.dump(params), :timeout => @timeout)
|
@@ -57,6 +59,15 @@ module Gibbon
|
|
57
59
|
%w{list ecommOrders ecomm_orders campaignSubscriberActivity campaign_subscriber_activity}.include?(method.to_s) || super
|
58
60
|
end
|
59
61
|
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def ensure_api_key(params)
|
66
|
+
unless @api_key || @default_params[:apikey] || params[:apikey]
|
67
|
+
raise Gibbon::GibbonError, "You must set an api_key prior to making a call"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
60
71
|
class << self
|
61
72
|
attr_accessor :api_key, :timeout, :throws_exceptions
|
62
73
|
|
data/spec/gibbon/gibbon_spec.rb
CHANGED
@@ -57,9 +57,8 @@ describe Gibbon do
|
|
57
57
|
@url = "https://api.mailchimp.com/2.0/say/hello"
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
61
|
-
|
62
|
-
@gibbon.say.hello
|
60
|
+
it "doesn't allow empty api key" do
|
61
|
+
expect {@gibbon.say.hello}.to raise_error(Gibbon::GibbonError)
|
63
62
|
end
|
64
63
|
|
65
64
|
it "handle malformed api key" do
|
@@ -70,7 +69,8 @@ describe Gibbon do
|
|
70
69
|
end
|
71
70
|
|
72
71
|
it "handle timeout" do
|
73
|
-
expect_post(@url, {"apikey" =>
|
72
|
+
expect_post(@url, {"apikey" => 'test'}, 120)
|
73
|
+
@gibbon.api_key = 'test'
|
74
74
|
@gibbon.timeout=120
|
75
75
|
@gibbon.say.hello
|
76
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gibbon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amro Mousa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/gibbon/api.rb
|
86
86
|
- lib/gibbon/api_category.rb
|
87
87
|
- lib/gibbon/export.rb
|
88
|
+
- lib/gibbon/gibbon_error.rb
|
88
89
|
- lib/gibbon/mailchimp_error.rb
|
89
90
|
- spec/gibbon/gibbon_spec.rb
|
90
91
|
- spec/spec_helper.rb
|
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
112
|
version: '0'
|
112
113
|
requirements: []
|
113
114
|
rubyforge_project: gibbon
|
114
|
-
rubygems_version: 2.2.
|
115
|
+
rubygems_version: 2.2.1
|
115
116
|
signing_key:
|
116
117
|
specification_version: 4
|
117
118
|
summary: A wrapper for MailChimp API 2.0 and Export API 1.0
|