beyond_api 0.2.1.pre → 0.3.0.pre
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/Gemfile.lock +1 -1
- data/lib/beyond_api/utils.rb +3 -2
- data/lib/beyond_api/version.rb +1 -1
- data/lib/beyond_api.rb +10 -1
- data/lib/generators/templates/beyond_api_initializer.rb +6 -0
- 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: 39f26590cd69a079e050654b3594df5730ad90b989135d2ec98f0ab81bdc8c29
|
4
|
+
data.tar.gz: bdf1d4aead411a78eeaddf0fefa04a9ff016ec512248002a83aa83b99ff09651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 844e88bcc3c6a4bc455ff939479429bb109ea11627bf745ad91ea8eea11bbd7ef3ffbdfbdcb767e96b8ded26c6e17d2e6e05dfe33e51c8901af9ab2e492222b0
|
7
|
+
data.tar.gz: 3c2ff7a924237f01b048c6de04b692b004039410023f0ef62e75b7a070a27145b2ba1526b08f5629389eb0a66fae6c7a1b85cd40d1a2a3fab6645ddd6842ffbe
|
data/Gemfile.lock
CHANGED
data/lib/beyond_api/utils.rb
CHANGED
@@ -10,8 +10,9 @@ 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
|
13
|
+
error = BeyondApi::Error.new(response)
|
14
|
+
BeyondApi.logger.error "[Beyond API] #{response}"
|
15
|
+
BeyondApi.configuration.raise_error_requests ? raise(error) : error
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
data/lib/beyond_api/version.rb
CHANGED
data/lib/beyond_api.rb
CHANGED
@@ -10,6 +10,14 @@ require "beyond_api/utils"
|
|
10
10
|
module BeyondApi
|
11
11
|
class Error < StandardError; end
|
12
12
|
|
13
|
+
def self.logger
|
14
|
+
@@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.logger=(logger)
|
18
|
+
@@logger = logger
|
19
|
+
end
|
20
|
+
|
13
21
|
class << self
|
14
22
|
attr_accessor :configuration
|
15
23
|
end
|
@@ -22,7 +30,7 @@ module BeyondApi
|
|
22
30
|
|
23
31
|
class Configuration
|
24
32
|
attr_accessor :client_id, :client_secret, :open_timeout, :timeout, :remove_response_links,
|
25
|
-
:remove_response_key_underscores, :object_struct_responses
|
33
|
+
:remove_response_key_underscores, :object_struct_responses, :raise_error_requests
|
26
34
|
|
27
35
|
def initialize
|
28
36
|
@client_id = nil
|
@@ -32,6 +40,7 @@ module BeyondApi
|
|
32
40
|
@remove_response_links = false
|
33
41
|
@remove_response_key_underscores = false
|
34
42
|
@object_struct_responses = false
|
43
|
+
@raise_error_requests = false
|
35
44
|
end
|
36
45
|
end
|
37
46
|
end
|
@@ -26,4 +26,10 @@ BeyondApi.setup do |config|
|
|
26
26
|
# With OpenStructs => response.embeded.products.first.id
|
27
27
|
# Without OpenStructs => response["embeded"]["products"].first["id"]
|
28
28
|
# config.object_struct_responses = false
|
29
|
+
|
30
|
+
# Configure if the gem should raise on error requests. Setting it to true is
|
31
|
+
# useful for working with exceptions. Setting it to false will return a
|
32
|
+
# BeyondApi::Error object with detailed information of the error.
|
33
|
+
# Default is false.
|
34
|
+
# config.raise_error_requests = false
|
29
35
|
end
|
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.3.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: 2019-10-
|
13
|
+
date: 2019-10-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|