Class: UspsApi::ReturnPackageResponse

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

Overview

ReturnPackageResponse 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(return_label_metadata: SKIP, return_label_image: SKIP, return_receipt_image: SKIP, label_broker_qr: SKIP) ⇒ ReturnPackageResponse

Returns a new instance of ReturnPackageResponse.



66
67
68
69
70
71
72
# File 'lib/usps_api/models/return_package_response.rb', line 66

def initialize(return_label_metadata: SKIP, return_label_image: SKIP,
               return_receipt_image: SKIP, label_broker_qr: SKIP)
  @return_label_metadata =  unless  == SKIP
  @return_label_image = return_label_image unless return_label_image == SKIP
  @return_receipt_image = return_receipt_image unless return_receipt_image == SKIP
  @label_broker_qr = label_broker_qr unless label_broker_qr == SKIP
end

Instance Attribute Details

#label_broker_qrString

The Label Broker QR Code image, Base64 encoded file contents. Only provided if ‘imageType` in the `imageInfo` is set to `LABEL_BROKER`.

Returns:

  • (String)


39
40
41
# File 'lib/usps_api/models/return_package_response.rb', line 39

def label_broker_qr
  @label_broker_qr
end

#return_label_imageString

Contains the Base64-encoded file contents of the return label image. Provided only when ‘imageInfo.imageType` is not `NONE`. Note:

  • Not provided when Extra Service Code ‘415 - USPS Label Delivery` is

requested, as no images are returned for this service.

Returns:

  • (String)


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

def return_label_image
  @return_label_image
end

#return_label_metadataReturnLabelMetadata

Return Label Metadata

Returns:



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

def 
  @return_label_metadata
end

#return_receipt_imageString

Contains the Base64-encoded file contents of the return receipt image. Provided only when ‘imageInfo.receiptOption` is `SEPARATE_PAGE`. Note:

  • When ‘imageInfo.imageType` is `ZPL203DPI` or `ZPL300DPI` and

‘imageInfo.receiptOption` is `SEPARATE_PAGE`, the receipt will be returned as an additional label segment within the single ZPL payload in `labelImage`. In this case, `receiptImage` will not be populated.

  • Not provided when Extra Service Code ‘415 - USPS Label Delivery` is

requested, as no images are returned for this service.

Returns:

  • (String)


34
35
36
# File 'lib/usps_api/models/return_package_response.rb', line 34

def return_receipt_image
  @return_receipt_image
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/usps_api/models/return_package_response.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = ReturnLabelMetadata.from_hash(hash['returnLabelMetadata']) if
    hash['returnLabelMetadata']
  return_label_image =
    hash.key?('returnLabelImage') ? hash['returnLabelImage'] : SKIP
  return_receipt_image =
    hash.key?('returnReceiptImage') ? hash['returnReceiptImage'] : SKIP
  label_broker_qr =
    hash.key?('labelBrokerQR') ? hash['labelBrokerQR'] : SKIP

  # Create object from extracted values.
  ReturnPackageResponse.new(return_label_metadata: ,
                            return_label_image: return_label_image,
                            return_receipt_image: return_receipt_image,
                            label_broker_qr: label_broker_qr)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['return_label_metadata'] = 'returnLabelMetadata'
  @_hash['return_label_image'] = 'returnLabelImage'
  @_hash['return_receipt_image'] = 'returnReceiptImage'
  @_hash['label_broker_qr'] = 'labelBrokerQR'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/usps_api/models/return_package_response.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
58
59
# File 'lib/usps_api/models/return_package_response.rb', line 52

def self.optionals
  %w[
    return_label_metadata
    return_label_image
    return_receipt_image
    label_broker_qr
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} return_label_metadata: #{@return_label_metadata.inspect},"\
  " return_label_image: #{@return_label_image.inspect}, return_receipt_image:"\
  " #{@return_receipt_image.inspect}, label_broker_qr: #{@label_broker_qr.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
101
# File 'lib/usps_api/models/return_package_response.rb', line 96

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} return_label_metadata: #{@return_label_metadata}, return_label_image:"\
  " #{@return_label_image}, return_receipt_image: #{@return_receipt_image}, label_broker_qr:"\
  " #{@label_broker_qr}>"
end