Class: ProcessOut::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resp) ⇒ Response

Returns a new instance of Response.



14
15
16
17
18
19
# File 'lib/processout/networking/response.rb', line 14

def initialize(resp)
  @resp = resp
  @status = resp.code.to_i
  @body = JSON.parse(resp.body)
  self.check
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



12
13
14
# File 'lib/processout/networking/response.rb', line 12

def body
  @body
end

Instance Method Details

#codeObject

Code returns the error code contained in the response, if any



30
31
32
33
34
35
# File 'lib/processout/networking/response.rb', line 30

def code
  if @body.include? "error_type"
    return @body["error_type"]
  end
  ""
end

#messageObject

Message returns the error message contained in the response, if any



38
39
40
41
42
43
# File 'lib/processout/networking/response.rb', line 38

def message
  if @body.include? "message"
    return @body["message"]
  end
  ""
end

#successObject

Success returns whether or not the response returned a successful message



22
23
24
25
26
27
# File 'lib/processout/networking/response.rb', line 22

def success
  if @body.include? "success"
    return @body["success"]
  end
  false
end