Class: CapitalOnTap::Response

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capital_on_tap/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



11
12
13
# File 'lib/capital_on_tap/response.rb', line 11

def initialize(http_response)
  @http_response = http_response
end

Instance Method Details

#errorObject



15
16
17
# File 'lib/capital_on_tap/response.rb', line 15

def error
  @http_response.body&.dig(:errorMessage) || @http_response.body&.dig(:error)
end

#invalid_token?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/capital_on_tap/response.rb', line 23

def invalid_token?
  auth_failure = @http_response.headers&.dig('www-authenticate')

  return false unless auth_failure

  auth_failure.match?('invalid_token')
end

#metadataObject



19
20
21
# File 'lib/capital_on_tap/response.rb', line 19

def 
  @http_response.body&.dig(:metaData)
end