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.



17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17103

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def attributes
  @attributes
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def destination
  @destination
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def order_number
  @order_number
end

#originObject (readonly)

Returns the value of attribute origin.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def package
  @package
end

#serviceObject (readonly)

Returns the value of attribute service.



17101
17102
17103
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17119
17120
17121
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17119

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

#to_hashObject



17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17123

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

#to_jsonObject



17115
17116
17117
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17115

def to_json
  JSON.dump(to_hash)
end