Class: Exa::Responses::CostDollars

Inherits:
T::Struct
  • Object
show all
Defined in:
lib/exa/responses/answer_response.rb

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/exa/responses/answer_response.rb', line 51

def self.from_hash(hash)
  return nil unless hash
  sym = Helpers.symbolize_keys(hash)
  new(
    total: sym[:total]&.to_f,
    break_down: sym[:breakDown]&.map { CostBreakdown.from_hash(_1) },
    per_request_prices: sym[:perRequestPrices]&.transform_keys(&:to_sym)
  )
end