shoptet 0.0.55 → 0.0.58

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: 3973988132bd7183d479a1e86cca5aea7ea6ac436390806c06bd1f62865f12f7
4
- data.tar.gz: 897b12f9a8dae2f05f79369854ae04181980ebb854741b7802047634e5f0fbb0
3
+ metadata.gz: 71cdd0b0002de52252ed31d2415e1c5d957faf71014a66dfaff304756caf5436
4
+ data.tar.gz: 8eb1b1cab9efe0f667745f1047b5c6ec69a84982ed9e984e387e334d8542502c
5
5
  SHA512:
6
- metadata.gz: 2c2016f22a74cab724d270950a0e7fac3005ad3e827321f5998c4c45c0c383cd7355b3ac11fca89e07fb9f56ea32c1a51171e55ba4b92b23f1b9610c3025d3cf
7
- data.tar.gz: 5a5d57ddaac9532ce0585d9ef13242c328f26c5ae0ccaec74daaced9f52bf9881f3469681278e535eb0638a190de899fed203b9039b68427fb8a3643469e05cb
6
+ metadata.gz: 720a1d2d6a73fedafcd006ce2447fb5510a3bfaa7b4442f3588d40ca8d5aa6f9437ad165802d31179adadf2c9a70f744c52871a8546cba0bd9b375918de8d5f0
7
+ data.tar.gz: 646bf13eea0ca50fd6d764a9c5e502a3589ea1d7ba73e936b1d11d289d92d9e5037d4e55850cf5be1e0d8f12f559c48785dc59334ab0623322e53e0268a317fb
@@ -3,7 +3,7 @@ require 'json'
3
3
 
4
4
  class Shoptet
5
5
  class Request
6
- def self.get(url, headers)
6
+ def self.get(url, headers, logger = nil)
7
7
  http = Net::HTTP.new(url.host, url.port)
8
8
  http.use_ssl = true
9
9
  http.open_timeout = 30
@@ -16,8 +16,16 @@ class Shoptet
16
16
  request[key] = value
17
17
  end
18
18
 
19
+ if logger
20
+ logger.debug("GET #{url}")
21
+ end
22
+
19
23
  response = handle_connection_errors { http.request(request) }
20
- parsed_body = JSON.parse(response.body)
24
+ body = response.body
25
+ if logger
26
+ logger.debug("RESPONSE #{body}")
27
+ end
28
+ parsed_body = JSON.parse(body)
21
29
 
22
30
  unless parsed_body
23
31
  message = "Status code: #{response.code}, url: #{url}"
data/lib/shoptet.rb CHANGED
@@ -29,7 +29,7 @@ class Shoptet
29
29
  end
30
30
 
31
31
  def self.version
32
- '0.0.55'
32
+ '0.0.58'
33
33
  end
34
34
 
35
35
  def self.ar_on_token_error(model)
@@ -81,13 +81,17 @@ 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, logger: 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
89
  @on_token_error = on_token_error || ON_TOKEN_ERROR
90
90
  @api_token = api_token
91
+ @logger = logger
92
+ if @logger
93
+ @logger.debug("Initialized Shoptet api")
94
+ end
91
95
  end
92
96
 
93
97
  def endpoints api_params = {}
@@ -235,6 +239,10 @@ class Shoptet
235
239
  enumerize("https://api.myshoptet.com/api/webhooks", api_params)
236
240
  end
237
241
 
242
+ def flags(api_params = {})
243
+ enumerize("https://api.myshoptet.com/api/products/flags", api_params)
244
+ end
245
+
238
246
  def new_api_token
239
247
  headers = { 'Authorization' => "Bearer #{@oauth_token}" }
240
248
 
@@ -252,7 +260,7 @@ class Shoptet
252
260
  headers = { 'Shoptet-Access-Token' => @api_token,
253
261
  'Content-Type' => 'application/vnd.shoptet.v1.0' }
254
262
 
255
- result = Shoptet::Request.get(url, headers)
263
+ result = Shoptet::Request.get(url, headers, @logger)
256
264
  token_errors = handle_errors(result)
257
265
 
258
266
  if token_errors.any?
@@ -349,7 +357,7 @@ class Shoptet
349
357
 
350
358
  def suspended?
351
359
  false if shop_info
352
- rescue Shoptet::AddonSuspended
360
+ rescue Shoptet::AddonSuspended, Shoptet::ProjectNotFound
353
361
  true
354
362
  end
355
363
 
data/shoptet.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = 'API wrapper for interacting with Shoptet api'
10
10
  spec.description = spec.summary
11
- spec.homepage = 'https://github.com/Masa331/shoptet'
11
+ spec.homepage = 'https://git.sr.ht/~masa331/shoptet'
12
12
  spec.license = 'MIT'
13
13
  spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
14
 
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.55
4
+ version: 0.0.58
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-12 00:00:00.000000000 Z
11
+ date: 2024-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: irb
@@ -43,12 +43,12 @@ files:
43
43
  - lib/shoptet/api_enumerator.rb
44
44
  - lib/shoptet/request.rb
45
45
  - shoptet.gemspec
46
- homepage: https://github.com/Masa331/shoptet
46
+ homepage: https://git.sr.ht/~masa331/shoptet
47
47
  licenses:
48
48
  - MIT
49
49
  metadata:
50
- homepage_uri: https://github.com/Masa331/shoptet
51
- source_code_uri: https://github.com/Masa331/shoptet
50
+ homepage_uri: https://git.sr.ht/~masa331/shoptet
51
+ source_code_uri: https://git.sr.ht/~masa331/shoptet
52
52
  post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths: