shoptet 0.0.56 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/shoptet/request.rb +10 -2
- data/lib/shoptet.rb +11 -3
- data/shoptet.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 71cdd0b0002de52252ed31d2415e1c5d957faf71014a66dfaff304756caf5436
|
|
4
|
+
data.tar.gz: 8eb1b1cab9efe0f667745f1047b5c6ec69a84982ed9e984e387e334d8542502c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 720a1d2d6a73fedafcd006ce2447fb5510a3bfaa7b4442f3588d40ca8d5aa6f9437ad165802d31179adadf2c9a70f744c52871a8546cba0bd9b375918de8d5f0
|
|
7
|
+
data.tar.gz: 646bf13eea0ca50fd6d764a9c5e502a3589ea1d7ba73e936b1d11d289d92d9e5037d4e55850cf5be1e0d8f12f559c48785dc59334ab0623322e53e0268a317fb
|
data/lib/shoptet/request.rb
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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://
|
|
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.
|
|
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:
|
|
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://
|
|
46
|
+
homepage: https://git.sr.ht/~masa331/shoptet
|
|
47
47
|
licenses:
|
|
48
48
|
- MIT
|
|
49
49
|
metadata:
|
|
50
|
-
homepage_uri: https://
|
|
51
|
-
source_code_uri: https://
|
|
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:
|