shoptet 0.0.27 → 0.0.28

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: fdf758bbae88c6e735ac1bd54968ce0ec7491b5608918767b86b892adf75b0d3
4
- data.tar.gz: bf8207c9c58a30251a8926aec33fb312af16792edbdf010a56dde488d9aa5e5e
3
+ metadata.gz: 39d32c0913a994e39a4886c159bedeb2c8d18a62e2c02d6d1934e49d5cbc4702
4
+ data.tar.gz: fc99b75ec8e3c0224dfd67d5783c447deb6b3de890558166c7ed1a41b50ed017
5
5
  SHA512:
6
- metadata.gz: b786cd47263dbc954c8b813134def4625c829ec4f6f23d5193d8bb07017b3efd4524d51d3a53ccb0f9d6ca97ed3b67aed4dd09608aa1261f0ea5f356c7c1adcd
7
- data.tar.gz: 80786ee8885ce65e971279e300dbd4f11de589d682467fbf55b41e6e43084958226c63bd52c8f0ff33ddd7718f124b402b64499d949f9783668cb8fbab485ae7
6
+ metadata.gz: 134155a8e5d780c772344f94a4cd1a1d82273bc714128b9a95b43ea83b816122e748cc59d4237d62e247af83dcdbf4ecb96b0a56620e60f931e58290dc58d35f
7
+ data.tar.gz: 169ed27569a934a8a5b19a042f0054412cc0c950c3a6f92a7048874eb2864bbb3b3fa5e33543d3412f8e4d798024fd4a26265facd332ad5d246317832ba252ef
data/lib/shoptet.rb CHANGED
@@ -23,7 +23,7 @@ class Shoptet
23
23
  end
24
24
 
25
25
  def self.version
26
- '0.0.27'
26
+ '0.0.28'
27
27
  end
28
28
 
29
29
  def self.ar_on_token_error(model)
@@ -16,7 +16,7 @@ class Shoptet
16
16
  request[key] = value
17
17
  end
18
18
 
19
- response = http.request(request)
19
+ response = handle_net_timeouts { http.request(request) }
20
20
  parsed_body = Oj.load(response.body, mode: :compat)
21
21
 
22
22
  unless parsed_body
@@ -25,8 +25,6 @@ class Shoptet
25
25
  end
26
26
 
27
27
  parsed_body
28
- rescue Net::OpenTimeout => e
29
- raise(e.class, "#{e.message} - on url #{url}")
30
28
  end
31
29
 
32
30
  def self.post url, body
@@ -34,10 +32,26 @@ class Shoptet
34
32
  request.set_form_data(body)
35
33
 
36
34
  response = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
37
- http.request(request)
35
+ handle_net_timeouts { http.request(request) }
38
36
  end
39
37
 
40
38
  Oj.load(response.body, mode: :compat)
41
39
  end
40
+
41
+ private
42
+
43
+ def self.handle_net_timeouts
44
+ attempts = 0
45
+
46
+ begin
47
+ yield
48
+ rescue Net::OpenTimeout
49
+ raise if retries > 3
50
+
51
+ retries += 1
52
+
53
+ retry
54
+ end
55
+ end
42
56
  end
43
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoptet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Premysl Donat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-07 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj