Class: HaveAPI::Client::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/client/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action, response) ⇒ Response



4
5
6
7
# File 'lib/haveapi/client/response.rb', line 4

def initialize(action, response)
  @action = action
  @response = response
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



2
3
4
# File 'lib/haveapi/client/response.rb', line 2

def action
  @action
end

Instance Method Details

#errorsObject



30
31
32
# File 'lib/haveapi/client/response.rb', line 30

def errors
  @response[:errors]
end

#failed?Boolean



13
14
15
# File 'lib/haveapi/client/response.rb', line 13

def failed?
  !ok?
end

#messageObject



26
27
28
# File 'lib/haveapi/client/response.rb', line 26

def message
  @response[:message]
end

#ok?Boolean



9
10
11
# File 'lib/haveapi/client/response.rb', line 9

def ok?
  @response[:status]
end

#responseObject



17
18
19
20
21
22
23
24
# File 'lib/haveapi/client/response.rb', line 17

def response
  case @action.layout.to_sym
    when :object, :list
      @response[:response][@action.namespace(:output).to_sym]
    else
      @response[:response]
  end
end