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, if no center key is provided

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.



51587
51588
51589
51590
51591
51592
51593
51594
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51587

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

Instance Attribute Details

#center_keyObject (readonly)

Returns the value of attribute center_key.



51585
51586
51587
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51585

def center_key
  @center_key
end

#itemsObject (readonly)

Returns the value of attribute items.



51585
51586
51587
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51585

def items
  @items
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



51585
51586
51587
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51585

def order_number
  @order_number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



51600
51601
51602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51600

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

#subtype_to_hashObject



51604
51605
51606
51607
51608
51609
51610
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51604

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

#to_jsonObject



51596
51597
51598
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 51596

def to_json
  JSON.dump(to_hash)
end