Class: UspsApi::ScanFormVendorResponse

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

Overview

Response for a SCAN Form request using the ‘application/vnd.usps.labels+json` or `application/vnd.usps.labels+xml` `Accept` header.

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(image_info: SKIP, form: Form::ENUM_5630, image_type: DeprecatedImageType::PDF, label_type: DeprecatedLabelTypeResponse::ENUM_85X11LABEL, mailing_date: SKIP, overwrite_mailing_date: false, entry_facility_zip_code: SKIP, destination_entry_facility_type: SKIP, shipment: SKIP, manifest_number: SKIP, tracking_numbers: SKIP, from_address: SKIP, scan_form_image: SKIP, additional_properties: nil) ⇒ ScanFormVendorResponse

Returns a new instance of ScanFormVendorResponse.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 131

def initialize(image_info: SKIP, form: Form::ENUM_5630,
               image_type: DeprecatedImageType::PDF,
               label_type: DeprecatedLabelTypeResponse::ENUM_85X11LABEL,
               mailing_date: SKIP, overwrite_mailing_date: false,
               entry_facility_zip_code: SKIP,
               destination_entry_facility_type: SKIP, shipment: SKIP,
               manifest_number: SKIP, tracking_numbers: SKIP,
               from_address: SKIP, scan_form_image: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @image_info = image_info unless image_info == SKIP
  @form = form unless form == SKIP
  @image_type = image_type unless image_type == SKIP
  @label_type = label_type unless label_type == SKIP
  @mailing_date = mailing_date unless mailing_date == SKIP
  @overwrite_mailing_date = overwrite_mailing_date unless overwrite_mailing_date == SKIP
  @entry_facility_zip_code = entry_facility_zip_code unless entry_facility_zip_code == SKIP
  unless destination_entry_facility_type == SKIP
    @destination_entry_facility_type =
      destination_entry_facility_type
  end
  @shipment = shipment unless shipment == SKIP
  @manifest_number = manifest_number unless manifest_number == SKIP
  @tracking_numbers = tracking_numbers unless tracking_numbers == SKIP
  @from_address = from_address unless from_address == SKIP
  @scan_form_image = scan_form_image unless scan_form_image == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#destination_entry_facility_typeDestinationEntryFacilityType1

Specifies the type of facility the mailpieces are being entered at. All mailpieces on a single SCAN Form must be entered at the same facility and facility type. A value of ‘NONE` cannot be used when shipping Parcel Select or USPS Connect Local items.



56
57
58
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 56

def destination_entry_facility_type
  @destination_entry_facility_type
end

#entry_facility_zip_codeString

The ZIP code of the destination entry facility.

Returns:

  • (String)


49
50
51
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 49

def entry_facility_zip_code
  @entry_facility_zip_code
end

#formForm

This field has been deprecated. The type of SCAN Form will be dictated by the ‘imageInfo.labelType` requested.

Returns:



21
22
23
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 21

def form
  @form
end

#from_addressScanFormAddress

Location of the Shipper. Only domestic addresses are supported for this API. Note:

  • The ‘firstName` and `lastName` or `firm` are always required.

Returns:



80
81
82
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 80

def from_address
  @from_address
end

#image_infoScanFormsImageInfo

Characteristics of the type of SCAN Form being requested.

Returns:



16
17
18
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 16

def image_info
  @image_info
end

#image_typeDeprecatedImageType

This field has been deprecated. ‘imageType` can be updated through `imageInfo.imageType`.

Returns:



26
27
28
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 26

def image_type
  @image_type
end

#label_typeDeprecatedLabelTypeResponse

This field has been deprecated. ‘labelType` can be updated through `imageInfo.labelType`.



31
32
33
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 31

def label_type
  @label_type
end

#mailing_dateDate

The date of mailing. The date when the items in the associated SCAN Form will be dropped off at the Entry Facility.

Returns:

  • (Date)


36
37
38
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 36

def mailing_date
  @mailing_date
end

#manifest_numberString

The Electronic File Number (EFN) stored in the Shipping Services File that represents all the tracking numbers associated to a shipment.

Returns:

  • (String)


66
67
68
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 66

def manifest_number
  @manifest_number
end

#overwrite_mailing_dateTrueClass | FalseClass

Label Mailing Date Overwrite option. If this value is set to ‘true`, the mailing dates for the packages contained within the SCAN Form will be overwritten with the `mailingDate` value provided in the SCAN Form request. If this value is set to `false`, the mailing dates for the packages contained within the SCAN Form will not be updated and will use the values initially provided in the Label request.

Returns:

  • (TrueClass | FalseClass)


45
46
47
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 45

def overwrite_mailing_date
  @overwrite_mailing_date
end

#scan_form_imageString

Contains the Base64-encoded file contents of the SCAN Form image. Provided only when ‘imageInfo.imageType` is not `NONE`.

Returns:

  • (String)


85
86
87
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 85

def scan_form_image
  @scan_form_image
end

#shipmentObject

SCAN Form shipment method used to populate tracking numbers into the SCAN FOrm.

Returns:

  • (Object)


61
62
63
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 61

def shipment
  @shipment
end

#tracking_numbersArray[String]

Tracking numbers that were added to the SCAN Form. For ‘MID` and `manifestMID` Shipment options, only eligible labels matching the `MID` or `manifestMID`, `mailingDate`, `entryFacilityZIPCode`, and `destinationEntryFacilityType` are added.

Returns:

  • (Array[String])


73
74
75
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 73

def tracking_numbers
  @tracking_numbers
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 163

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  image_info = ScanFormsImageInfo.from_hash(hash['imageInfo']) if hash['imageInfo']
  form = hash['form'] ||= Form::ENUM_5630
  image_type = hash['imageType'] ||= DeprecatedImageType::PDF
  label_type =
    hash['labelType'] ||= DeprecatedLabelTypeResponse::ENUM_85X11LABEL
  mailing_date = hash.key?('mailingDate') ? hash['mailingDate'] : SKIP
  overwrite_mailing_date = hash['overwriteMailingDate'] ||= false
  entry_facility_zip_code =
    hash.key?('entryFacilityZIPCode') ? hash['entryFacilityZIPCode'] : SKIP
  destination_entry_facility_type =
    hash.key?('destinationEntryFacilityType') ? hash['destinationEntryFacilityType'] : SKIP
  shipment = hash.key?('shipment') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ScanFormVendorResponseShipment), hash['shipment']
  ) : SKIP
  manifest_number =
    hash.key?('manifestNumber') ? hash['manifestNumber'] : SKIP
  tracking_numbers =
    hash.key?('trackingNumbers') ? hash['trackingNumbers'] : SKIP
  from_address = ScanFormAddress.from_hash(hash['fromAddress']) if hash['fromAddress']
  scan_form_image =
    hash.key?('SCANFormImage') ? hash['SCANFormImage'] : SKIP

  # 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.
  ScanFormVendorResponse.new(image_info: image_info,
                             form: form,
                             image_type: image_type,
                             label_type: label_type,
                             mailing_date: mailing_date,
                             overwrite_mailing_date: overwrite_mailing_date,
                             entry_facility_zip_code: entry_facility_zip_code,
                             destination_entry_facility_type: destination_entry_facility_type,
                             shipment: shipment,
                             manifest_number: manifest_number,
                             tracking_numbers: tracking_numbers,
                             from_address: from_address,
                             scan_form_image: scan_form_image,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 88

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['image_info'] = 'imageInfo'
  @_hash['form'] = 'form'
  @_hash['image_type'] = 'imageType'
  @_hash['label_type'] = 'labelType'
  @_hash['mailing_date'] = 'mailingDate'
  @_hash['overwrite_mailing_date'] = 'overwriteMailingDate'
  @_hash['entry_facility_zip_code'] = 'entryFacilityZIPCode'
  @_hash['destination_entry_facility_type'] =
    'destinationEntryFacilityType'
  @_hash['shipment'] = 'shipment'
  @_hash['manifest_number'] = 'manifestNumber'
  @_hash['tracking_numbers'] = 'trackingNumbers'
  @_hash['from_address'] = 'fromAddress'
  @_hash['scan_form_image'] = 'SCANFormImage'
  @_hash
end

.nullablesObject

An array for nullable fields



127
128
129
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 127

def self.nullables
  []
end

.optionalsObject

An array for optional fields



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 108

def self.optionals
  %w[
    image_info
    form
    image_type
    label_type
    mailing_date
    overwrite_mailing_date
    entry_facility_zip_code
    destination_entry_facility_type
    shipment
    manifest_number
    tracking_numbers
    from_address
    scan_form_image
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



215
216
217
218
219
220
221
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 215

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.



236
237
238
239
240
241
242
243
244
245
246
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 236

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} image_info: #{@image_info.inspect}, form: #{@form.inspect}, image_type:"\
  " #{@image_type.inspect}, label_type: #{@label_type.inspect}, mailing_date:"\
  " #{@mailing_date.inspect}, overwrite_mailing_date: #{@overwrite_mailing_date.inspect},"\
  " entry_facility_zip_code: #{@entry_facility_zip_code.inspect},"\
  " destination_entry_facility_type: #{@destination_entry_facility_type.inspect}, shipment:"\
  " #{@shipment.inspect}, manifest_number: #{@manifest_number.inspect}, tracking_numbers:"\
  " #{@tracking_numbers.inspect}, from_address: #{@from_address.inspect}, scan_form_image:"\
  " #{@scan_form_image.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



224
225
226
227
228
229
230
231
232
233
# File 'lib/usps_api/models/scan_form_vendor_response.rb', line 224

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} image_info: #{@image_info}, form: #{@form}, image_type: #{@image_type},"\
  " label_type: #{@label_type}, mailing_date: #{@mailing_date}, overwrite_mailing_date:"\
  " #{@overwrite_mailing_date}, entry_facility_zip_code: #{@entry_facility_zip_code},"\
  " destination_entry_facility_type: #{@destination_entry_facility_type}, shipment:"\
  " #{@shipment}, manifest_number: #{@manifest_number}, tracking_numbers:"\
  " #{@tracking_numbers}, from_address: #{@from_address}, scan_form_image:"\
  " #{@scan_form_image}, additional_properties: #{@additional_properties}>"
end