Class: PMP::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, request) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
# File 'lib/pmp/response.rb', line 7

def initialize(raw, request)
  @raw     = raw
  @request = request

  # check_for_error(raw)
end

Instance Attribute Details

#rawObject

Returns the value of attribute raw.



5
6
7
# File 'lib/pmp/response.rb', line 5

def raw
  @raw
end

#requestObject

Returns the value of attribute request.



5
6
7
# File 'lib/pmp/response.rb', line 5

def request
  @request
end

Instance Method Details

#bodyObject

def check_for_error(response)

status_code_type = response.status.to_s[0]
case status_code_type
when "2"
  # puts "all is well, status: #{response.status}"
when "4", "5"
  raise "Whoops, error back from PMP: #{response.status}"
else
  raise "Unrecongized status code: #{response.status}"
end

end



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

def body
  self.raw.body
end