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 +4 -4
- data/.env.template +0 -3
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +1 -1
- data/lib/shopify_api_bruv/clients/http_request.rb +23 -0
- data/lib/shopify_api_bruv/clients/http_response.rb +2 -2
- data/lib/shopify_api_bruv/errors/http_request_error.rb +8 -0
- data/lib/shopify_api_bruv/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c0d6c9a757b1c4164d65adcd704201932875e5451b7fc452206fce010847f16
|
4
|
+
data.tar.gz: 5139a1b215e2d4985857577edc2727e398edae28b068bc20744ec31b57052d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82222f2e7665f99ea63e8c17a7c0445a01e61504ed37ac4c69aaac93704a576e55a813be22e8f4b89e45d85e66e87eea40e7f141f7b8f205f5380bddc89f7dfd
|
7
|
+
data.tar.gz: 19f07ef9290a43606159963d7eef46fc135376f90b9a58aad4e51209aca20950aa37dcea68bdf2bf5e269bffaf251bb0be17450fd771a42556f6057701af440f
|
data/.env.template
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
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.
|
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
|