class Fondy::BaseResponse
Public Class Methods
new(http_response)
click to toggle source
# File lib/fondy/base_response.rb, line 4 def initialize(http_response) @http_response = http_response end
Public Instance Methods
error?()
click to toggle source
# File lib/fondy/base_response.rb, line 12 def error? !success? end
error_code()
click to toggle source
# File lib/fondy/base_response.rb, line 16 def error_code raise NotImplementedError end
error_message()
click to toggle source
# File lib/fondy/base_response.rb, line 20 def error_message raise NotImplementedError end
success?()
click to toggle source
# File lib/fondy/base_response.rb, line 8 def success? raise NotImplementedError end
Private Instance Methods
json_body()
click to toggle source
# File lib/fondy/base_response.rb, line 30 def json_body @json_body ||= begin JSON.parse(@http_response.body, symbolize_names: true) rescue raise Fondy::InvalidResponseError, 'Invalid response' end end
response()
click to toggle source
# File lib/fondy/base_response.rb, line 26 def response @response ||= json_body[:response] || raise(Fondy::Error, 'Invalid response') end