Class: Io::Flow::V0::Models::ShippingLabelPackage

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Describes a package to be shipped, including dimensions and items included

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingLabelPackage

Returns a new instance of ShippingLabelPackage.



26762
26763
26764
26765
26766
26767
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26762

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:dimensions, :items], 'ShippingLabelPackage')
  @dimensions = (x = opts.delete(:dimensions); x.is_a?(::Io::Flow::V0::Models::Dimension) ? x : ::Io::Flow::V0::Models::Dimension.new(x))
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
end

Instance Attribute Details

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



26760
26761
26762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26760

def dimensions
  @dimensions
end

#itemsObject (readonly)

Returns the value of attribute items.



26760
26761
26762
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26760

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26773
26774
26775
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26773

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

#to_hashObject



26777
26778
26779
26780
26781
26782
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26777

def to_hash
  {
    :dimensions => dimensions.to_hash,
    :items => items.map { |o| o.to_hash }
  }
end

#to_jsonObject



26769
26770
26771
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26769

def to_json
  JSON.dump(to_hash)
end