Class: Io::Flow::V0::Models::SummaryShippingLabelForm

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

Overview

Minimal form to create a shipping label. Origin and destination are assumed based on a given order's center and final shipping destination

Instance Attribute Summary collapse

Attributes inherited from ShippingLabelForm

#discriminator

Instance Method Summary collapse

Methods inherited from ShippingLabelForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ SummaryShippingLabelForm

Returns a new instance of SummaryShippingLabelForm.



49864
49865
49866
49867
49868
49869
49870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49864

def initialize(incoming={})
  super(:discriminator => ShippingLabelForm::Types::SUMMARY_SHIPPING_LABEL_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order_number, :items], 'SummaryShippingLabelForm')
  @order_number = HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_number), String)
  @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

#itemsObject (readonly)

Returns the value of attribute items.



49862
49863
49864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49862

def items
  @items
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



49862
49863
49864
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49862

def order_number
  @order_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



49876
49877
49878
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49876

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

#subtype_to_hashObject



49880
49881
49882
49883
49884
49885
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49880

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

#to_jsonObject



49872
49873
49874
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49872

def to_json
  JSON.dump(to_hash)
end