finapps 2.0.13 → 2.0.14
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/finapps/middleware/response/raise_error.rb +13 -13
- data/lib/finapps/rest/connection.rb +1 -1
- data/lib/finapps/version.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- 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: 049e5b0cf3c762597409c561552dfb6eca8d6bdd
|
4
|
+
data.tar.gz: f9606a4cb061d6bff60a8906433dd83ea58ef0b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f906883bfa5c26c1f2bb08d74857a42b03f1de1e75463828d83c1ca91b6c4a2fe590dd3c198bff991313571e97cb1bd9d5b4702ffe90911550786b3688cd0f4
|
7
|
+
data.tar.gz: 458ea6bd78d194e2205653389b7d427e2963f3ee3b3332e28a41211a92ec453deaacc2439e81e4a00e13c6528c9befec256d7adfa34f55c74a43f7f1557440e2
|
@@ -4,21 +4,17 @@ module FinApps
|
|
4
4
|
class RaiseError < Faraday::Response::Middleware # :nodoc:
|
5
5
|
using ObjectExtensions
|
6
6
|
using StringExtensions
|
7
|
-
include FinApps::Utils::Loggeable
|
8
7
|
|
9
|
-
|
8
|
+
SUCCESS_STATUSES = 200..299
|
9
|
+
CONNECTION_FAILED_STATUS = 407
|
10
10
|
|
11
11
|
def on_complete(env)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
raise
|
16
|
-
when CLIENT_ERROR_STATUSES
|
17
|
-
raise Faraday::Error::ClientError, response_values(env)
|
12
|
+
if SUCCESS_STATUSES.include? env[:status]
|
13
|
+
# do nothing
|
14
|
+
elsif env[:status] == CONNECTION_FAILED_STATUS
|
15
|
+
raise(Faraday::Error::ConnectionFailed, '407 "Proxy Authentication Required"')
|
18
16
|
else
|
19
|
-
|
20
|
-
# all good!
|
21
|
-
logger.debug "##{__method__} => Status code: [#{env[:status]}]"
|
17
|
+
raise(Faraday::Error::ClientError, response_values(env))
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
@@ -36,13 +32,17 @@ module FinApps
|
|
36
32
|
def error_messages(body)
|
37
33
|
return nil if body.blank?
|
38
34
|
body = parse_string(body) if body.is_a?(String)
|
39
|
-
|
35
|
+
has_message_key?(body) ? body['messages'] : nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def has_message_key?(body)
|
39
|
+
body.respond_to?(:key?) && body.key?('messages')
|
40
40
|
end
|
41
41
|
|
42
42
|
def parse_string(body)
|
43
43
|
::JSON.parse(body)
|
44
44
|
rescue ::JSON::ParserError
|
45
|
-
logger.error "##{__method__} => Unable to parse JSON response."
|
45
|
+
# logger.error "##{__method__} => Unable to parse JSON response."
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -23,7 +23,7 @@ module FinApps
|
|
23
23
|
conn.use FinApps::Middleware::RaiseError
|
24
24
|
conn.response :rashify
|
25
25
|
conn.response :json, content_type: /\bjson$/
|
26
|
-
conn.response :logger, logger, bodies: (ENV['
|
26
|
+
conn.response :logger, logger, bodies: (ENV['SILENT_LOG_BODIES'] != 'true')
|
27
27
|
|
28
28
|
# Adapter (ensure that the adapter is always last.)
|
29
29
|
conn.adapter :typhoeus
|
data/lib/finapps/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|