shopify_api_bruv 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8119277813ab65392ec1a963097cd264dc4f610c00ae3e31c8cfaeaaf9b735e
4
- data.tar.gz: 834626e70982174fb36b0bd7451e6e6318ea13c213a05d295262039287aea7c3
3
+ metadata.gz: 0c0d6c9a757b1c4164d65adcd704201932875e5451b7fc452206fce010847f16
4
+ data.tar.gz: 5139a1b215e2d4985857577edc2727e398edae28b068bc20744ec31b57052d81
5
5
  SHA512:
6
- metadata.gz: e119e67234a23b633eca37f5370054b951669cd9c9363c0d99d215bbfd288c235ffabda5f8456fb43213222c6910092182717c63ff2f0e93211ecf859ba504d7
7
- data.tar.gz: ff88c2d8b7a888a310cd14594d34ffe26c19506913ee1d91e232da4058bed4b3b42be46a3495f6cce6b096d48fc9f70db705875b289a7d35615316b191ee700f
6
+ metadata.gz: 82222f2e7665f99ea63e8c17a7c0445a01e61504ed37ac4c69aaac93704a576e55a813be22e8f4b89e45d85e66e87eea40e7f141f7b8f205f5380bddc89f7dfd
7
+ data.tar.gz: 19f07ef9290a43606159963d7eef46fc135376f90b9a58aad4e51209aca20950aa37dcea68bdf2bf5e269bffaf251bb0be17450fd771a42556f6057701af440f
data/.env.template CHANGED
@@ -2,6 +2,3 @@ API_DOMAIN="{API_DOMAIN}"
2
2
  API_VERSION="{API_VERSION}"
3
3
  API_ACCESS_TOKEN="{API_ACCESS_TOKEN}"
4
4
  SHOPIFY_API_BRUV_LOGGER_ENABLED="true"
5
- SHOPIFY_API_BRUV_REQUEST_MAX_TRIES="3"
6
- SHOPIFY_API_BRUV_REQUEST_SLEEP_TIMER="4"
7
- SHOPIFY_API_BRUV_REQUEST_MINIMUM_CREDIT_LEFT="4"
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2023-12-10
4
+
5
+ - Adds error handling for http requests
6
+
3
7
  ## [0.3.0] - 2023-12-10
4
8
 
5
- - Refactor resource classes
6
- - Update docs
9
+ - Refactors resource classes
10
+ - Updates docs
7
11
 
8
12
  ## [0.2.7] - 2023-12-09
9
13
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api_bruv (0.3.0)
4
+ shopify_api_bruv (0.3.1)
5
5
  httparty
6
6
  logger
7
7
 
@@ -5,6 +5,13 @@ module ShopifyApiBruv
5
5
  class HttpRequest
6
6
  attr_reader :api, :method, :path, :body, :content_type, :query, :headers
7
7
 
8
+ VALID_METHODS = [
9
+ :get,
10
+ :delete,
11
+ :put,
12
+ :post
13
+ ].freeze
14
+
8
15
  def initialize(api:, method:, path:, body:, content_type:, query: nil, headers:)
9
16
  @api = api
10
17
  @method = method
@@ -14,11 +21,27 @@ module ShopifyApiBruv
14
21
  @query = query
15
22
  @headers = headers
16
23
 
24
+ validate
25
+
17
26
  ShopifyApiBruv.logger(
18
27
  method: :info,
19
28
  message: "Shopify API Request (Method: #{method}):\nPath:\n#{path}\n\nBody:\n#{body}"
20
29
  )
21
30
  end
31
+
32
+ private
33
+
34
+ def validate
35
+ raise Errors::HttpRequestError,
36
+ "Invalid method #{method}, valid methods are: #{VALID_METHODS}" unless VALID_METHODS.include?(method)
37
+
38
+ raise Errors::HttpRequestError,
39
+ 'Content-Type missing' if !body.nil? && content_type.nil?
40
+
41
+ return unless [:put, :post].include?(method)
42
+
43
+ raise Errors::HttpRequestError, "Body is required for method #{method}" if body.nil?
44
+ end
22
45
  end
23
46
  end
24
47
  end
@@ -10,12 +10,12 @@ module ShopifyApiBruv
10
10
  @headers = headers
11
11
  @body = body
12
12
 
13
+ validate
14
+
13
15
  ShopifyApiBruv.logger(
14
16
  method: :info,
15
17
  message: "Shopify API Response (Code: #{code}):\nHeaders:\n#{headers}\n\nBody:\n#{body}"
16
18
  )
17
-
18
- validate
19
19
  end
20
20
 
21
21
  private
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ShopifyApiBruv
4
+ module Errors
5
+ class HttpRequestError < StandardError
6
+ end
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyApiBruv
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Idjent
@@ -127,6 +127,7 @@ files:
127
127
  - lib/shopify_api_bruv/clients/rest/client.rb
128
128
  - lib/shopify_api_bruv/clients/rest/http_response.rb
129
129
  - lib/shopify_api_bruv/errors/http_client_error.rb
130
+ - lib/shopify_api_bruv/errors/http_request_error.rb
130
131
  - lib/shopify_api_bruv/errors/http_response_error.rb
131
132
  - lib/shopify_api_bruv/errors/resource_error.rb
132
133
  - lib/shopify_api_bruv/logger.rb