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.



40697
40698
40699
40700
40701
40702
40703
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40697

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)) }
  @reference_number = (x = opts.delete(:reference_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('reference_number', x, String))
end

Instance Attribute Details

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



40695
40696
40697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40695

def dimensions
  @dimensions
end

#itemsObject (readonly)

Returns the value of attribute items.



40695
40696
40697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40695

def items
  @items
end

#reference_numberObject (readonly)

Returns the value of attribute reference_number.



40695
40696
40697
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40695

def reference_number
  @reference_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40709
40710
40711
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40709

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

#to_hashObject



40713
40714
40715
40716
40717
40718
40719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40713

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

#to_jsonObject



40705
40706
40707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40705

def to_json
  JSON.dump(to_hash)
end