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.



15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15010

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:service, :delivered_duty, :destination, :origin, :packages], 'ShippingLabelForm')
  @service = HttpClient::Preconditions.assert_class('service', opts.delete(:service), String)
  @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x))
  @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))
  @packages = HttpClient::Preconditions.assert_class('packages', opts.delete(:packages), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ShippingLabelPackage) ? x : ::Io::Flow::V0::Models::ShippingLabelPackage.new(x)) }
  @insurance = (x = opts.delete(:insurance); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)))
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
end

Instance Attribute Details

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def destination
  @destination
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def insurance
  @insurance
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def order_number
  @order_number
end

#originObject (readonly)

Returns the value of attribute origin.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def origin
  @origin
end

#packagesObject (readonly)

Returns the value of attribute packages.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def packages
  @packages
end

#serviceObject (readonly)

Returns the value of attribute service.



15008
15009
15010
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15008

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



15026
15027
15028
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15026

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

#to_hashObject



15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15030

def to_hash
  {
    :service => service,
    :delivered_duty => delivered_duty.value,
    :destination => destination.to_hash,
    :origin => origin.to_hash,
    :packages => packages.map { |o| o.to_hash },
    :insurance => insurance.nil? ? nil : insurance.to_hash,
    :order_number => order_number
  }
end

#to_jsonObject



15022
15023
15024
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15022

def to_json
  JSON.dump(to_hash)
end