Class: ShopifyApiBruv::Resources::Rest::Resource

Inherits:
Base
  • Object
show all
Defined in:
lib/shopify_api_bruv/resources/rest/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call

Constructor Details

#initialize(config:, method:, path:, body: nil, query: nil) ⇒ Resource

Returns a new instance of Resource.



10
11
12
13
14
15
16
17
18
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 10

def initialize(config:, method:, path:, body: nil, query: nil)
  @client = Clients::Rest::Client.new(config:)
  @method = method
  @path = path
  @body = body
  @query = query

  validate
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 7

def body
  @body
end

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 7

def client
  @client
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 7

def method
  @method
end

#paginationObject

Returns the value of attribute pagination.



8
9
10
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 8

def pagination
  @pagination
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 7

def path
  @path
end

#queryObject

Returns the value of attribute query.



8
9
10
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 8

def query
  @query
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
# File 'lib/shopify_api_bruv/resources/rest/resource.rb', line 20

def call
  response = client.public_send(method, path:, body:, query:)

  pagination = Pagination.new(resource: self, page_info: response.page_info)
  @pagination = pagination if pagination.page_exists?

  ResourceResponse.new(body: response.body, headers: response.headers)
end