my_target_api 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/my_target_api/request.rb +14 -8
- data/lib/my_target_api/request_error.rb +3 -1
- data/lib/my_target_api/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: f9f3188adcf480c8c732b25cba9d6ff3ed917e82
|
4
|
+
data.tar.gz: b952a49b44aad9f0c8cf0c581c449e06dbc02262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0441c39f4b4dd63fc8b4ecf9542024c8575041d2fbee0654323ba5a47e34e298cb346158decb33f76499293a722bf5526cf1fb639d998ba0a9976b47b0868fe
|
7
|
+
data.tar.gz: 110e86dc4f466f507d0ec690d705f32183357ce80eba4d8f57e6f9ed560eacef549a4477bc93aad287c007302ef3a5f458c866367cd9513fbbe6de388ee5475d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ class MyTargetApi
|
|
14
14
|
def get(url, params = {})
|
15
15
|
log_hash(method: 'Request#get', url: url, params: params)
|
16
16
|
|
17
|
-
response = with_exception_handling do
|
17
|
+
response = with_exception_handling(params) do
|
18
18
|
RestClient.get(url, headers.merge(query(params)))
|
19
19
|
end
|
20
20
|
|
@@ -24,7 +24,7 @@ class MyTargetApi
|
|
24
24
|
def post(url, params = {})
|
25
25
|
log_hash(method: 'Request#post', url: url, params: params)
|
26
26
|
|
27
|
-
response = with_exception_handling do
|
27
|
+
response = with_exception_handling(params) do
|
28
28
|
RestClient.post(url, body_parameters(params), headers)
|
29
29
|
end
|
30
30
|
|
@@ -34,7 +34,7 @@ class MyTargetApi
|
|
34
34
|
def delete(url, params = {})
|
35
35
|
log_hash(method: 'Request#delete', url: url, params: params)
|
36
36
|
|
37
|
-
response = with_exception_handling do
|
37
|
+
response = with_exception_handling(params) do
|
38
38
|
RestClient.delete(url, headers.merge(query(params)))
|
39
39
|
end
|
40
40
|
|
@@ -44,7 +44,7 @@ class MyTargetApi
|
|
44
44
|
def upload(url, content, params = {})
|
45
45
|
log_hash(method: 'Request#upload', url: url, params: params, content: 'no logging')
|
46
46
|
|
47
|
-
response = with_exception_handling do
|
47
|
+
response = with_exception_handling(params) do
|
48
48
|
RestClient.post(
|
49
49
|
url, content, headers.merge(query(params)).merge(content_type: 'application/octet-stream')
|
50
50
|
)
|
@@ -90,16 +90,16 @@ class MyTargetApi
|
|
90
90
|
response.body
|
91
91
|
end
|
92
92
|
|
93
|
-
def with_exception_handling
|
93
|
+
def with_exception_handling(params)
|
94
94
|
response = yield
|
95
95
|
log(response)
|
96
96
|
response
|
97
97
|
rescue RestClient::ExceptionWithResponse => e
|
98
98
|
log_rest_client_exception(e)
|
99
|
-
|
99
|
+
raise_with_params(e, params)
|
100
100
|
rescue RestClient::Exception => e
|
101
101
|
log("#{e.class.name} #{e.message}")
|
102
|
-
|
102
|
+
raise_with_params(e, params)
|
103
103
|
rescue SocketError => e
|
104
104
|
raise MyTargetApi::ConnectionError, e
|
105
105
|
end
|
@@ -113,11 +113,17 @@ class MyTargetApi
|
|
113
113
|
HTTP Code: #{exception.http_code}
|
114
114
|
HTTP Body: #{exception.http_body}
|
115
115
|
HTTP headers: #{exception.http_headers}
|
116
|
-
|
116
|
+
LOG
|
117
117
|
|
118
118
|
log(log_message)
|
119
119
|
end
|
120
120
|
|
121
|
+
def raise_with_params(e, params)
|
122
|
+
result = MyTargetApi::RequestError.new(e, params)
|
123
|
+
result.set_backtrace(caller)
|
124
|
+
raise result
|
125
|
+
end
|
126
|
+
|
121
127
|
def log_hash(hash)
|
122
128
|
log(hash.map do |key, value|
|
123
129
|
"#{key}: #{value.is_a?(String) ? value : value.inspect}"
|
@@ -5,9 +5,11 @@ class MyTargetApi
|
|
5
5
|
class RequestError < StandardError
|
6
6
|
|
7
7
|
attr_reader :original_exception
|
8
|
+
attr_reader :params
|
8
9
|
|
9
|
-
def initialize(exception)
|
10
|
+
def initialize(exception, params)
|
10
11
|
@original_exception = exception
|
12
|
+
@params = params
|
11
13
|
super build_message exception
|
12
14
|
end
|
13
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_target_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OneRetarget.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|