finapps_core 4.0.5 → 4.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: eba98fc6c3a8244d55bb5df6cdf3b7f6d801ca3616832d7d5212a457bc89ae00
4
- data.tar.gz: 7a25c2e816c3d042db423f352281576a33d78c16508a78ce777b9d1846475b1d
2
+ SHA1:
3
+ metadata.gz: 2e039d057e211719518583a16d832fe80a64e212
4
+ data.tar.gz: ce75fe43109625603b86c62f5feb4aaa6f28d62a
5
5
  SHA512:
6
- metadata.gz: 721f6b53b469d6a438bfeeb480f40cfb93f3ce1623859cc48275557c6db20201aea9fa2b519317ad1bd799b2ca98dbb639bf05e070b5c2672ae1ebc865db8703
7
- data.tar.gz: 0e1056a5f6c0dd3a821c37d40d883422abe8f7a9faadac948964c909e95dbffad11d142cb5376143d6e63dee202b6b8cf4ecd1fd16a08032603fd91e0290b9c5
6
+ metadata.gz: 8a0e395d5141e1ea0d4f3d6b4f2b09cc4b70df1b883424837380d6278a14dcadb7313da11fb99585803161f1c3578b930fba911bfe1ae3bb5e27146f536c6ea5
7
+ data.tar.gz: 7b11dee0c9f65d0c8f3dd823fa5ffc4106c8773e42053ade4df13df498b2172c6ca0b957b51a0873f43f7962f9b4059282d9bae0e05093ffa8ee1736bd0bf777
data/.travis.yml CHANGED
@@ -6,7 +6,7 @@ before_install:
6
6
  - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
7
7
  - gem update --system
8
8
  - gem --version
9
- - gem install bundler
9
+ - gem install bundler -v "~>1.0"
10
10
  script:
11
11
  - bundle exec rspec
12
12
  notifications:
@@ -23,6 +23,9 @@ module FinAppsCore # :nodoc:
23
23
  # Raised whenever the connection fails.
24
24
  class ConnectionFailedError < Error; end
25
25
 
26
+ # Raised whenever the user is locked out from sign in.
27
+ class UserLockoutError < Error; end
28
+
26
29
  %i[InvalidArgumentsError MissingArgumentsError ApiSessionTimeoutError
27
30
  UnsupportedHttpMethodError ConnectionFailedError].each do |const|
28
31
  Error.const_set(const, FinAppsCore.const_get(const))
@@ -8,8 +8,10 @@ module FinAppsCore
8
8
  class RaiseError < Faraday::Response::Middleware # :nodoc:
9
9
  SUCCESS_STATUSES = (200..299).freeze
10
10
  API_UNAUTHENTICATED = 401
11
+ FORBIDDEN = 403
11
12
  CONNECTION_FAILED_STATUS = 407
12
13
  API_SESSION_TIMEOUT = 419
14
+ LOCKOUT_MESSAGE = 'user is locked'
13
15
 
14
16
  def on_complete(env)
15
17
  return if SUCCESS_STATUSES.include?(env[:status])
@@ -17,6 +19,7 @@ module FinAppsCore
17
19
  raise(FinAppsCore::ApiUnauthenticatedError, 'API Invalid Session') if env[:status] == API_UNAUTHENTICATED
18
20
  raise(FinAppsCore::ApiSessionTimeoutError, 'API Session Timed out') if env[:status] == API_SESSION_TIMEOUT
19
21
  raise(FinAppsCore::ConnectionFailedError, 'Connection Failed') if env[:status] == CONNECTION_FAILED_STATUS
22
+ raise(FinAppsCore::UserLockoutError, 'User is Locked') if user_is_locked?(env)
20
23
 
21
24
  raise(Faraday::Error::ClientError, response_values(env))
22
25
  end
@@ -54,6 +57,10 @@ module FinAppsCore
54
57
  def empty?(obj)
55
58
  obj.nil? || (obj.respond_to?(:empty?) && obj.empty?)
56
59
  end
60
+
61
+ def user_is_locked?(env)
62
+ env.status == FORBIDDEN && error_messages(env.body)&.[](0)&.downcase == LOCKOUT_MESSAGE
63
+ end
57
64
  end
58
65
  end
59
66
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FinAppsCore
4
- VERSION = '4.0.6'
4
+ VERSION = '4.0.7'
5
5
  end
@@ -31,5 +31,10 @@ RSpec.describe FinAppsCore::Middleware::RaiseError do
31
31
  error_message = 'API Session Timed out'
32
32
  it { expect { subject.on_complete(env) }.to raise_error(FinAppsCore::ApiSessionTimeoutError, error_message) }
33
33
  end
34
+ context 'for user lockout error' do
35
+ let(:env) { Env.new(403, {}, '{"messages":["User is locked"]}') }
36
+ error_message = 'User is Locked'
37
+ it { expect { subject.on_complete(env) }.to raise_error(FinAppsCore::UserLockoutError, error_message) }
38
+ end
34
39
  end
35
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finapps_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.5
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Quintero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-26 00:00:00.000000000 Z
11
+ date: 2019-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
341
  version: '0'
342
342
  requirements: []
343
343
  rubyforge_project:
344
- rubygems_version: 2.7.6
344
+ rubygems_version: 2.6.8
345
345
  signing_key:
346
346
  specification_version: 4
347
347
  summary: FinApps REST API ruby client - Core.