ad_leads 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ad_leads/client.rb +21 -20
- data/lib/ad_leads/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: 9e53759fafe8fe534b5cd7a4a5a84d33cc8f8245
|
4
|
+
data.tar.gz: 123123d1d136c73f8498478d42249e589f60b0dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 897589e8bcc66177af0d4044cdcc990f654cc8f75b8bc8a149d6e65cc6ad91e98fa6b81d2794285086571cf567f8a833174432764f61a7130616dc448f10fad2
|
7
|
+
data.tar.gz: 696d0731508ac10ad88fa45ba18a3779afcea7d808493911e56d4cc30f602941fdaa4d1253e0413f3ac711c490ee61dec0e8b2907af89cfa3c8c837e31177c65
|
data/lib/ad_leads/client.rb
CHANGED
@@ -58,6 +58,7 @@ module AdLeads
|
|
58
58
|
faraday.authorization :Bearer, token
|
59
59
|
faraday.adapter :httpclient
|
60
60
|
faraday.request :url_encoded
|
61
|
+
# faraday.response :logger
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -74,33 +75,33 @@ module AdLeads
|
|
74
75
|
request.body = params if method == :post
|
75
76
|
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
body: #{response.body}
|
85
|
-
ERROR
|
86
|
-
when 500
|
87
|
-
raise ApiError.new(<<-ERROR)
|
88
|
-
endpoint: #{endpoint},
|
89
|
-
method: #{method},
|
90
|
-
path: #{path}",
|
91
|
-
body: #{response.body}
|
92
|
-
ERROR
|
78
|
+
# Logger.new(STDOUT).info [
|
79
|
+
# '====================',
|
80
|
+
# endpoint: endpoint,
|
81
|
+
# method: method,
|
82
|
+
# path: path,
|
83
|
+
# body: response.body
|
84
|
+
# ].join("\n")
|
93
85
|
|
86
|
+
case response.status
|
87
|
+
when 400 then raise ArgError.new response.body
|
88
|
+
when 401 then raise AuthError.new "token: #{token}" + response.body.to_s
|
89
|
+
when 500 then raise ApiError.new response.body
|
94
90
|
else
|
95
91
|
response
|
96
92
|
end
|
97
|
-
|
98
93
|
# rescue Faraday::Error::TimeoutError, Timeout::Error => error
|
99
94
|
# rescue Faraday::Error::ClientError, JSON::ParserError => error
|
100
95
|
end
|
96
|
+
|
101
97
|
end
|
102
98
|
|
103
|
-
class
|
104
|
-
|
99
|
+
class Error < StandardError
|
100
|
+
def initialize(message)
|
101
|
+
super(message)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
class AuthError < Error; end
|
105
|
+
class ApiError < Error; end
|
106
|
+
class ArgError < Error; end
|
105
107
|
end
|
106
|
-
2
|
data/lib/ad_leads/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ad_leads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dinshaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|