finapps 2.0.13 → 2.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2987098824b52fede2e1a57d407bc402a6811e6
4
- data.tar.gz: ed685e787f5a304be08d50a13ccc79467b93380e
3
+ metadata.gz: 049e5b0cf3c762597409c561552dfb6eca8d6bdd
4
+ data.tar.gz: f9606a4cb061d6bff60a8906433dd83ea58ef0b7
5
5
  SHA512:
6
- metadata.gz: 7efb0ddf292db6de0ed56592d88e691ba37bc704dfa4afa3eb2dea6144e23b73d697f4c4bbd8426fa6198a19ca947ec31f6a75faec05010f755d439b37c8db97
7
- data.tar.gz: 935e7f9909363169f09717e1ab384a56ef34bbec5663aa9b64f0e00030b9ce2d2c4176c3f8af03e043e63f12e2195cc2ad62e89a5bd5e50d97c69c911ffd94ca
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
- CLIENT_ERROR_STATUSES = 400...600
8
+ SUCCESS_STATUSES = 200..299
9
+ CONNECTION_FAILED_STATUS = 407
10
10
 
11
11
  def on_complete(env)
12
- case env[:status]
13
- when 407
14
- # mimic the behavior that we get with proxy requests with HTTPS
15
- raise Faraday::Error::ConnectionFailed, '407 "Proxy Authentication Required"'
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
- # 200..206 Success codes
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
- body.is_a?(Hash) && body.key?('messages') ? body['messages'] : nil
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['RSPEC'] != 'true')
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module FinApps
3
- VERSION = '2.0.13'
3
+ VERSION = '2.0.14'
4
4
  end
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,6 @@ if ENV['CODECLIMATE_REPO_TOKEN']
4
4
  CodeClimate::TestReporter.start
5
5
  end
6
6
 
7
- ENV['RSPEC'] = 'true'
8
-
9
7
  require 'bundler/setup'
10
8
  Bundler.setup
11
9
 
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.13
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-19 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday