beyond_api 0.2.1.pre → 0.3.0.pre

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
  SHA256:
3
- metadata.gz: 59988b23bcac918d9cbe5a81b89f632a989bef014ef802e4fbaa2793b204ac78
4
- data.tar.gz: 1139c9d4e6a7d349c91a5dad4edd5abfcef03a0809f8b1dfeb3536ce5b6ab270
3
+ metadata.gz: 39f26590cd69a079e050654b3594df5730ad90b989135d2ec98f0ab81bdc8c29
4
+ data.tar.gz: bdf1d4aead411a78eeaddf0fefa04a9ff016ec512248002a83aa83b99ff09651
5
5
  SHA512:
6
- metadata.gz: 0c393c99fe9e57b317333f033e8c8c007e26c67495e3c67986c13e670288fe9d7e5c0efc3250dab338215075209d290c3637491d5b7bcbf73b0b8e868202759f
7
- data.tar.gz: bb899b65618f95b1ea0d1632ea23a562a8672ea9dfbe1d99053ab0daab3d85a1d4a2757a06396fd82b556ec942b5b003581480bd35b764d61982a15db12f0e9e
6
+ metadata.gz: 844e88bcc3c6a4bc455ff939479429bb109ea11627bf745ad91ea8eea11bbd7ef3ffbdfbdcb767e96b8ded26c6e17d2e6e05dfe33e51c8901af9ab2e492222b0
7
+ data.tar.gz: 3c2ff7a924237f01b048c6de04b692b004039410023f0ef62e75b7a070a27145b2ba1526b08f5629389eb0a66fae6c7a1b85cd40d1a2a3fab6645ddd6842ffbe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_api (0.2.1.pre)
4
+ beyond_api (0.3.0.pre)
5
5
  faraday (~> 0.15)
6
6
 
7
7
  GEM
@@ -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
- logger.error "[Beyond API] #{response}" if logger
14
- BeyondApi::Error.new(response)
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
 
@@ -1,3 +1,3 @@
1
1
  module BeyondApi
2
- VERSION = "0.2.1.pre".freeze
2
+ VERSION = "0.3.0.pre".freeze
3
3
  end
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.2.1.pre
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-18 00:00:00.000000000 Z
13
+ date: 2019-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler