beyond_api 0.10.0.pre → 0.11.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/beyond_api/error.rb +10 -7
- data/lib/beyond_api/resources/token.rb +5 -1
- data/lib/beyond_api/utils.rb +7 -2
- data/lib/beyond_api/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: 78c3366e77c86e546074cbbc049e2161b231511deede234a92f96d315575ba45
|
4
|
+
data.tar.gz: f8e08acff7d5f80be7ffd249c83d6116abd86ddfb216e5c25e955deaffe439be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4f0be05bb0c55da87c1c650b86f112993ce8346f6178f3cf27d865d8415377924263d0b2ec648b8a1d8026c6a5a4250221a8dc68ba39bd154bfb43c0913649c
|
7
|
+
data.tar.gz: 8400df3f3b61240c0516fc4d86e386eea7e67f88ca56324e68989f731d415e77ab9907817b092dc59c87f79794d96d1e7a76960e4785ebf0237b384ca6ed64e7
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/beyond_api/error.rb
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BeyondApi
|
4
|
-
class Error
|
5
|
-
attr_reader :error_id, :details, :
|
4
|
+
class Error < StandardError
|
5
|
+
attr_reader :error_id, :details, :trace_id, :full_message, :status_code
|
6
6
|
|
7
|
-
def initialize(data)
|
8
|
-
@error_id
|
9
|
-
@details
|
10
|
-
@
|
11
|
-
@
|
7
|
+
def initialize(data, status_code = nil)
|
8
|
+
@error_id = data['errorId']
|
9
|
+
@details = data['details']
|
10
|
+
@trace_id = data['traceId']
|
11
|
+
@full_message = data
|
12
|
+
@status_code = status_code
|
13
|
+
|
14
|
+
super(data['message'])
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "beyond_api/utils"
|
4
|
+
|
3
5
|
module BeyondApi
|
4
6
|
class Token
|
5
7
|
class InvalidSessionError < StandardError; end
|
6
8
|
|
9
|
+
include BeyondApi::Utils
|
10
|
+
|
7
11
|
attr_reader :session
|
8
12
|
|
9
13
|
def initialize(session)
|
@@ -44,7 +48,7 @@ module BeyondApi
|
|
44
48
|
@session.refresh_token = response["refresh_token"]
|
45
49
|
@session
|
46
50
|
else
|
47
|
-
|
51
|
+
handle_error(response, status)
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
data/lib/beyond_api/utils.rb
CHANGED
@@ -10,11 +10,16 @@ module BeyondApi
|
|
10
10
|
response = sanitize_response(response)
|
11
11
|
BeyondApi.configuration.object_struct_responses ? to_object_struct(response) : response
|
12
12
|
else
|
13
|
-
|
14
|
-
BeyondApi.configuration.raise_error_requests ? raise(response.to_s) : BeyondApi::Error.new(response)
|
13
|
+
handle_error(response, status)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
17
|
+
def handle_error(response, status)
|
18
|
+
BeyondApi.logger.error "[Beyond API] #{status}: #{response}"
|
19
|
+
error = BeyondApi::Error.new(response, status)
|
20
|
+
BeyondApi.configuration.raise_error_requests ? raise(error) : error
|
21
|
+
end
|
22
|
+
|
18
23
|
def to_object_struct(data)
|
19
24
|
if data.is_a? Hash
|
20
25
|
return OpenStruct.new(data.map { |key, val| [key, to_object_struct(val)] }.to_h)
|
data/lib/beyond_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beyond_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unai Abrisketa
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-05-
|
13
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|