Class: Io::Flow::V0::Models::ShippingLabelForm

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingLabelForm

Returns a new instance of ShippingLabelForm.



26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26721

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:destination, :origin, :package], 'ShippingLabelForm')
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @package = (x = opts.delete(:package); x.is_a?(::Io::Flow::V0::Models::ShippingLabelPackage) ? x : ::Io::Flow::V0::Models::ShippingLabelPackage.new(x))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
  @delivered_duty = (x = opts.delete(:delivered_duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)))
  @direction = (x = opts.delete(:direction); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Direction) ? x : ::Io::Flow::V0::Models::Direction.apply(x)))
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @service = (x = opts.delete(:service); x.nil? ? nil : HttpClient::Preconditions.assert_class('service', x, String))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def attributes
  @attributes
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def destination
  @destination
end

#directionObject (readonly)

Returns the value of attribute direction.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def direction
  @direction
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def order_number
  @order_number
end

#originObject (readonly)

Returns the value of attribute origin.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def package
  @package
end

#serviceObject (readonly)

Returns the value of attribute service.



26719
26720
26721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26719

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26738
26739
26740
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26738

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

#to_hashObject



26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26742

def to_hash
  {
    :destination => destination.to_hash,
    :origin => origin.to_hash,
    :package => package.to_hash,
    :attributes => attributes.nil? ? nil : attributes,
    :delivered_duty => delivered_duty.nil? ? nil : delivered_duty.value,
    :direction => direction.nil? ? nil : direction.value,
    :order_number => order_number,
    :service => service
  }
end

#to_jsonObject



26734
26735
26736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26734

def to_json
  JSON.dump(to_hash)
end