Class: Io::Flow::V0::Models::ConsumerInvoiceLineShippingForm

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

Instance Attribute Summary collapse

Attributes inherited from ConsumerInvoiceLineForm

#discriminator

Instance Method Summary collapse

Methods inherited from ConsumerInvoiceLineForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ ConsumerInvoiceLineShippingForm

Returns a new instance of ConsumerInvoiceLineShippingForm.



33676
33677
33678
33679
33680
33681
33682
33683
33684
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33676

def initialize(incoming={})
  super(:discriminator => ConsumerInvoiceLineForm::Types::CONSUMER_INVOICE_LINE_SHIPPING_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price], 'ConsumerInvoiceLineShippingForm')
  @price = HttpClient::Preconditions.assert_class('price', HttpClient::Helper.to_big_decimal(opts.delete(:price)), BigDecimal)
  @discount = (x = opts.delete(:discount); x.nil? ? nil : HttpClient::Preconditions.assert_class('discount', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLevyForm) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLevyForm.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ConsumerInvoiceLevyForm) ? x : ::Io::Flow::V0::Models::ConsumerInvoiceLevyForm.new(x)))
end

Instance Attribute Details

#discountObject (readonly)

Returns the value of attribute discount.



33674
33675
33676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33674

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



33674
33675
33676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33674

def duty
  @duty
end

#priceObject (readonly)

Returns the value of attribute price.



33674
33675
33676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33674

def price
  @price
end

#taxObject (readonly)

Returns the value of attribute tax.



33674
33675
33676
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33674

def tax
  @tax
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33690
33691
33692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33690

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

#subtype_to_hashObject



33694
33695
33696
33697
33698
33699
33700
33701
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33694

def subtype_to_hash
  {
    :price => price.to_f.to_s,
    :discount => discount.to_f.to_s,
    :tax => tax.nil? ? nil : tax.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash
  }
end

#to_jsonObject



33686
33687
33688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33686

def to_json
  JSON.dump(to_hash)
end