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.



31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31349

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)))
  @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))
  @shipment_recipient = (x = opts.delete(:shipment_recipient); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShipmentRecipient) ? x : ::Io::Flow::V0::Models::ShipmentRecipient.apply(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def attributes
  @attributes
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def destination
  @destination
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def order_number
  @order_number
end

#originObject (readonly)

Returns the value of attribute origin.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def package
  @package
end

#serviceObject (readonly)

Returns the value of attribute service.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def service
  @service
end

#shipment_recipientObject (readonly)

Returns the value of attribute shipment_recipient.



31347
31348
31349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31347

def shipment_recipient
  @shipment_recipient
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



31366
31367
31368
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31366

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

#to_hashObject



31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31370

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,
    :order_number => order_number,
    :service => service,
    :shipment_recipient => shipment_recipient.nil? ? nil : shipment_recipient.value
  }
end

#to_jsonObject



31362
31363
31364
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31362

def to_json
  JSON.dump(to_hash)
end