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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 352d24353de02f75eacf6c36787cb7874b39ca1a46861fda5e7158b3c832849c
4
- data.tar.gz: af2a5e82844ee8ab33f6084594ffb36f9849ba00204fb75f33478fc7a5fbaa02
3
+ metadata.gz: 8fe961253cfd9043fec5d23379112770493cca121e7ae185b0728afe98fed68f
4
+ data.tar.gz: 4889e5d8748bc5c60d4e74ee196e935e738fdd843630ceaac28aa9857bb7529d
5
5
  SHA512:
6
- metadata.gz: 83468266128639b7439119bd14099e9d8082a71edd5b738b6321651e44398aa0ccf40dded8f48b46d74469c570e0783982e5bef8ae7250ca4c2a1ca39bae6df6
7
- data.tar.gz: 10b38d91004d40e2c8f71cec7de451e1295b447b592b91fd0ae8f0fc4053108eca59f788740fe44ca4af3eeb358f3337de9a85a2fc4f307d3297dede4fdc603a
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
@@ -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.3)
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
@@ -27,7 +48,9 @@ module ShopifyApiBruv
27
48
  def validate!
28
49
  return if ok?
29
50
 
30
- raise Errors::HttpResponseError, self
51
+ errors = body['errors'] || ''
52
+
53
+ raise Errors::HttpResponseError, errors
31
54
  end
32
55
  end
33
56
  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.3'
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Idjent