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



43806
43807
43808
43809
43810
43811
43812
43813
43814
43815
43816
43817
43818
43819
43820
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43806

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.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def currency
  @currency
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def destination
  @destination
end

#dim_factorObject (readonly)

Returns the value of attribute dim_factor.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def dim_factor
  @dim_factor
end

#distance_unitObject (readonly)

Returns the value of attribute distance_unit.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def distance_unit
  @distance_unit
end

#originObject (readonly)

Returns the value of attribute origin.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def origin
  @origin
end

#ratecard_ownerObject (readonly)

Returns the value of attribute ratecard_owner.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def ratecard_owner
  @ratecard_owner
end

#ratesObject (readonly)

Returns the value of attribute rates.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def rates
  @rates
end

#serviceObject (readonly)

Returns the value of attribute service.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def service
  @service
end

#shipment_windowObject (readonly)

Returns the value of attribute shipment_window.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def shipment_window
  @shipment_window
end

#weight_unitObject (readonly)

Returns the value of attribute weight_unit.



43804
43805
43806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43804

def weight_unit
  @weight_unit
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



43826
43827
43828
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43826

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

#to_hashObject



43830
43831
43832
43833
43834
43835
43836
43837
43838
43839
43840
43841
43842
43843
43844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43830

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



43822
43823
43824
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43822

def to_json
  JSON.dump(to_hash)
end