Class: EcalClient::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/ecal_client/api/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



4
5
6
# File 'lib/ecal_client/api/response.rb', line 4

def initialize(response)
  @response = response
end

Instance Method Details

#errorsObject



20
21
22
# File 'lib/ecal_client/api/response.rb', line 20

def errors
  @error ||= params['errors']
end

#paramsObject



24
25
26
27
28
29
30
31
# File 'lib/ecal_client/api/response.rb', line 24

def params
  @params ||= begin
                JSON.parse(@response.body)
              rescue => e
                puts e.to_s if EcalClient.configuration.options[:verbose]
              end
  @params ||= {}
end

#statusObject



12
13
14
# File 'lib/ecal_client/api/response.rb', line 12

def status
  @response.status.to_i
end

#status_longObject



16
17
18
# File 'lib/ecal_client/api/response.rb', line 16

def status_long
  @status_log ||= params['statusLong']
end

#success?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/ecal_client/api/response.rb', line 8

def success?
  [ 200 ].include? status
end