Class: Decommas::Response::PriceService

Inherits:
Base
  • Object
show all
Defined in:
lib/decommas/response/price_service.rb

Constant Summary

Constants inherited from Base

Base::THROTTLED_RESPONSES, Base::VALID_RESPONSES

Instance Attribute Summary

Attributes inherited from Base

#code, #data, #message

Instance Method Summary collapse

Methods inherited from Base

#success?, #throttled?

Constructor Details

#initialize(response) ⇒ PriceService

Returns a new instance of PriceService.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/decommas/response/price_service.rb', line 4

def initialize(response)
  # Workaround for 429 response that returns text/html content-type for some reason
  response_data = if response.parsed_response.kind_of?(String)
    JSON.parse(response.parsed_response)
  else
    response.parsed_response
  end
  @code = response.code
  @data = response_data
  @message = response_data["message"] unless success?
end