Class: ShopifyApiBruv::Resources::Rest::ResourceResponse

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

Constant Summary collapse

CREDIT_LEFT_THRESHOLD =
ENV.fetch('SHOPIFY_API_BRUV_RESOURCE_REST_CREDIT_LEFT_THRESHOLD', 8).to_i

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, headers:) ⇒ ResourceResponse



12
13
14
15
16
# File 'lib/shopify_api_bruv/resources/rest/resource_response.rb', line 12

def initialize(body:, headers:)
  @data = body

  parse_api_call_limit(headers:)
end

Instance Attribute Details

#credit_leftObject (readonly)

Returns the value of attribute credit_left.



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

def credit_left
  @credit_left
end

#credit_limitObject (readonly)

Returns the value of attribute credit_limit.



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

def credit_limit
  @credit_limit
end

#credit_usedObject (readonly)

Returns the value of attribute credit_used.



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

def credit_used
  @credit_used
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

Instance Method Details

#as_open_structObject



18
19
20
21
22
# File 'lib/shopify_api_bruv/resources/rest/resource_response.rb', line 18

def as_open_struct
  # rubocop:disable Style/OpenStructUse
  JSON.parse(data.to_json, object_class: OpenStruct)
  # rubocop:enable Style/OpenStructUse
end

#credit_left?Boolean



24
25
26
# File 'lib/shopify_api_bruv/resources/rest/resource_response.rb', line 24

def credit_left?
  credit_left > CREDIT_LEFT_THRESHOLD
end