gibbon 2.2.0 → 2.2.1
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/CHANGELOG.md +3 -0
- data/README.markdown +1 -1
- data/lib/gibbon/api_request.rb +10 -11
- data/lib/gibbon/mailchimp_error.rb +25 -1
- data/lib/gibbon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ade9615ee9a69d1ce2d1d560ce14ec92430dd2
|
4
|
+
data.tar.gz: a82c3dea034eead23703265b805607a0c311e14f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dd1f3f444a7e6e0852f70705676cff464e67c3455a3be06c16bbd6597e7c33678e392c47184821b8c97c77c3b4bbe834620dbf2430c56da3e7176d2e0fa7d25
|
7
|
+
data.tar.gz: 99e997b80b822cfa08d93fa4004ccd2395aa0a699ba9e37bfb0360b891194e5e861b6f32dfe1e0f5ebcb5e42f0a8d96eab0ee76a9ff1bcbbfd47670f4affe431
|
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -253,7 +253,7 @@ You can set an optional proxy url like this (or with an environment variable MAI
|
|
253
253
|
gibbon.proxy = 'http://your_proxy.com:80'
|
254
254
|
```
|
255
255
|
|
256
|
-
You can set a different Faraday adapter during initialization:
|
256
|
+
You can set a different [Faraday adapter](https://github.com/lostisland/faraday) during initialization:
|
257
257
|
|
258
258
|
```ruby
|
259
259
|
gibbon = Gibbon::Request.new(api_key: "your_api_key", faraday_adapter: :net_http)
|
data/lib/gibbon/api_request.rb
CHANGED
@@ -84,7 +84,7 @@ module Gibbon
|
|
84
84
|
def timeout
|
85
85
|
@request_builder.timeout
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def proxy
|
89
89
|
@request_builder.proxy
|
90
90
|
end
|
@@ -96,28 +96,27 @@ module Gibbon
|
|
96
96
|
# Helpers
|
97
97
|
|
98
98
|
def handle_error(error)
|
99
|
-
|
99
|
+
error_params = {}
|
100
100
|
|
101
101
|
begin
|
102
|
-
error_to_raise = MailChimpError.new(error.message)
|
103
|
-
|
104
102
|
if error.is_a?(Faraday::Error::ClientError) && error.response
|
105
103
|
parsed_response = MultiJson.load(error.response[:body])
|
106
104
|
|
107
105
|
if parsed_response
|
108
|
-
|
109
|
-
|
110
|
-
|
106
|
+
error_params[:body] = parsed_response
|
107
|
+
error_params[:title] = parsed_response["title"] if parsed_response["title"]
|
108
|
+
error_params[:detail] = parsed_response["detail"] if parsed_response["detail"]
|
111
109
|
end
|
112
110
|
|
113
|
-
|
114
|
-
|
111
|
+
error_params[:status_code] = error.response[:status]
|
112
|
+
error_params[:raw_body] = error.response[:body]
|
115
113
|
end
|
116
114
|
rescue MultiJson::ParseError
|
117
|
-
|
118
|
-
error_to_raise.status_code = error.response[:status]
|
115
|
+
error_params[:status_code] = error.response[:status]
|
119
116
|
end
|
120
117
|
|
118
|
+
error_to_raise = MailChimpError.new(error.message, error_params)
|
119
|
+
|
121
120
|
raise error_to_raise
|
122
121
|
end
|
123
122
|
|
@@ -1,5 +1,29 @@
|
|
1
1
|
module Gibbon
|
2
2
|
class MailChimpError < StandardError
|
3
|
-
|
3
|
+
attr_reader :title, :detail, :body, :raw_body, :status_code
|
4
|
+
|
5
|
+
def initialize(message = "", params = {})
|
6
|
+
@title = params[:title]
|
7
|
+
@detail = params[:detail]
|
8
|
+
@body = params[:body]
|
9
|
+
@raw_body = params[:raw_body]
|
10
|
+
@status_code = params[:status_code]
|
11
|
+
|
12
|
+
super(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
super + " " + instance_variables_to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def instance_variables_to_s
|
22
|
+
[:title, :detail, :body, :raw_body, :status_code].map do |attr|
|
23
|
+
attr_value = send(attr)
|
24
|
+
|
25
|
+
"@#{attr}=#{attr_value.inspect}"
|
26
|
+
end.join(", ")
|
27
|
+
end
|
4
28
|
end
|
5
29
|
end
|
data/lib/gibbon/version.rb
CHANGED
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: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amro Mousa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|