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
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2e039d057e211719518583a16d832fe80a64e212
|
|
4
|
+
data.tar.gz: ce75fe43109625603b86c62f5feb4aaa6f28d62a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a0e395d5141e1ea0d4f3d6b4f2b09cc4b70df1b883424837380d6278a14dcadb7313da11fb99585803161f1c3578b930fba911bfe1ae3bb5e27146f536c6ea5
|
|
7
|
+
data.tar.gz: 7b11dee0c9f65d0c8f3dd823fa5ffc4106c8773e42053ade4df13df498b2172c6ca0b957b51a0873f43f7962f9b4059282d9bae0e05093ffa8ee1736bd0bf777
|
data/.travis.yml
CHANGED
data/lib/finapps_core/error.rb
CHANGED
|
@@ -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
|
data/lib/finapps_core/version.rb
CHANGED
|
@@ -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.
|
|
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:
|
|
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.
|
|
344
|
+
rubygems_version: 2.6.8
|
|
345
345
|
signing_key:
|
|
346
346
|
specification_version: 4
|
|
347
347
|
summary: FinApps REST API ruby client - Core.
|