Class: Io::Flow::V0::Models::ShippingLabelForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ShippingLabelForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#insurance ⇒ Object
readonly
Returns the value of attribute insurance.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ShippingLabelForm
constructor
A new instance of ShippingLabelForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
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_duty ⇒ Object (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 |
#destination ⇒ Object (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 |
#insurance ⇒ Object (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 |
#origin ⇒ Object (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 |
#packages ⇒ Object (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 |
#service ⇒ Object (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_hash ⇒ Object
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_json ⇒ Object
13346 13347 13348 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13346 def to_json JSON.dump(to_hash) end |