Class: Geti::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
# File 'lib/geti/response.rb', line 6

def initialize(response)
  @validation    = OpenStruct.new(response[:response][:validation_message])
  @authorization = OpenStruct.new(response[:response][:authorization_message])
  @exception     = OpenStruct.new(response[:response][:exception])
end

Instance Attribute Details

#authorizationObject (readonly)

Returns the value of attribute authorization.



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

def authorization
  @authorization
end

#exceptionObject (readonly)

Returns the value of attribute exception.



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

def exception
  @exception
end

#validationObject (readonly)

Returns the value of attribute validation.



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

def validation
  @validation
end

Instance Method Details

#errorsObject



12
13
14
15
16
17
18
19
# File 'lib/geti/response.rb', line 12

def errors
  err = []
  Array(@validation.validation_error).each do |e|
    err << e[:message]
  end
  err << @exception.message
  err.compact
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/geti/response.rb', line 21

def success?
  validation.result == "Passed"
end