Class: Io::Flow::V0::Models::TaxDutyQuoteSimpleShippingForm

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

Overview

Shipping revenue paid by the consumer for a single shipping charge. If a shipping revenue line is not provided for any ship_from location, it will be assumed no shipping was collected for shipments from this location.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TaxDutyQuoteSimpleShippingForm

Returns a new instance of TaxDutyQuoteSimpleShippingForm.



65120
65121
65122
65123
65124
65125
65126
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65120

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price], 'TaxDutyQuoteSimpleShippingForm')
  @price = HttpClient::Preconditions.assert_class('price', HttpClient::Helper.to_big_decimal(opts.delete(:price)), BigDecimal)
  @includes = HttpClient::Preconditions.assert_class('includes', (x = opts.delete(:includes); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LevyInclusion) ? x : ::Io::Flow::V0::Models::LevyInclusion.apply(x)) }
  @ship_from = (x = opts.delete(:ship_from); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::StreetAddress) ? x : ::Io::Flow::V0::Models::StreetAddress.new(x)))
end

Instance Attribute Details

#includesObject (readonly)

Returns the value of attribute includes.



65118
65119
65120
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65118

def includes
  @includes
end

#priceObject (readonly)

Returns the value of attribute price.



65118
65119
65120
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65118

def price
  @price
end

#ship_fromObject (readonly)

Returns the value of attribute ship_from.



65118
65119
65120
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65118

def ship_from
  @ship_from
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



65132
65133
65134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65132

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

#to_hashObject



65136
65137
65138
65139
65140
65141
65142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65136

def to_hash
  {
    :price => price.to_f.to_s,
    :includes => includes.map { |o| o.value },
    :ship_from => ship_from.nil? ? nil : ship_from.to_hash
  }
end

#to_jsonObject



65128
65129
65130
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65128

def to_json
  JSON.dump(to_hash)
end