shoptet 0.0.56 → 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: b806de61c9bdc66e0cf313c61e02917974ffa4dc8ff9f66caa4ef0a58e7a7289
4
- data.tar.gz: fe10bf593c8ed55589553c98b5b8d77a4ca84193fe9435b7ba104aaa0ec5107d
3
+ metadata.gz: 71cdd0b0002de52252ed31d2415e1c5d957faf71014a66dfaff304756caf5436
4
+ data.tar.gz: 8eb1b1cab9efe0f667745f1047b5c6ec69a84982ed9e984e387e334d8542502c
5
5
  SHA512:
6
- metadata.gz: 291f00b5cd05083b7927c886b6dfb392f2dbdf9d058e6f3b5d10dee469d537005f6a6a38d9f12ff67ca301bde14e899324f8d45c53ccf799c527bebffc557f6d
7
- data.tar.gz: fcbf8ae671df96e103418e341572f0e4db85e57fed82371c1bc4583c1b0be90399c15fbae21d0561cbb18305efb819ad89e0012c955426abef7902fe789f8d01
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.56'
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?
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.56
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-10-21 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: