Method: PostageApp::Response#initialize

Defined in:
lib/postageapp/response.rb

#initialize(http_response) ⇒ Response

Takes in Net::HTTPResponse object as the attribute. If something goes wrong Response will be thought of as failed



20
21
22
23
24
25
26
27
28
# File 'lib/postageapp/response.rb', line 20

def initialize(http_response)
  hash = JSON::parse(http_response.body)
  @status   = hash['response']['status']
  @uid      = hash['response']['uid']
  @message  = hash['response']['message']
  @data     = hash['data']
rescue
  @status   = 'fail'
end