beyond_api 0.24.2.pre → 0.24.3.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: 8d639c8a6307238a7dbc87d0d3a66b0e69c693db6d124cea7f7d89cfa5cc7488
4
- data.tar.gz: eb19fa1766b92049d2900829a730ccc0fdd78dd18465f8b5ae9d28df384e799b
3
+ metadata.gz: c9a08ccefc4acb0bfeacf32a46a5245957fecd2aa36e382417031a641638bb0c
4
+ data.tar.gz: 5841b98257b1233859ac6e4066172411017560aca64abf3e87ec134452949d4a
5
5
  SHA512:
6
- metadata.gz: 7ac1cc1a3e0b046b5add6a53001a2c602741ca62d3acfee1d6db1a59469af38907693918f821688a5d4c31cde5e27048b56ddd9468ed91d14890d49454dffc7c
7
- data.tar.gz: 5c7468464f88a6513832236edf49939f534d9482edf27668a55b1ef659c5aec03795c40d1775acf3630f37958f17ce356c856e53bbde2ce19e20514389e1347e
6
+ metadata.gz: d6a82f6ff8d9902d48541ca9a4e1d0458b42256cc3678c2960a7fad0e99cc6648fbd0ff3a93f795405ad22048bd4bf3c08d697175b2c8981b11f656b23b061ed
7
+ data.tar.gz: 1dab71c2c694618119f57aaad1fe46a5febf61a104ae5251e737e83418883d449a01cb1b2646f236011acef501877bf8f25bc62ba4ca3a3b51ce2fc78dbe747d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- beyond_api (0.24.2.pre)
4
+ beyond_api (0.24.3.pre)
5
5
  faraday (~> 1.9.0)
6
6
 
7
7
  GEM
@@ -9,15 +9,16 @@ module BeyondApi
9
9
 
10
10
  def self.default
11
11
  Faraday.new(ssl: { verify: true }) do |faraday|
12
+ faraday.adapter(:net_http)
12
13
  faraday.options[:open_timeout] = BeyondApi.configuration.open_timeout.to_i
13
14
  faraday.options[:timeout] = BeyondApi.configuration.timeout.to_i
14
- faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
15
- bodies: BeyondApi.configuration.log_bodies }
16
15
  faraday.headers["Accept"] = "application/json"
17
16
  faraday.headers["Content-Type"] = "application/json"
18
17
  faraday.request(:multipart)
19
18
  faraday.request(:url_encoded)
20
- faraday.adapter(:net_http)
19
+ faraday.request(:retry, BeyondApi.configuration.retry_options)
20
+ faraday.response :logger, LOGGER, { headers: BeyondApi.configuration.log_headers,
21
+ bodies: BeyondApi.configuration.log_bodies }
21
22
  end
22
23
  end
23
24
 
@@ -5,6 +5,8 @@ module BeyondApi
5
5
  attr_reader :error_id, :details, :trace_id, :full_message, :status_code, :error, :error_description
6
6
 
7
7
  def initialize(data, status_code = nil)
8
+ data ||= {}
9
+
8
10
  @error_id = data["errorId"]
9
11
  @details = data["details"]
10
12
  @trace_id = data["traceId"]
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ostruct"
4
+
3
5
  module BeyondApi
4
6
  module Utils
5
7
  extend self
@@ -22,7 +24,11 @@ module BeyondApi
22
24
  result = all_paginated(url, params.merge(page: 0, size: paginated_size))
23
25
 
24
26
  (1..result[:page][:total_pages] - 1).each do |page|
25
- result[:embedded][resource].concat(all_paginated(url, params.merge(page: page, size: paginated_size))[:embedded][resource])
27
+ result[:embedded][resource].concat(
28
+ all_paginated(url,
29
+ params.merge(page: page,
30
+ size: paginated_size))[:embedded][resource]
31
+ )
26
32
  end
27
33
 
28
34
  result[:page][:size] = result[:page][:total_elements]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeyondApi
4
- VERSION = "0.24.2.pre"
4
+ VERSION = "0.24.3.pre"
5
5
  end
data/lib/beyond_api.rb CHANGED
@@ -29,7 +29,7 @@ module BeyondApi
29
29
  class Configuration
30
30
  attr_accessor :client_id, :client_secret, :open_timeout, :timeout, :remove_response_links,
31
31
  :remove_response_key_underscores, :object_struct_responses, :raise_error_requests,
32
- :log_headers, :log_bodies, :log_level, :all_pagination_size
32
+ :log_headers, :log_bodies, :log_level, :all_pagination_size, :retry_options
33
33
 
34
34
  def initialize
35
35
  @client_id = nil
@@ -46,6 +46,15 @@ module BeyondApi
46
46
  @log_bodies = false
47
47
 
48
48
  @all_pagination_size = 200
49
+
50
+ @retry_options = {
51
+ max: 5,
52
+ interval: 0.05,
53
+ interval_randomness: 0.5,
54
+ backoff_factor: 2,
55
+ retry_statuses: [409],
56
+ exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed]
57
+ }
49
58
  end
50
59
  end
51
60
  end
@@ -50,4 +50,18 @@ BeyondApi.setup do |config|
50
50
  # BeyondApi::Error object with detailed information of the error.
51
51
  # Default is false.
52
52
  # config.raise_error_requests = false
53
+
54
+ # ==> Retry configuration
55
+ # Configure the retry options for requests. Default is:
56
+ # config.retry_options = {
57
+ # max: 5,
58
+ # interval: 0.05,
59
+ # interval_randomness: 0.5,
60
+ # backoff_factor: 2,
61
+ # retry_statuses: [409],
62
+ # exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed]
63
+ # }
64
+ # Or you can set single retry options like this:
65
+ # config.retry_options[:max] = 5
66
+ # config.retry_options[:interval] = 1
53
67
  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.24.2.pre
4
+ version: 0.24.3.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unai Abrisketa
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2024-03-06 00:00:00.000000000 Z
14
+ date: 2024-11-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler