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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 352d24353de02f75eacf6c36787cb7874b39ca1a46861fda5e7158b3c832849c
4
- data.tar.gz: af2a5e82844ee8ab33f6084594ffb36f9849ba00204fb75f33478fc7a5fbaa02
3
+ metadata.gz: 38efd46bd4364767f9f3ab83f500fc9a7dd4361e80023eaf2587fd66d5dff380
4
+ data.tar.gz: a2f7d1f2e9a218dff3b96e123040ba8e06333f828b74a25b46decf27d791c025
5
5
  SHA512:
6
- metadata.gz: 83468266128639b7439119bd14099e9d8082a71edd5b738b6321651e44398aa0ccf40dded8f48b46d74469c570e0783982e5bef8ae7250ca4c2a1ca39bae6df6
7
- data.tar.gz: 10b38d91004d40e2c8f71cec7de451e1295b447b592b91fd0ae8f0fc4053108eca59f788740fe44ca4af3eeb358f3337de9a85a2fc4f307d3297dede4fdc603a
6
+ metadata.gz: 56d43835d001e36aea5beec0d02f5d3c9f0ecb47808167a0b48a2050905e1bd187cb0532b9e84d239d769e035f7254a599cdf18b802be3abca930abb90c40666
7
+ data.tar.gz: 06076ae61c40e87ec4802f89ebe8c9196c347e5c5d4f3ce3a6dface969badf10aa489ebf579f69da1bfb6db987d666f1d50019d0efc361bfff9a534b1c2d16be
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.2] - 2023-12-09
4
+
5
+ - Adds page info to http response
6
+
3
7
  ## [0.2.1] - 2023-12-09
4
8
 
5
9
  - Adds feature to automatically fetch the mutation object name to pre-select data
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api_bruv (0.2.1)
4
+ shopify_api_bruv (0.2.2)
5
5
  httparty
6
6
  logger
7
7
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyApiBruv
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api_bruv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Idjent