shoptet 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/lib/shoptet.rb +4 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f2a8ff1331b90ddcd3421d6408b667643d3fe8b95643ea7833f192a8152103d
|
4
|
+
data.tar.gz: 8a87de0252b757023dd35c20f67885454d4cc85f72651b4b91c32a9430531805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b1cfa1f1fe0b8d57bb8df48793224a94dd970adad6af9438ada8bdbeb0ba62caa91578058c50582fdcf2f890970995ff6bb73c56358699b9fa2726dd5801520
|
7
|
+
data.tar.gz: 5d45e753e5a64158e0d1d21b2f1dbc6daea2c894a70c6a2b43e0eccdd3645fe2ae569f452865c7752fde2b3ea623e90c17dd83c8d005f95f1eb5175901ffa7bd
|
data/.gitignore
CHANGED
data/lib/shoptet.rb
CHANGED
@@ -17,7 +17,7 @@ class Shoptet
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.version
|
20
|
-
'0.0.
|
20
|
+
'0.0.2'
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.ar_on_token_error(model)
|
@@ -106,22 +106,7 @@ class Shoptet
|
|
106
106
|
headers = { 'Authorization' => "Bearer #{@oauth_token}" }
|
107
107
|
|
108
108
|
result = Shoptet::Request.get @oauth_url, headers
|
109
|
-
handle_errors result
|
110
|
-
|
111
|
-
# error = result['error']
|
112
|
-
# errors = result['errors'] || []
|
113
|
-
#
|
114
|
-
# #TODO: unite error handling with #request
|
115
|
-
# if error || errors.any?
|
116
|
-
# additional_data = {
|
117
|
-
# uri: @oauth_url,
|
118
|
-
# headers: scrub_sensitive_headers(headers)
|
119
|
-
# }
|
120
|
-
#
|
121
|
-
# raise Error.new result, additional_data
|
122
|
-
# else
|
123
|
-
# result.fetch 'access_token'
|
124
|
-
# end
|
109
|
+
handle_errors result, @oauth_url
|
125
110
|
|
126
111
|
result.fetch 'access_token'
|
127
112
|
end
|
@@ -160,7 +145,7 @@ class Shoptet
|
|
160
145
|
'Content-Type' => 'application/vnd.shoptet.v1.0' }
|
161
146
|
|
162
147
|
result = Shoptet::Request.get uri, headers
|
163
|
-
token_errors = handle_errors result
|
148
|
+
token_errors = handle_errors result, uri
|
164
149
|
|
165
150
|
if token_errors.any?
|
166
151
|
@on_token_error.call self
|
@@ -170,7 +155,7 @@ class Shoptet
|
|
170
155
|
end
|
171
156
|
end
|
172
157
|
|
173
|
-
def handle_errors result
|
158
|
+
def handle_errors result, uri
|
174
159
|
error = result['error']
|
175
160
|
errors = result['errors'] || []
|
176
161
|
token_errors, non_token_errors = errors.partition { |err| ['invalid-token', 'expired-token'].include? err['errorCode'] }
|