class Io::Flow::V0::Models::ShippingLane

Attributes

centers[R]
direction[R]
id[R]
preference[R]
query[R]
region[R]
shipping_configuration[R]
strategy[R]
tiers[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 66706
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :shipping_configuration, :region, :centers, :tiers, :query], 'ShippingLane')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @shipping_configuration = (x = opts.delete(:shipping_configuration); x.is_a?(::Io::Flow::V0::Models::ShippingConfigurationReference) ? x : ::Io::Flow::V0::Models::ShippingConfigurationReference.new(x))
  @region = HttpClient::Preconditions.assert_class('region', opts.delete(:region), String)
  @centers = HttpClient::Preconditions.assert_class('centers', opts.delete(:centers), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ExpandableCenter) ? x : ::Io::Flow::V0::Models::ExpandableCenter.from_json(x)) }
  @tiers = HttpClient::Preconditions.assert_class('tiers', opts.delete(:tiers), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Tier) ? x : ::Io::Flow::V0::Models::Tier.new(x)) }
  @query = (x = opts.delete(:query); x.is_a?(::Io::Flow::V0::Models::Query) ? x : ::Io::Flow::V0::Models::Query.new(x))
  @strategy = (x = (x = opts.delete(:strategy); x.nil? ? "oldest" : x); x.is_a?(::Io::Flow::V0::Models::LaneStrategy) ? x : ::Io::Flow::V0::Models::LaneStrategy.apply(x))
  @direction = (x = opts.delete(:direction); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LaneDirection) ? x : ::Io::Flow::V0::Models::LaneDirection.apply(x)))
  @preference = (x = opts.delete(:preference); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LanePreselectPreference) ? x : ::Io::Flow::V0::Models::LanePreselectPreference.apply(x)))
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 66724
def copy(incoming={})
  ShippingLane.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 66728
def to_hash
  {
    :id => id,
    :shipping_configuration => shipping_configuration.to_hash,
    :region => region,
    :centers => centers.map { |o| o.to_hash },
    :tiers => tiers.map { |o| o.to_hash },
    :query => query.to_hash,
    :strategy => strategy.value,
    :direction => direction.nil? ? nil : direction.value,
    :preference => preference.nil? ? nil : preference.value
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 66720
def to_json
  JSON.dump(to_hash)
end