Class: Io::Flow::V0::Models::RatecardLaneImportForm

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

Overview

Represents a line in a ratecard lane import file to be used with bulk CSV imports of multiple ratecard lanes across different services in a single import file. This would represent a row in each file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RatecardLaneImportForm

Returns a new instance of RatecardLaneImportForm.



57627
57628
57629
57630
57631
57632
57633
57634
57635
57636
57637
57638
57639
57640
57641
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57627

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:ratecard_owner, :service, :currency, :delivered_duty, :origin, :destination, :shipment_window, :dim_factor, :weight_unit, :distance_unit, :rates], 'RatecardLaneImportForm')
  @ratecard_owner = (x = opts.delete(:ratecard_owner); x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x))
  @service = HttpClient::Preconditions.assert_class('service', opts.delete(:service), String)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x))
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::Zone) ? x : ::Io::Flow::V0::Models::Zone.new(x))
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::Zone) ? x : ::Io::Flow::V0::Models::Zone.new(x))
  @shipment_window = (x = opts.delete(:shipment_window); x.is_a?(::Io::Flow::V0::Models::ShipmentWindow) ? x : ::Io::Flow::V0::Models::ShipmentWindow.new(x))
  @dim_factor = HttpClient::Preconditions.assert_class('dim_factor', HttpClient::Helper.to_big_decimal(opts.delete(:dim_factor)), BigDecimal)
  @weight_unit = (x = opts.delete(:weight_unit); x.is_a?(::Io::Flow::V0::Models::UnitOfMeasurement) ? x : ::Io::Flow::V0::Models::UnitOfMeasurement.apply(x))
  @distance_unit = (x = opts.delete(:distance_unit); x.is_a?(::Io::Flow::V0::Models::UnitOfMeasurement) ? x : ::Io::Flow::V0::Models::UnitOfMeasurement.apply(x))
  @rates = HttpClient::Preconditions.assert_class('rates', opts.delete(:rates), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::RatecardRateForm) ? x : ::Io::Flow::V0::Models::RatecardRateForm.new(x)) }
end

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def currency
  @currency
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def destination
  @destination
end

#dim_factorObject (readonly)

Returns the value of attribute dim_factor.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def dim_factor
  @dim_factor
end

#distance_unitObject (readonly)

Returns the value of attribute distance_unit.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def distance_unit
  @distance_unit
end

#originObject (readonly)

Returns the value of attribute origin.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def origin
  @origin
end

#ratecard_ownerObject (readonly)

Returns the value of attribute ratecard_owner.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def ratecard_owner
  @ratecard_owner
end

#ratesObject (readonly)

Returns the value of attribute rates.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def rates
  @rates
end

#serviceObject (readonly)

Returns the value of attribute service.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def service
  @service
end

#shipment_windowObject (readonly)

Returns the value of attribute shipment_window.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def shipment_window
  @shipment_window
end

#weight_unitObject (readonly)

Returns the value of attribute weight_unit.



57625
57626
57627
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57625

def weight_unit
  @weight_unit
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



57647
57648
57649
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57647

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

#to_hashObject



57651
57652
57653
57654
57655
57656
57657
57658
57659
57660
57661
57662
57663
57664
57665
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57651

def to_hash
  {
    :ratecard_owner => ratecard_owner.value,
    :service => service,
    :currency => currency,
    :delivered_duty => delivered_duty.value,
    :origin => origin.to_hash,
    :destination => destination.to_hash,
    :shipment_window => shipment_window.to_hash,
    :dim_factor => dim_factor.to_f.to_s,
    :weight_unit => weight_unit.value,
    :distance_unit => distance_unit.value,
    :rates => rates.map { |o| o.to_hash }
  }
end

#to_jsonObject



57643
57644
57645
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57643

def to_json
  JSON.dump(to_hash)
end