Class: ShopifyApiBruv::Resources::Rest::ResourceResponse
- Inherits:
-
Object
- Object
- ShopifyApiBruv::Resources::Rest::ResourceResponse
- 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
-
#credit_left ⇒ Object
readonly
Returns the value of attribute credit_left.
-
#credit_limit ⇒ Object
readonly
Returns the value of attribute credit_limit.
-
#credit_used ⇒ Object
readonly
Returns the value of attribute credit_used.
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #as_open_struct ⇒ Object
- #credit_left? ⇒ Boolean
-
#initialize(body:, headers:) ⇒ ResourceResponse
constructor
A new instance of ResourceResponse.
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_left ⇒ Object (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_limit ⇒ Object (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_used ⇒ Object (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 |
#data ⇒ Object
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_struct ⇒ Object
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 |