Class: Squake::Model::Price
- Inherits:
-
T::Struct
- Object
- T::Struct
- Squake::Model::Price
- 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 27 28 |
# File 'lib/squake/model/price.rb', line 17 def self.from_api_response(response_body) product = response_body.fetch(:price, {}) Squake::Model::Price.new( id: product.fetch(:id), product: product.fetch(:product), unit_amount: product.fetch(:unit_amount).to_d, valid_from: Date.parse(product.fetch(:valid_from, nil)), carbon_unit: product.fetch(:carbon_unit), currency: product.fetch(:currency), ) end |