Class: Squake::Model::Price

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/squake/model/price.rb

Class Method Summary collapse

Class Method Details

.from_api_response(response_body) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/squake/model/price.rb', line 17

def self.from_api_response(response_body)
  Squake::Model::Price.new(
    id: response_body.fetch(:id),
    product: response_body.fetch(:product),
    unit_amount: BigDecimal(response_body.fetch(:unit_amount).to_s),
    valid_from: Date.parse(response_body.fetch(:valid_from)),
    carbon_unit: response_body.fetch(:carbon_unit),
    currency: response_body.fetch(:currency),
  )
end