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.



25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25310

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.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def attributes
  @attributes
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def carrier_tracking_number
  @carrier_tracking_number
end

#carrier_tracking_number_urlObject (readonly)

Returns the value of attribute carrier_tracking_number_url.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def carrier_tracking_number_url
  @carrier_tracking_number_url
end

#commercial_invoiceObject (readonly)

Returns the value of attribute commercial_invoice.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def commercial_invoice
  @commercial_invoice
end

#costObject (readonly)

Returns the value of attribute cost.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def cost
  @cost
end

#destinationObject (readonly)

Returns the value of attribute destination.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def destination
  @destination
end

#directionObject (readonly)

Returns the value of attribute direction.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def direction
  @direction
end

#flow_tracking_numberObject (readonly)

Returns the value of attribute flow_tracking_number.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def flow_tracking_number
  @flow_tracking_number
end

#flow_tracking_number_urlObject (readonly)

Returns the value of attribute flow_tracking_number_url.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def flow_tracking_number_url
  @flow_tracking_number_url
end

#idObject (readonly)

Returns the value of attribute id.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def order
  @order
end

#originObject (readonly)

Returns the value of attribute origin.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def origin
  @origin
end

#pdfObject (readonly)

Returns the value of attribute pdf.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def pdf
  @pdf
end

#pngObject (readonly)

Returns the value of attribute png.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def png
  @png
end

#serviceObject (readonly)

Returns the value of attribute service.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def service
  @service
end

#windowObject (readonly)

Returns the value of attribute window.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def window
  @window
end

#zplObject (readonly)

Returns the value of attribute zpl.



25308
25309
25310
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25308

def zpl
  @zpl
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



25336
25337
25338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25336

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

#to_hashObject



25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25340

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



25332
25333
25334
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 25332

def to_json
  JSON.dump(to_hash)
end