shoptet 0.0.56 → 0.0.59

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: d83c5b425d0d96c66746d1da9c20cbcbaeaf5d4b3536a08fd7bf0783a837da4c
4
+ data.tar.gz: 15bf1adccfd6ee30386f1d8faa6d35ad1dc0db0f8d25e8164a9596f1fb083c1b
5
5
  SHA512:
6
- metadata.gz: 291f00b5cd05083b7927c886b6dfb392f2dbdf9d058e6f3b5d10dee469d537005f6a6a38d9f12ff67ca301bde14e899324f8d45c53ccf799c527bebffc557f6d
7
- data.tar.gz: fcbf8ae671df96e103418e341572f0e4db85e57fed82371c1bc4583c1b0be90399c15fbae21d0561cbb18305efb819ad89e0012c955426abef7902fe789f8d01
6
+ metadata.gz: 6aa3654df9ee3ca98d6d6970b3bcf131b6ceda362357951fa1ffc67c955954db0c28bec92ac99fd8bb017bfc4f8949697b74a0828cb85c9b2bf800895fc15a73
7
+ data.tar.gz: 2a50345b31764d6e1cf4d16952c96d27a4414aa65a559d926d3fc8f558daf80d10a896d08bb0d3a7ff5e81520dbbf04cf1168ab7b66df82094291a404127c5f8
@@ -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.59'
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,14 @@ 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
+
246
+ def brands(api_params = {})
247
+ enumerize("https://api.myshoptet.com/api/brands", api_params)
248
+ end
249
+
238
250
  def new_api_token
239
251
  headers = { 'Authorization' => "Bearer #{@oauth_token}" }
240
252
 
@@ -252,7 +264,7 @@ class Shoptet
252
264
  headers = { 'Shoptet-Access-Token' => @api_token,
253
265
  'Content-Type' => 'application/vnd.shoptet.v1.0' }
254
266
 
255
- result = Shoptet::Request.get(url, headers)
267
+ result = Shoptet::Request.get(url, headers, @logger)
256
268
  token_errors = handle_errors(result)
257
269
 
258
270
  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.59
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-29 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: