Class: ShopifyGraphql::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_graphql/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
# File 'lib/shopify_graphql/response.rb', line 6

def initialize(response)
  @raw = response
  @data = response.data
  @extensions = response.extensions
  @errors = response.errors
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/shopify_graphql/response.rb', line 4

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/shopify_graphql/response.rb', line 3

def errors
  @errors
end

#extensionsObject (readonly)

Returns the value of attribute extensions.



3
4
5
# File 'lib/shopify_graphql/response.rb', line 3

def extensions
  @extensions
end

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/shopify_graphql/response.rb', line 3

def raw
  @raw
end

Instance Method Details

#points_leftObject



13
14
15
# File 'lib/shopify_graphql/response.rb', line 13

def points_left
  extensions&.cost&.throttleStatus&.currentlyAvailable
end

#points_limitObject



17
18
19
# File 'lib/shopify_graphql/response.rb', line 17

def points_limit
  extensions&.cost&.throttleStatus&.maximumAvailable
end

#points_maxed?(threshold: 0) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/shopify_graphql/response.rb', line 29

def points_maxed?(threshold: 0)
  points_left < threshold
end

#points_restore_rateObject



21
22
23
# File 'lib/shopify_graphql/response.rb', line 21

def points_restore_rate
  extensions&.cost&.throttleStatus&.restoreRate
end

#query_costObject



25
26
27
# File 'lib/shopify_graphql/response.rb', line 25

def query_cost
  extensions&.cost&.actualQueryCost
end