Class: UspsApi::LabelsCustomerReference

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/labels_customer_reference.rb

Overview

LabelsCustomerReference Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(reference_number: SKIP, print_reference_number: false, additional_properties: nil) ⇒ LabelsCustomerReference

Returns a new instance of LabelsCustomerReference.



55
56
57
58
59
60
61
62
63
# File 'lib/usps_api/models/labels_customer_reference.rb', line 55

def initialize(reference_number: SKIP, print_reference_number: false,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @reference_number = reference_number unless reference_number == SKIP
  @print_reference_number = print_reference_number unless print_reference_number == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

Indicates whether or not to print the customer reference number on the label in the Additional Information and User Segment. Note:

  • Customer Reference numbers are not displayed on label types ‘2X7LABEL`

or ‘4X4LABEL`.

  • Customer Reference numbers are not displayed with Customs Forms.

Returns:

  • (TrueClass | FalseClass)


32
33
34
# File 'lib/usps_api/models/labels_customer_reference.rb', line 32

def print_reference_number
  @print_reference_number
end

#reference_numberString

A user-assigned number for internal use, such as Order, Invoice, Customer, or Return Merchandise Authorization Numbers. Note:

  • Domestic outbound label and return label with ‘labelType` of `4X6LABEL`

will display the entire value.

  • Return label with ‘labelType` of `4X6LABEL` with `brandingImageFormat`

of ‘TWO_SQUARES` will show the first 25 characters.

  • For all other label formats, only a maximum of 18 characters will be

shown on the shipping label.

  • These values will also be included in the Shipping Services File.

Returns:

  • (String)


23
24
25
# File 'lib/usps_api/models/labels_customer_reference.rb', line 23

def reference_number
  @reference_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/usps_api/models/labels_customer_reference.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reference_number =
    hash.key?('referenceNumber') ? hash['referenceNumber'] : SKIP
  print_reference_number = hash['printReferenceNumber'] ||= false

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  LabelsCustomerReference.new(reference_number: reference_number,
                              print_reference_number: print_reference_number,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
# File 'lib/usps_api/models/labels_customer_reference.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reference_number'] = 'referenceNumber'
  @_hash['print_reference_number'] = 'printReferenceNumber'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/usps_api/models/labels_customer_reference.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



43
44
45
46
47
48
# File 'lib/usps_api/models/labels_customer_reference.rb', line 43

def self.optionals
  %w[
    reference_number
    print_reference_number
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



89
90
91
92
93
94
95
# File 'lib/usps_api/models/labels_customer_reference.rb', line 89

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



105
106
107
108
109
# File 'lib/usps_api/models/labels_customer_reference.rb', line 105

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} reference_number: #{@reference_number.inspect}, print_reference_number:"\
  " #{@print_reference_number.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



98
99
100
101
102
# File 'lib/usps_api/models/labels_customer_reference.rb', line 98

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} reference_number: #{@reference_number}, print_reference_number:"\
  " #{@print_reference_number}, additional_properties: #{@additional_properties}>"
end