shoptet 0.0.53 → 0.0.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shoptet.rb +8 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42b4c432df5a8cfab2fd74136176b36850144aac3a4d58b218b35ed0991b5d9d
4
- data.tar.gz: b3de00e1daa9c3559092ee0245e646bf6023de7a1b09e4cf42834949f578a41f
3
+ metadata.gz: 3973988132bd7183d479a1e86cca5aea7ea6ac436390806c06bd1f62865f12f7
4
+ data.tar.gz: 897b12f9a8dae2f05f79369854ae04181980ebb854741b7802047634e5f0fbb0
5
5
  SHA512:
6
- metadata.gz: 842b328f703ac1b57597933aa98609fcae19343ae1572889f68e15c6b8438e4a904a7176ed88c65aa4934f331672addf19150e4ee12dd2ce118771ec3c9811d0
7
- data.tar.gz: 5030c94e9b3a8487bcdbc07c1fc62e06e8cd1b6fd3a764e5b40269556de93f4a50bf6ace829f3cdec849da3084073def60f40d172e8f90c466863ae7857ac8fc
6
+ metadata.gz: 2c2016f22a74cab724d270950a0e7fac3005ad3e827321f5998c4c45c0c383cd7355b3ac11fca89e07fb9f56ea32c1a51171e55ba4b92b23f1b9610c3025d3cf
7
+ data.tar.gz: 5a5d57ddaac9532ce0585d9ef13242c328f26c5ae0ccaec74daaced9f52bf9881f3469681278e535eb0638a190de899fed203b9039b68427fb8a3643469e05cb
data/lib/shoptet.rb CHANGED
@@ -29,7 +29,7 @@ class Shoptet
29
29
  end
30
30
 
31
31
  def self.version
32
- '0.0.53'
32
+ '0.0.55'
33
33
  end
34
34
 
35
35
  def self.ar_on_token_error(model)
@@ -81,13 +81,13 @@ class Shoptet
81
81
 
82
82
  attr_accessor :api_token
83
83
 
84
- def initialize oauth_url:, oauth_token:, shop_url:, client_id:, api_token: nil, on_token_error: nil
84
+ def initialize(oauth_url:, oauth_token:, shop_url:, client_id:, api_token: nil, on_token_error: nil)
85
85
  @oauth_url = oauth_url
86
86
  @oauth_token = oauth_token
87
87
  @shop_url = shop_url
88
88
  @client_id = client_id
89
- @api_token = api_token
90
89
  @on_token_error = on_token_error || ON_TOKEN_ERROR
90
+ @api_token = api_token
91
91
  end
92
92
 
93
93
  def endpoints api_params = {}
@@ -245,6 +245,7 @@ class Shoptet
245
245
  end
246
246
 
247
247
  def get(url, api_params = {}, retry_on_token_error = true)
248
+ @api_token ||= @on_token_error.call(self)
248
249
  url = URI(url)
249
250
  url.query = URI.encode_www_form(api_params) if api_params.any?
250
251
 
@@ -267,6 +268,7 @@ class Shoptet
267
268
  end
268
269
 
269
270
  def patch(url, data, retry_on_token_error = true)
271
+ @api_token ||= @on_token_error.call(self)
270
272
  url = URI(url)
271
273
  headers = { 'Shoptet-Access-Token' => @api_token,
272
274
  'Content-Type' => 'application/vnd.shoptet.v1.0' }
@@ -286,6 +288,7 @@ class Shoptet
286
288
  end
287
289
 
288
290
  def post_json(url, data, retry_on_token_error = true)
291
+ @api_token ||= @on_token_error.call(self)
289
292
  url = URI(url)
290
293
  headers = { 'Shoptet-Access-Token' => @api_token,
291
294
  'Content-Type' => 'application/vnd.shoptet.v1.0' }
@@ -305,6 +308,7 @@ class Shoptet
305
308
  end
306
309
 
307
310
  def post_binary(url, data, retry_on_token_error = true)
311
+ @api_token ||= @on_token_error.call(self)
308
312
  url = URI(url)
309
313
  headers = { 'Shoptet-Access-Token' => @api_token,
310
314
  'Content-Type' => 'application/vnd.shoptet.v1.0' }
@@ -324,6 +328,7 @@ class Shoptet
324
328
  end
325
329
 
326
330
  def delete(url, retry_on_token_error = true)
331
+ @api_token ||= @on_token_error.call(self)
327
332
  url = URI(url)
328
333
  headers = { 'Shoptet-Access-Token' => @api_token,
329
334
  'Content-Type' => 'application/vnd.shoptet.v1.0' }
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.53
4
+ version: 0.0.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Premysl Donat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: irb