Method: Uni::Response#initialize

Defined in:
lib/uni-sdk/response.rb

#initialize(response) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/uni-sdk/response.rb', line 7

def initialize(response)
    @raw = response
    @status = response.status
    @headers = response.headers
    @body = response.body
    @request_id = @headers[@@request_id_header_key]
    @code = @body['code']
    @message = @body['message']
    @data = @body['data']

    if @status < 200 || @status >= 300 || @code != '0'
      raise UniError.new(@message || response.reason_phrase, self)
    end
end