Class: UspsApi::OutboundLabelReprintResponse

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

Overview

Response schema for outbound label reprint requests.

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(label_metadata: SKIP, label_image: SKIP, reprint_info: SKIP) ⇒ OutboundLabelReprintResponse

Returns a new instance of OutboundLabelReprintResponse.



47
48
49
50
51
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 47

def initialize(label_metadata: SKIP, label_image: SKIP, reprint_info: SKIP)
  @label_metadata =  unless  == SKIP
  @label_image = label_image unless label_image == SKIP
  @reprint_info = reprint_info unless reprint_info == SKIP
end

Instance Attribute Details

#label_imageString

Contains the Base64-encoded file contents of the label image.

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 18

def label_image
  @label_image
end

#label_metadataLabelMetadata

Label Metadata returned from label creation and label edit.

Returns:



14
15
16
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 14

def 
  @label_metadata
end

#reprint_infoInternationalLabelsReprintInfo

Schema containing reprint information for a label.



22
23
24
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 22

def reprint_info
  @reprint_info
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 54

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = LabelMetadata.from_hash(hash['labelMetadata']) if hash['labelMetadata']
  label_image = hash.key?('labelImage') ? hash['labelImage'] : SKIP
  reprint_info = InternationalLabelsReprintInfo.from_hash(hash['reprintInfo']) if
    hash['reprintInfo']

  # Create object from extracted values.
  OutboundLabelReprintResponse.new(label_metadata: ,
                                   label_image: label_image,
                                   reprint_info: reprint_info)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['label_metadata'] = 'labelMetadata'
  @_hash['label_image'] = 'labelImage'
  @_hash['reprint_info'] = 'reprintInfo'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    label_metadata
    label_image
    reprint_info
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



71
72
73
74
75
76
77
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 71

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.



87
88
89
90
91
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 87

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

#to_sObject

Provides a human-readable string representation of the object.



80
81
82
83
84
# File 'lib/usps_api/models/outbound_label_reprint_response.rb', line 80

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