Class: Io::Flow::V0::Models::ShippingLabel

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

Overview

Represents information about a carrier-generated shipping label used by a shipper to transport a package from a given origin to destination

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShippingLabel

Returns a new instance of ShippingLabel.



26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26407

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :direction, :carrier_tracking_number, :carrier_tracking_number_url, :cost, :destination, :flow_tracking_number, :flow_tracking_number_url, :origin, :service, :window], 'ShippingLabel')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @direction = (x = opts.delete(:direction); x.is_a?(::Io::Flow::V0::Models::Direction) ? x : ::Io::Flow::V0::Models::Direction.apply(x))
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @carrier_tracking_number = HttpClient::Preconditions.assert_class('carrier_tracking_number', opts.delete(:carrier_tracking_number), String)
  @carrier_tracking_number_url = HttpClient::Preconditions.assert_class('carrier_tracking_number_url', opts.delete(:carrier_tracking_number_url), String)
  @cost = (x = opts.delete(:cost); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @flow_tracking_number = HttpClient::Preconditions.assert_class('flow_tracking_number', opts.delete(:flow_tracking_number), String)
  @flow_tracking_number_url = HttpClient::Preconditions.assert_class('flow_tracking_number_url', opts.delete(:flow_tracking_number_url), String)
  @origin = (x = opts.delete(:origin); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x))
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::ServiceSummary) ? x : ::Io::Flow::V0::Models::ServiceSummary.new(x))
  @window = (x = opts.delete(:window); x.is_a?(::Io::Flow::V0::Models::DatetimeRange) ? x : ::Io::Flow::V0::Models::DatetimeRange.new(x))
  @commercial_invoice = (x = opts.delete(:commercial_invoice); x.nil? ? nil : HttpClient::Preconditions.assert_class('commercial_invoice', x, String))
  @zpl = (x = opts.delete(:zpl); x.nil? ? nil : HttpClient::Preconditions.assert_class('zpl', x, String))
  @pdf = (x = opts.delete(:pdf); x.nil? ? nil : HttpClient::Preconditions.assert_class('pdf', x, String))
  @png = (x = opts.delete(:png); x.nil? ? nil : HttpClient::Preconditions.assert_class('png', x, String))
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::LabelOrderSummary) ? x : ::Io::Flow::V0::Models::LabelOrderSummary.new(x)))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def attributes
  @attributes
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def carrier_tracking_number
  @carrier_tracking_number
end

#carrier_tracking_number_urlObject (readonly)

Returns the value of attribute carrier_tracking_number_url.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def carrier_tracking_number_url
  @carrier_tracking_number_url
end

#commercial_invoiceObject (readonly)

Returns the value of attribute commercial_invoice.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def commercial_invoice
  @commercial_invoice
end

#costObject (readonly)

Returns the value of attribute cost.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def cost
  @cost
end

#destinationObject (readonly)

Returns the value of attribute destination.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def destination
  @destination
end

#directionObject (readonly)

Returns the value of attribute direction.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def direction
  @direction
end

#flow_tracking_numberObject (readonly)

Returns the value of attribute flow_tracking_number.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def flow_tracking_number
  @flow_tracking_number
end

#flow_tracking_number_urlObject (readonly)

Returns the value of attribute flow_tracking_number_url.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def flow_tracking_number_url
  @flow_tracking_number_url
end

#idObject (readonly)

Returns the value of attribute id.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def order
  @order
end

#originObject (readonly)

Returns the value of attribute origin.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def origin
  @origin
end

#pdfObject (readonly)

Returns the value of attribute pdf.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def pdf
  @pdf
end

#pngObject (readonly)

Returns the value of attribute png.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def png
  @png
end

#serviceObject (readonly)

Returns the value of attribute service.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def service
  @service
end

#windowObject (readonly)

Returns the value of attribute window.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def window
  @window
end

#zplObject (readonly)

Returns the value of attribute zpl.



26405
26406
26407
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26405

def zpl
  @zpl
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26433
26434
26435
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26433

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

#to_hashObject



26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26437

def to_hash
  {
    :id => id,
    :direction => direction.value,
    :attributes => attributes,
    :carrier_tracking_number => carrier_tracking_number,
    :carrier_tracking_number_url => carrier_tracking_number_url,
    :cost => cost.to_hash,
    :destination => destination.to_hash,
    :flow_tracking_number => flow_tracking_number,
    :flow_tracking_number_url => flow_tracking_number_url,
    :origin => origin.to_hash,
    :service => service.to_hash,
    :window => window.to_hash,
    :commercial_invoice => commercial_invoice,
    :zpl => zpl,
    :pdf => pdf,
    :png => png,
    :order => order.nil? ? nil : order.to_hash
  }
end

#to_jsonObject



26429
26430
26431
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26429

def to_json
  JSON.dump(to_hash)
end