Class: PecCalcClient::Response

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

Overview

Response from api server

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
9
# File 'lib/pec_calc_client/response.rb', line 6

def initialize(response)
  @response = response
  fail BadResponse, 'Respons Code not 200' if @response.code != '200'
end

Instance Method Details

#to_hashObject



11
12
13
# File 'lib/pec_calc_client/response.rb', line 11

def to_hash
  JSON.parse @response.body if @response.body.to_s != ''
end