Class: ShopifyTheme::APIChecker::APIResult
- Inherits:
-
Object
- Object
- ShopifyTheme::APIChecker::APIResult
- Defined in:
- lib/shopify_theme/api_checker.rb
Constant Summary collapse
- OK =
200
- UNAUTHORIZED =
401
- SERVER_ERROR_CODES =
(500..599)
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #accessed_api? ⇒ Boolean
- #api_down? ⇒ Boolean
- #cannot_access_api? ⇒ Boolean
-
#initialize(http_response) ⇒ APIResult
constructor
A new instance of APIResult.
- #invalid_config? ⇒ Boolean
Constructor Details
#initialize(http_response) ⇒ APIResult
Returns a new instance of APIResult.
9 10 11 |
# File 'lib/shopify_theme/api_checker.rb', line 9 def initialize(http_response) @response = http_response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
8 9 10 |
# File 'lib/shopify_theme/api_checker.rb', line 8 def response @response end |
Instance Method Details
#accessed_api? ⇒ Boolean
13 14 15 |
# File 'lib/shopify_theme/api_checker.rb', line 13 def accessed_api? response.code == OK end |
#api_down? ⇒ Boolean
25 26 27 |
# File 'lib/shopify_theme/api_checker.rb', line 25 def api_down? SERVER_ERROR_CODES.include?(response.code) end |
#cannot_access_api? ⇒ Boolean
17 18 19 |
# File 'lib/shopify_theme/api_checker.rb', line 17 def cannot_access_api? !accessed_api? end |
#invalid_config? ⇒ Boolean
21 22 23 |
# File 'lib/shopify_theme/api_checker.rb', line 21 def invalid_config? response.code == UNAUTHORIZED end |