shoptet 0.0.56 → 0.0.59
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 +15 -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: d83c5b425d0d96c66746d1da9c20cbcbaeaf5d4b3536a08fd7bf0783a837da4c
|
|
4
|
+
data.tar.gz: 15bf1adccfd6ee30386f1d8faa6d35ad1dc0db0f8d25e8164a9596f1fb083c1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6aa3654df9ee3ca98d6d6970b3bcf131b6ceda362357951fa1ffc67c955954db0c28bec92ac99fd8bb017bfc4f8949697b74a0828cb85c9b2bf800895fc15a73
|
|
7
|
+
data.tar.gz: 2a50345b31764d6e1cf4d16952c96d27a4414aa65a559d926d3fc8f558daf80d10a896d08bb0d3a7ff5e81520dbbf04cf1168ab7b66df82094291a404127c5f8
|
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.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://
|
|
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.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:
|
|
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://
|
|
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:
|