class OpenapiClient::Label

A label represents the physical sticker that you affix to a package to ship it. ShipEngine makes it easy for you to [create labels](www.shipengine.com/docs/labels/create-a-label/) and then download them in PDF, PNG, or ZPL format so you can print them.

Attributes

batch_id[RW]

If this label was created as part of a [batch](www.shipengine.com/docs/labels/bulk/), then this is the unique ID of that batch.

carrier_code[RW]

The [shipping carrier](www.shipengine.com/docs/carriers/setup/) who will ship the package, such as `fedex`, `dhl_express`, `stamps_com`, etc.

carrier_id[RW]

The unique ID of the [carrier account](www.shipengine.com/docs/carriers/setup/) that was used to create this label

charge_event[RW]

The label charge event.

created_at[RW]

The date and time that the label was created in ShipEngine.

form_download[RW]

The link to downlaod the customs form (a.k.a. commercial invoice) for this shipment, if any. Forms are in PDF format. This field is null if the shipment does not require a customs form, or if the carrier does not support it.

insurance_claim[RW]

The link to submit an insurance claim for the shipment. This field is null if the shipment is not insured or if the insurance provider does not support online claim submission.

insurance_cost[RW]

The insurance cost for this package. Add this to the `shipment_cost` field to get the total cost.

is_international[RW]

Indicates whether this is an international shipment. That is, the originating country and destination country are different.

is_return_label[RW]

Indicates whether this is a return label. You may also want to set the `rma_number` so you know what is being returned.

label_download[RW]
label_download_type[RW]
label_format[RW]

The file format that you want the label to be in. We recommend `pdf` format because it is supported by all carriers, whereas some carriers do not support the `png` or `zpl` formats.

label_id[RW]

A string that uniquely identifies the label. This ID is generated by ShipEngine when the label is created.

label_image_id[RW]

The label image resource that was used to create a custom label image.

label_layout[RW]

The layout (size) that you want the label to be in. The `label_format` determines which sizes are allowed. `4x6` is supported for all label formats, whereas `letter` (8.5" x 11") is only supported for `pdf` format.

outbound_label_id[RW]

The `label_id` of the original (outgoing) label that the return label is for. This associates the two labels together, which is required by some carriers.

package_code[RW]

The [package type](www.shipengine.com/docs/reference/list-carrier-packages/), such as `thick_envelope`, `small_flat_rate_box`, `large_package`, etc. The code `package` indicates a custom or unknown package type.

packages[RW]

The label's package(s). > Note: Some carriers only allow one package per label. If you attempt to create a multi-package label for a carrier that doesn't allow it, an error will be returned.

rma_number[RW]

An optional Return Merchandise Authorization number. This field is useful for return labels. You can set it to any string value.

service_code[RW]

The [carrier service](www.shipengine.com/docs/shipping/use-a-carrier-service/) used to ship the package, such as `fedex_ground`, `usps_first_class_mail`, `flat_rate_envelope`, etc.

ship_date[RW]

The date that the package was (or will be) shippped. ShipEngine will take the day of week into consideration. For example, if the carrier does not operate on Sundays, then a package that would have shipped on Sunday will ship on Monday instead.

shipment[RW]

The shipment information used to generate the label

shipment_cost[RW]

The cost of shipping, delivery confirmation, and other carrier charges. This amount **does not** include insurance costs.

shipment_id[RW]

The shipment that this label is for. ShipEngine can create a shipment for you automatically when you [create a label](www.shipengine.com/docs/labels/create-a-label/), or you can [create your own shipment](www.shipengine.com/docs/shipping/create-a-shipment/) and then [use it to print a label](www.shipengine.com/docs/labels/create-from-shipment/)

status[RW]
test_label[RW]

Indicate if this label is being used only for testing purposes. If true, then no charge will be added to your account.

trackable[RW]

Indicates whether the shipment is trackable, in which case the `tracking_status` field will reflect the current status and each package will have a `tracking_number`.

tracking_number[RW]

The tracking number for the package. Tracking number formats vary across carriers.

tracking_status[RW]

The current status of the package, such as `in_transit` or `delivered`

validate_address[RW]
voided[RW]

Indicates whether the label has been [voided](www.shipengine.com/docs/labels/voiding/)

voided_at[RW]

The date and time that the label was [voided](www.shipengine.com/docs/labels/voiding/), or `null` if the label has not been voided

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/openapi_client/models/label.rb, line 114
def self.attribute_map
  {
    :'label_id' => :'label_id',
    :'status' => :'status',
    :'shipment_id' => :'shipment_id',
    :'shipment' => :'shipment',
    :'ship_date' => :'ship_date',
    :'created_at' => :'created_at',
    :'shipment_cost' => :'shipment_cost',
    :'insurance_cost' => :'insurance_cost',
    :'tracking_number' => :'tracking_number',
    :'is_return_label' => :'is_return_label',
    :'rma_number' => :'rma_number',
    :'is_international' => :'is_international',
    :'batch_id' => :'batch_id',
    :'carrier_id' => :'carrier_id',
    :'charge_event' => :'charge_event',
    :'outbound_label_id' => :'outbound_label_id',
    :'service_code' => :'service_code',
    :'test_label' => :'test_label',
    :'package_code' => :'package_code',
    :'validate_address' => :'validate_address',
    :'voided' => :'voided',
    :'voided_at' => :'voided_at',
    :'label_download_type' => :'label_download_type',
    :'label_format' => :'label_format',
    :'label_layout' => :'label_layout',
    :'trackable' => :'trackable',
    :'label_image_id' => :'label_image_id',
    :'carrier_code' => :'carrier_code',
    :'tracking_status' => :'tracking_status',
    :'label_download' => :'label_download',
    :'form_download' => :'form_download',
    :'insurance_claim' => :'insurance_claim',
    :'packages' => :'packages'
  }
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/openapi_client/models/label.rb, line 437
def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/openapi_client/models/label.rb, line 204
def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Label` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Label`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'label_id')
    self.label_id = attributes[:'label_id']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'shipment_id')
    self.shipment_id = attributes[:'shipment_id']
  end

  if attributes.key?(:'shipment')
    self.shipment = attributes[:'shipment']
  end

  if attributes.key?(:'ship_date')
    self.ship_date = attributes[:'ship_date']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'shipment_cost')
    self.shipment_cost = attributes[:'shipment_cost']
  end

  if attributes.key?(:'insurance_cost')
    self.insurance_cost = attributes[:'insurance_cost']
  end

  if attributes.key?(:'tracking_number')
    self.tracking_number = attributes[:'tracking_number']
  end

  if attributes.key?(:'is_return_label')
    self.is_return_label = attributes[:'is_return_label']
  end

  if attributes.key?(:'rma_number')
    self.rma_number = attributes[:'rma_number']
  end

  if attributes.key?(:'is_international')
    self.is_international = attributes[:'is_international']
  end

  if attributes.key?(:'batch_id')
    self.batch_id = attributes[:'batch_id']
  end

  if attributes.key?(:'carrier_id')
    self.carrier_id = attributes[:'carrier_id']
  end

  if attributes.key?(:'charge_event')
    self.charge_event = attributes[:'charge_event']
  end

  if attributes.key?(:'outbound_label_id')
    self.outbound_label_id = attributes[:'outbound_label_id']
  end

  if attributes.key?(:'service_code')
    self.service_code = attributes[:'service_code']
  end

  if attributes.key?(:'test_label')
    self.test_label = attributes[:'test_label']
  else
    self.test_label = false
  end

  if attributes.key?(:'package_code')
    self.package_code = attributes[:'package_code']
  end

  if attributes.key?(:'validate_address')
    self.validate_address = attributes[:'validate_address']
  end

  if attributes.key?(:'voided')
    self.voided = attributes[:'voided']
  end

  if attributes.key?(:'voided_at')
    self.voided_at = attributes[:'voided_at']
  end

  if attributes.key?(:'label_download_type')
    self.label_download_type = attributes[:'label_download_type']
  end

  if attributes.key?(:'label_format')
    self.label_format = attributes[:'label_format']
  end

  if attributes.key?(:'label_layout')
    self.label_layout = attributes[:'label_layout']
  end

  if attributes.key?(:'trackable')
    self.trackable = attributes[:'trackable']
  end

  if attributes.key?(:'label_image_id')
    self.label_image_id = attributes[:'label_image_id']
  end

  if attributes.key?(:'carrier_code')
    self.carrier_code = attributes[:'carrier_code']
  end

  if attributes.key?(:'tracking_status')
    self.tracking_status = attributes[:'tracking_status']
  end

  if attributes.key?(:'label_download')
    self.label_download = attributes[:'label_download']
  end

  if attributes.key?(:'form_download')
    self.form_download = attributes[:'form_download']
  end

  if attributes.key?(:'insurance_claim')
    self.insurance_claim = attributes[:'insurance_claim']
  end

  if attributes.key?(:'packages')
    if (value = attributes[:'packages']).is_a?(Array)
      self.packages = value
    end
  end
end
openapi_nullable() click to toggle source

List of attributes with nullable: true

# File lib/openapi_client/models/label.rb, line 192
def self.openapi_nullable
  Set.new([
    :'rma_number',
    :'voided_at',
    :'label_image_id',
    :'form_download',
    :'insurance_claim',
  ])
end
openapi_types() click to toggle source

Attribute type mapping.

# File lib/openapi_client/models/label.rb, line 153
def self.openapi_types
  {
    :'label_id' => :'String',
    :'status' => :'LabelStatus',
    :'shipment_id' => :'String',
    :'shipment' => :'Shipment',
    :'ship_date' => :'DateTime',
    :'created_at' => :'DateTime',
    :'shipment_cost' => :'MonetaryValue',
    :'insurance_cost' => :'MonetaryValue',
    :'tracking_number' => :'String',
    :'is_return_label' => :'Boolean',
    :'rma_number' => :'String',
    :'is_international' => :'Boolean',
    :'batch_id' => :'String',
    :'carrier_id' => :'String',
    :'charge_event' => :'LabelChargeEvent',
    :'outbound_label_id' => :'String',
    :'service_code' => :'String',
    :'test_label' => :'Boolean',
    :'package_code' => :'String',
    :'validate_address' => :'ValidateAddress',
    :'voided' => :'Boolean',
    :'voided_at' => :'DateTime',
    :'label_download_type' => :'LabelDownloadType',
    :'label_format' => :'LabelFormat',
    :'label_layout' => :'LabelLayout',
    :'trackable' => :'Boolean',
    :'label_image_id' => :'String',
    :'carrier_code' => :'String',
    :'tracking_status' => :'TrackingStatus',
    :'label_download' => :'LabelDownload',
    :'form_download' => :'Link',
    :'insurance_claim' => :'Link',
    :'packages' => :'Array<Package>'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/openapi_client/models/label.rb, line 384
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      label_id == o.label_id &&
      status == o.status &&
      shipment_id == o.shipment_id &&
      shipment == o.shipment &&
      ship_date == o.ship_date &&
      created_at == o.created_at &&
      shipment_cost == o.shipment_cost &&
      insurance_cost == o.insurance_cost &&
      tracking_number == o.tracking_number &&
      is_return_label == o.is_return_label &&
      rma_number == o.rma_number &&
      is_international == o.is_international &&
      batch_id == o.batch_id &&
      carrier_id == o.carrier_id &&
      charge_event == o.charge_event &&
      outbound_label_id == o.outbound_label_id &&
      service_code == o.service_code &&
      test_label == o.test_label &&
      package_code == o.package_code &&
      validate_address == o.validate_address &&
      voided == o.voided &&
      voided_at == o.voided_at &&
      label_download_type == o.label_download_type &&
      label_format == o.label_format &&
      label_layout == o.label_layout &&
      trackable == o.trackable &&
      label_image_id == o.label_image_id &&
      carrier_code == o.carrier_code &&
      tracking_status == o.tracking_status &&
      label_download == o.label_download &&
      form_download == o.form_download &&
      insurance_claim == o.insurance_claim &&
      packages == o.packages
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/openapi_client/models/label.rb, line 465
def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    OpenapiClient.const_get(type).build_from_hash(value)
  end
end
_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/openapi_client/models/label.rb, line 534
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/openapi_client/models/label.rb, line 444
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/openapi_client/models/label.rb, line 424
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Integer] Hash code

# File lib/openapi_client/models/label.rb, line 430
def hash
  [label_id, status, shipment_id, shipment, ship_date, created_at, shipment_cost, insurance_cost, tracking_number, is_return_label, rma_number, is_international, batch_id, carrier_id, charge_event, outbound_label_id, service_code, test_label, package_code, validate_address, voided, voided_at, label_download_type, label_format, label_layout, trackable, label_image_id, carrier_code, tracking_status, label_download, form_download, insurance_claim, packages].hash
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons

# File lib/openapi_client/models/label.rb, line 356
def list_invalid_properties
  invalid_properties = Array.new
  if !@tracking_number.nil? && @tracking_number.to_s.length < 1
    invalid_properties.push('invalid value for "tracking_number", the character length must be great than or equal to 1.')
  end

  invalid_properties
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/openapi_client/models/label.rb, line 510
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/openapi_client/models/label.rb, line 516
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end
    
    hash[param] = _to_hash(value)
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/openapi_client/models/label.rb, line 504
def to_s
  to_hash.to_s
end
tracking_number=(tracking_number) click to toggle source

Custom attribute writer method with validation @param [Object] tracking_number Value to be assigned

# File lib/openapi_client/models/label.rb, line 374
def tracking_number=(tracking_number)
  if !tracking_number.nil? && tracking_number.to_s.length < 1
    fail ArgumentError, 'invalid value for "tracking_number", the character length must be great than or equal to 1.'
  end

  @tracking_number = tracking_number
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/openapi_client/models/label.rb, line 367
def valid?
  return false if !@tracking_number.nil? && @tracking_number.to_s.length < 1
  true
end