shopify_api_bruv 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/shopify_api_bruv/clients/http_response.rb +25 -2
- data/lib/shopify_api_bruv/version.rb +1 -1
- 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: 8fe961253cfd9043fec5d23379112770493cca121e7ae185b0728afe98fed68f
|
4
|
+
data.tar.gz: 4889e5d8748bc5c60d4e74ee196e935e738fdd843630ceaac28aa9857bb7529d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a02f83d45ec7bf81c2aa9d8e335f86b0ddf09496d9647e7e0e145403350b746e36f21cfd706806cb536d35facdd8cc01c4fecd4f5d35f56644553802b4651e
|
7
|
+
data.tar.gz: d976fd73f1a78aac2d9f37cd598b469ab3831934577f147ba4b62d330e8cd2ce92bcfd7d07d00487f1d9b7761d73ee590b1ac2f92fce662e48ae0edede583394
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.3] - 2023-12-09
|
4
|
+
|
5
|
+
- Updates http response error message
|
6
|
+
|
7
|
+
## [0.2.2] - 2023-12-09
|
8
|
+
|
9
|
+
- Adds page info to http response
|
10
|
+
|
3
11
|
## [0.2.1] - 2023-12-09
|
4
12
|
|
5
13
|
- Adds feature to automatically fetch the mutation object name to pre-select data
|
data/Gemfile.lock
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
module ShopifyApiBruv
|
4
4
|
module Clients
|
5
5
|
class HttpResponse
|
6
|
-
attr_reader :code, :headers, :body
|
6
|
+
attr_reader :code, :headers, :body, :page_info
|
7
7
|
|
8
8
|
def initialize(code:, headers:, body:)
|
9
9
|
@code = code
|
10
10
|
@headers = headers
|
11
11
|
@body = body
|
12
|
+
@page_info = parse_page_info
|
12
13
|
|
13
14
|
ShopifyApiBruv.logger(
|
14
15
|
method: :info,
|
@@ -20,6 +21,26 @@ module ShopifyApiBruv
|
|
20
21
|
|
21
22
|
private
|
22
23
|
|
24
|
+
def parse_page_info
|
25
|
+
return { previous: nil, next: nil } if headers['link'].nil?
|
26
|
+
|
27
|
+
page_info = {}
|
28
|
+
|
29
|
+
headers['link'].split(',').each do |link|
|
30
|
+
rel = link.match(/rel="(.*?)"/).captures.first
|
31
|
+
url = link.match(/<(.*?)>/).captures.first
|
32
|
+
|
33
|
+
URI.parse(url).query.split('&').each do |param|
|
34
|
+
if param.split('=').first == 'page_info'
|
35
|
+
page_info[rel] = param.split('=').last
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
{ previous: page_info['previous'], next: page_info['next'] }
|
42
|
+
end
|
43
|
+
|
23
44
|
def ok?
|
24
45
|
(200..299).cover?(code)
|
25
46
|
end
|
@@ -27,7 +48,9 @@ module ShopifyApiBruv
|
|
27
48
|
def validate!
|
28
49
|
return if ok?
|
29
50
|
|
30
|
-
|
51
|
+
errors = body['errors'] || ''
|
52
|
+
|
53
|
+
raise Errors::HttpResponseError, errors
|
31
54
|
end
|
32
55
|
end
|
33
56
|
end
|