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
- #check_for_error(response) ⇒ Object
-
#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
26 27 28 |
# File 'lib/pmp/response.rb', line 26 def body self.raw.body end |
#check_for_error(response) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pmp/response.rb', line 14 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 |