whiplash-app 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/whiplash/app.rb +1 -0
- data/lib/whiplash/app/connections.rb +37 -6
- data/lib/whiplash/app/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29188ceeacb00228aee15d9f56ab151aac8b491c43b05463d25e648114fbb8ac
|
4
|
+
data.tar.gz: 93b8d38a3809d3e30d570f4acfe1ad3007f3754273d2ae1cf7299f3f4ce0f113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a952642f993be0711907cbef3567362f7eb55026c43f22a2d0a1a83e40c24742d5f26db1e9ab0ca36ad7ca8479c9b04e3dc5b930cc8eebfa97b09a7d9e834ca
|
7
|
+
data.tar.gz: a2e597b3658c0cdfec8727e44f91a5b6050871ab62d876f59fddcfb8c9412aba62bd0ecac8a4d300ffc5a85002553e746234cde7b70bbdf29c656655fff43a87
|
data/lib/whiplash/app.rb
CHANGED
@@ -32,7 +32,12 @@ module Whiplash
|
|
32
32
|
|
33
33
|
def app_request!(options = {})
|
34
34
|
begin
|
35
|
-
app_request(options)
|
35
|
+
response = app_request(options)
|
36
|
+
return response.body if response.success?
|
37
|
+
message = response.body if response.body.is_a? String
|
38
|
+
message = response.body.dig('error') if response.body.respond_to?(:dig)
|
39
|
+
store_whiplash_error!(response.status)
|
40
|
+
error_response(response.status, message)
|
36
41
|
rescue Faraday::ConnectionFailed => e
|
37
42
|
case e.message
|
38
43
|
when 'end of file reached'
|
@@ -49,11 +54,6 @@ module Whiplash
|
|
49
54
|
raise ProviderError::InternalServerError, e.message
|
50
55
|
end
|
51
56
|
end
|
52
|
-
return response.body if response.success?
|
53
|
-
message = response.body if response.body.is_a? String
|
54
|
-
message = response.body.dig('error') if response.body.respond_to?(:dig)
|
55
|
-
store_whiplash_error!(response.status)
|
56
|
-
error_response(response.status, message)
|
57
57
|
end
|
58
58
|
|
59
59
|
def delete(endpoint, params = {}, headers = nil)
|
@@ -112,6 +112,37 @@ module Whiplash
|
|
112
112
|
headers: headers)
|
113
113
|
end
|
114
114
|
|
115
|
+
def get_body_or_empty(endpoint, params = {}, headers = nil)
|
116
|
+
response = get(endpoint, params, headers)
|
117
|
+
if !response.success?
|
118
|
+
case response.status
|
119
|
+
when 500
|
120
|
+
Appsignal.send_error(WhiplashApiError::InternalServerError.new(response.body), {raised: false})
|
121
|
+
else
|
122
|
+
end
|
123
|
+
|
124
|
+
case get_context(endpoint)
|
125
|
+
when 'collection'
|
126
|
+
Rails.logger.info "[WhiplashApi] Returned #{response.status}. Returning an empty array..."
|
127
|
+
return []
|
128
|
+
when 'member'
|
129
|
+
Rails.logger.info "[WhiplashApi] Returned #{response.status}. Returning nil..."
|
130
|
+
return nil
|
131
|
+
when 'aggregate'
|
132
|
+
Rails.logger.info "[WhiplashApi] Returned #{response.status}. Returning an empty hash..."
|
133
|
+
return {}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
response.body
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_context(endpoint)
|
140
|
+
parts = endpoint.split('/').compact
|
141
|
+
return 'member' if (parts.last =~ /\d+/).present?
|
142
|
+
return 'aggregate' if parts.include?('aggregate')
|
143
|
+
'collection'
|
144
|
+
end
|
145
|
+
|
115
146
|
def sanitize_headers(headers)
|
116
147
|
if headers
|
117
148
|
{}.tap do |hash|
|
data/lib/whiplash/app/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiplash-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Sullivan, Mark Dickson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|