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.



24338
24339
24340
24341
24342
24343
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24338

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.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def dimensions
  @dimensions
end

#itemsObject (readonly)

Returns the value of attribute items.



24336
24337
24338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24336

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24349
24350
24351
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24349

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

#to_hashObject



24353
24354
24355
24356
24357
24358
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24353

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

#to_jsonObject



24345
24346
24347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24345

def to_json
  JSON.dump(to_hash)
end