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.



24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24239

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.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def attributes
  @attributes
end

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def carrier_tracking_number
  @carrier_tracking_number
end

#carrier_tracking_number_urlObject (readonly)

Returns the value of attribute carrier_tracking_number_url.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def carrier_tracking_number_url
  @carrier_tracking_number_url
end

#commercial_invoiceObject (readonly)

Returns the value of attribute commercial_invoice.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def commercial_invoice
  @commercial_invoice
end

#costObject (readonly)

Returns the value of attribute cost.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def cost
  @cost
end

#destinationObject (readonly)

Returns the value of attribute destination.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def destination
  @destination
end

#directionObject (readonly)

Returns the value of attribute direction.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def direction
  @direction
end

#flow_tracking_numberObject (readonly)

Returns the value of attribute flow_tracking_number.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def flow_tracking_number
  @flow_tracking_number
end

#flow_tracking_number_urlObject (readonly)

Returns the value of attribute flow_tracking_number_url.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def flow_tracking_number_url
  @flow_tracking_number_url
end

#idObject (readonly)

Returns the value of attribute id.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def order
  @order
end

#originObject (readonly)

Returns the value of attribute origin.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def origin
  @origin
end

#pdfObject (readonly)

Returns the value of attribute pdf.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def pdf
  @pdf
end

#pngObject (readonly)

Returns the value of attribute png.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def png
  @png
end

#serviceObject (readonly)

Returns the value of attribute service.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def service
  @service
end

#windowObject (readonly)

Returns the value of attribute window.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def window
  @window
end

#zplObject (readonly)

Returns the value of attribute zpl.



24237
24238
24239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24237

def zpl
  @zpl
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24265
24266
24267
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24265

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

#to_hashObject



24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24269

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



24261
24262
24263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24261

def to_json
  JSON.dump(to_hash)
end