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.



13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13335

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)))
end

Instance Attribute Details

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



13333
13334
13335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13333

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



13333
13334
13335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13333

def destination
  @destination
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



13333
13334
13335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13333

def insurance
  @insurance
end

#originObject (readonly)

Returns the value of attribute origin.



13333
13334
13335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13333

def origin
  @origin
end

#packagesObject (readonly)

Returns the value of attribute packages.



13333
13334
13335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13333

def packages
  @packages
end

#serviceObject (readonly)

Returns the value of attribute service.



13333
13334
13335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13333

def service
  @service
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13350
13351
13352
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13350

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

#to_hashObject



13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13354

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
  }
end

#to_jsonObject



13346
13347
13348
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13346

def to_json
  JSON.dump(to_hash)
end