Class: ShopifyApiBruv::Clients::HttpRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_api_bruv/clients/http_request.rb

Constant Summary collapse

VALID_METHODS =
[
  :get,
  :delete,
  :put,
  :post
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api:, method:, path:, body:, content_type:, query: nil, headers:) ⇒ HttpRequest

Returns a new instance of HttpRequest.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 15

def initialize(api:, method:, path:, body:, content_type:, query: nil, headers:)
  @api = api
  @method = method
  @path = path
  @body = body.is_a?(Hash) ? body.to_json : body
  @content_type = content_type
  @query = query
  @headers = headers

  validate

  ShopifyApiBruv.logger(
    method: :info,
    message: "Shopify API Request (Method: #{method}):\nPath:\n#{path}\n\nBody:\n#{body}"
  )
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def api
  @api
end

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def body
  @body
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def content_type
  @content_type
end

#headersObject (readonly)

Returns the value of attribute headers.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def headers
  @headers
end

#methodObject (readonly)

Returns the value of attribute method.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def path
  @path
end

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/shopify_api_bruv/clients/http_request.rb', line 6

def query
  @query
end