Class: Io::Flow::V0::Models::BridgeShippingLabelForm

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

Overview

Form to create a shipping label via the GLBE Bridge.

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 = {}) ⇒ BridgeShippingLabelForm

Returns a new instance of BridgeShippingLabelForm.



32507
32508
32509
32510
32511
32512
32513
32514
32515
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32507

def initialize(incoming={})
  super(:discriminator => ShippingLabelForm::Types::BRIDGE_SHIPPING_LABEL_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order_number], 'BridgeShippingLabelForm')
  @order_number = HttpClient::Preconditions.assert_class('order_number', opts.delete(:order_number), String)
  @items = (x = opts.delete(:items); x.nil? ? nil : HttpClient::Preconditions.assert_class('items', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) })
  @package = (x = opts.delete(:package); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingLabelPackage) ? x : ::Io::Flow::V0::Models::ShippingLabelPackage.new(x)))
  @origin = (x = opts.delete(:origin); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)))
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



32505
32506
32507
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32505

def items
  @items
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



32505
32506
32507
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32505

def order_number
  @order_number
end

#originObject (readonly)

Returns the value of attribute origin.



32505
32506
32507
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32505

def origin
  @origin
end

#packageObject (readonly)

Returns the value of attribute package.



32505
32506
32507
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32505

def package
  @package
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



32521
32522
32523
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32521

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

#subtype_to_hashObject



32525
32526
32527
32528
32529
32530
32531
32532
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32525

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

#to_jsonObject



32517
32518
32519
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32517

def to_json
  JSON.dump(to_hash)
end