Class: ShopifyTheme::APIChecker::APIResult

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_theme/api_checker.rb

Constant Summary collapse

OK =
200
UNAUTHORIZED =
401
SERVER_ERROR_CODES =
(500..599)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/shopify_theme/api_checker.rb', line 13

def accessed_api?
  response.code == OK
end

#api_down?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


17
18
19
# File 'lib/shopify_theme/api_checker.rb', line 17

def cannot_access_api?
  !accessed_api?
end

#invalid_config?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/shopify_theme/api_checker.rb', line 21

def invalid_config?
  response.code == UNAUTHORIZED
end