Class: EcalClient::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/ecal_client/api/response.rb', line 6

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#errorsObject



22
23
24
# File 'lib/ecal_client/api/response.rb', line 22

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

#paramsObject



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

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

#statusObject



14
15
16
# File 'lib/ecal_client/api/response.rb', line 14

def status
  @response.status.to_i
end

#status_longObject



18
19
20
# File 'lib/ecal_client/api/response.rb', line 18

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

#success?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/ecal_client/api/response.rb', line 10

def success?
  [ 200 ].include? status
end