Module: ShopifyAPI::Limits::ClassMethods
- Defined in:
- lib/shopify_api/limits.rb
Constant Summary collapse
- CREDIT_LIMIT_HEADER_PARAM =
Takes form <call count>/<bucket size> See help.shopify.com/en/api/getting-started/api-call-limit Eg: 2/40
{ shop: 'X-Shopify-Shop-Api-Call-Limit', }
Instance Method Summary collapse
-
#credit_left ⇒ Integer
(also: #available_calls)
How many more API calls can I make?.
-
#credit_limit(scope = :shop) ⇒ Integer
(also: #call_limit)
How many total API calls can I make? NOTE: subtracting 1 from credit_limit because I think ShopifyAPI cuts off at 299 or shop limits.
-
#credit_maxed? ⇒ Boolean
(also: #maxed?)
Have I reached my API call limit?.
-
#credit_used(scope = :shop) ⇒ Integer
(also: #call_count)
How many API calls have I made?.
- #response ⇒ HTTPResonse
Instance Method Details
#credit_left ⇒ Integer Also known as: available_calls
How many more API calls can I make?
21 22 23 |
# File 'lib/shopify_api/limits.rb', line 21 def credit_left credit_limit(:shop) - credit_used(:shop) end |
#credit_limit(scope = :shop) ⇒ Integer Also known as: call_limit
How many total API calls can I make? NOTE: subtracting 1 from credit_limit because I think ShopifyAPI cuts off at 299 or shop limits.
41 42 43 |
# File 'lib/shopify_api/limits.rb', line 41 def credit_limit(scope = :shop) api_credit_limit_param(scope).pop.to_i - 1 end |
#credit_maxed? ⇒ Boolean Also known as: maxed?
Have I reached my API call limit?
30 31 32 |
# File 'lib/shopify_api/limits.rb', line 30 def credit_maxed? credit_left <= 0 end |
#credit_used(scope = :shop) ⇒ Integer Also known as: call_count
How many API calls have I made?
51 52 53 |
# File 'lib/shopify_api/limits.rb', line 51 def credit_used(scope = :shop) api_credit_limit_param(scope).shift.to_i end |
#response ⇒ HTTPResonse
59 60 61 62 |
# File 'lib/shopify_api/limits.rb', line 59 def response Shop.current unless ShopifyAPI::Base.connection.response ShopifyAPI::Base.connection.response end |