Class: Squake::Model::Purchase

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

Class Method Summary collapse

Class Method Details

.from_api_response(response_body) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/squake/model/purchase.rb', line 22

def self.from_api_response(response_body)
  Squake::Model::Purchase.new(
    id: response_body.fetch(:id),
    files: response_body.fetch(:files),
    payment_method: response_body.fetch(:payment_method),
    state: response_body.fetch(:state),
    metadata: response_body.fetch(:metadata),
    checkout_page: response_body.fetch(:checkout_page, nil),
    carbon_quantity: BigDecimal(response_body.fetch(:carbon_quantity).to_s),
    carbon_unit: response_body.fetch(:carbon_unit),
    total: response_body.fetch(:total),
    currency: response_body.fetch(:currency),
    external_reference: response_body.fetch(:external_reference, nil),
  )
end