Class: Squake::Calculation
- Inherits:
-
Object
- Object
- Squake::Calculation
- Extended by:
- T::Sig
- Defined in:
- lib/squake/calculation.rb
Constant Summary collapse
- ENDPOINT =
T.let('/v2/calculations', String)
Class Method Summary collapse
Class Method Details
.create(client:, items:, carbon_unit: 'gram', expand: []) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/squake/calculation.rb', line 19 def self.create(client:, items:, carbon_unit: 'gram', expand: []) result = client.call( path: ENDPOINT, method: :post, params: { items: items.map(&:serialize), carbon_unit: carbon_unit, expand: , }, ) raise Squake::APIError.new(response: result) unless result.success? Squake::Model::Carbon.from_api_response( T.cast(result.body, T::Hash[Symbol, T.untyped]), ) end |