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.



14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14962

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :carrier_tracking_number, :zpl, :destination, :flow_tracking_number, :origin, :service, :window], 'ShippingLabel')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @carrier_tracking_number = HttpClient::Preconditions.assert_class('carrier_tracking_number', opts.delete(:carrier_tracking_number), String)
  @zpl = HttpClient::Preconditions.assert_class('zpl', opts.delete(:zpl), String)
  @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)
  @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))
  @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

#carrier_tracking_numberObject (readonly)

Returns the value of attribute carrier_tracking_number.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def carrier_tracking_number
  @carrier_tracking_number
end

#commercial_invoiceObject (readonly)

Returns the value of attribute commercial_invoice.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def commercial_invoice
  @commercial_invoice
end

#destinationObject (readonly)

Returns the value of attribute destination.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def destination
  @destination
end

#flow_tracking_numberObject (readonly)

Returns the value of attribute flow_tracking_number.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def flow_tracking_number
  @flow_tracking_number
end

#idObject (readonly)

Returns the value of attribute id.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def id
  @id
end

#orderObject (readonly)

Returns the value of attribute order.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def order
  @order
end

#originObject (readonly)

Returns the value of attribute origin.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def origin
  @origin
end

#pdfObject (readonly)

Returns the value of attribute pdf.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def pdf
  @pdf
end

#pngObject (readonly)

Returns the value of attribute png.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def png
  @png
end

#serviceObject (readonly)

Returns the value of attribute service.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def service
  @service
end

#windowObject (readonly)

Returns the value of attribute window.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def window
  @window
end

#zplObject (readonly)

Returns the value of attribute zpl.



14960
14961
14962
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14960

def zpl
  @zpl
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14983
14984
14985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14983

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

#to_hashObject



14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14987

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

#to_jsonObject



14979
14980
14981
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14979

def to_json
  JSON.dump(to_hash)
end