Class: Io::Flow::V0::Models::ShopifyLocalCartMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyLocalCartMetadata



49412
49413
49414
49415
49416
49417
49418
49419
49420
49421
49422
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49412

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:total_price, :promotions, :subtotal], 'ShopifyLocalCartMetadata')
  @total_price = (x = opts.delete(:total_price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @promotions = (x = opts.delete(:promotions); x.is_a?(::Io::Flow::V0::Models::Promotions) ? x : ::Io::Flow::V0::Models::Promotions.new(x))
  @rules = (x = opts.delete(:rules); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderRulesSummary) ? x : ::Io::Flow::V0::Models::OrderRulesSummary.new(x)))
  @subtotal = (x = opts.delete(:subtotal); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @vat = (x = opts.delete(:vat); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
  @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)))
end

Instance Attribute Details

#discountObject (readonly)

Returns the value of attribute discount.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def duty
  @duty
end

#promotionsObject (readonly)

Returns the value of attribute promotions.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def promotions
  @promotions
end

#rulesObject (readonly)

Returns the value of attribute rules.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def rules
  @rules
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def subtotal
  @subtotal
end

#total_priceObject (readonly)

Returns the value of attribute total_price.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def total_price
  @total_price
end

#vatObject (readonly)

Returns the value of attribute vat.



49410
49411
49412
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49410

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



49428
49429
49430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49428

def copy(incoming={})
  .new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



49432
49433
49434
49435
49436
49437
49438
49439
49440
49441
49442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49432

def to_hash
  {
    :total_price => total_price.to_hash,
    :promotions => promotions.to_hash,
    :rules => rules.nil? ? nil : rules.to_hash,
    :subtotal => subtotal.to_hash,
    :vat => vat.nil? ? nil : vat.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash,
    :discount => discount.nil? ? nil : discount.to_hash
  }
end

#to_jsonObject



49424
49425
49426
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49424

def to_json
  JSON.dump(to_hash)
end