shopify_api_bruv 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/shopify_api_bruv/clients/http_response.rb +22 -1
- 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: 38efd46bd4364767f9f3ab83f500fc9a7dd4361e80023eaf2587fd66d5dff380
|
4
|
+
data.tar.gz: a2f7d1f2e9a218dff3b96e123040ba8e06333f828b74a25b46decf27d791c025
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d43835d001e36aea5beec0d02f5d3c9f0ecb47808167a0b48a2050905e1bd187cb0532b9e84d239d769e035f7254a599cdf18b802be3abca930abb90c40666
|
7
|
+
data.tar.gz: 06076ae61c40e87ec4802f89ebe8c9196c347e5c5d4f3ce3a6dface969badf10aa489ebf579f69da1bfb6db987d666f1d50019d0efc361bfff9a534b1c2d16be
|
data/CHANGELOG.md
CHANGED
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
|