Class: PMP::Response
- Inherits:
-
Object
- Object
- PMP::Response
- Defined in:
- lib/pmp/response.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#request ⇒ Object
Returns the value of attribute request.
Instance Method Summary collapse
-
#body ⇒ Object
def check_for_error(response) status_code_type = response.status.to_s case status_code_type when “2” # puts “all is well, status: #responseresponse.status” when “4”, “5” raise “Whoops, error back from PMP: #responseresponse.status” else raise “Unrecongized status code: #responseresponse.status” end end.
-
#initialize(raw, request) ⇒ Response
constructor
A new instance of Response.
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
#raw ⇒ Object
Returns the value of attribute raw.
5 6 7 |
# File 'lib/pmp/response.rb', line 5 def raw @raw end |
#request ⇒ Object
Returns the value of attribute request.
5 6 7 |
# File 'lib/pmp/response.rb', line 5 def request @request end |
Instance Method Details
#body ⇒ Object
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 |