Class: UspsApi::SlotAvailability

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

Overview

Request object for checking on slot availability

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(mail_class:, dropship_key:, destination_entry:, consignee_facility:, detail_info:, one_time_appt: SKIP, recurring_appt: SKIP, appointment_type: SKIP, appointment_start_date: SKIP, appointment_end_date: SKIP, apply_tiers: SKIP, perishable_ind: SKIP, user_crid: SKIP, scheduler_id: SKIP, scheduler_corp_id: SKIP, scheduler_crid: SKIP, preferred_appt: SKIP, appt_time: SKIP, day_frequency: SKIP, week_frequency: SKIP, appt_tracking_id: SKIP, comments: SKIP, scheduler_content_id: SKIP, shipper_appt_request_id: SKIP, shipper_multi_stop_id: SKIP, trailer_info: SKIP, additional_properties: nil) ⇒ SlotAvailability

Returns a new instance of SlotAvailability.



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/usps_api/models/slot_availability.rb', line 189

def initialize(mail_class:, dropship_key:, destination_entry:,
               consignee_facility:, detail_info:, one_time_appt: SKIP,
               recurring_appt: SKIP, appointment_type: SKIP,
               appointment_start_date: SKIP, appointment_end_date: SKIP,
               apply_tiers: SKIP, perishable_ind: SKIP, user_crid: SKIP,
               scheduler_id: SKIP, scheduler_corp_id: SKIP,
               scheduler_crid: SKIP, preferred_appt: SKIP, appt_time: SKIP,
               day_frequency: SKIP, week_frequency: SKIP,
               appt_tracking_id: SKIP, comments: SKIP,
               scheduler_content_id: SKIP, shipper_appt_request_id: SKIP,
               shipper_multi_stop_id: SKIP, trailer_info: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @one_time_appt = one_time_appt unless one_time_appt == SKIP
  @recurring_appt = recurring_appt unless recurring_appt == SKIP
  @mail_class = mail_class
  @dropship_key = dropship_key
  @appointment_type = appointment_type unless appointment_type == SKIP
  @appointment_start_date = appointment_start_date unless appointment_start_date == SKIP
  @appointment_end_date = appointment_end_date unless appointment_end_date == SKIP
  @destination_entry = destination_entry
  @apply_tiers = apply_tiers unless apply_tiers == SKIP
  @perishable_ind = perishable_ind unless perishable_ind == SKIP
  @user_crid = user_crid unless user_crid == SKIP
  @scheduler_id = scheduler_id unless scheduler_id == SKIP
  @scheduler_corp_id = scheduler_corp_id unless scheduler_corp_id == SKIP
  @scheduler_crid = scheduler_crid unless scheduler_crid == SKIP
  @consignee_facility = consignee_facility
  @detail_info = detail_info
  @preferred_appt = preferred_appt unless preferred_appt == SKIP
  @appt_time = appt_time unless appt_time == SKIP
  @day_frequency = day_frequency unless day_frequency == SKIP
  @week_frequency = week_frequency unless week_frequency == SKIP
  @appt_tracking_id = appt_tracking_id unless appt_tracking_id == SKIP
  @comments = comments unless comments == SKIP
  @scheduler_content_id = scheduler_content_id unless scheduler_content_id == SKIP
  @shipper_appt_request_id = shipper_appt_request_id unless shipper_appt_request_id == SKIP
  @shipper_multi_stop_id = shipper_multi_stop_id unless shipper_multi_stop_id == SKIP
  @trailer_info = trailer_info unless trailer_info == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#apply_tiersApplyTiers

The applyTiers used for the search. YES or NO

Returns:



54
55
56
# File 'lib/usps_api/models/slot_availability.rb', line 54

def apply_tiers
  @apply_tiers
end

#appointment_end_dateDateTime

The end date of the date range of the query. Maximum of 21 days in the future. Required for recurring appointments.

Returns:

  • (DateTime)


46
47
48
# File 'lib/usps_api/models/slot_availability.rb', line 46

def appointment_end_date
  @appointment_end_date
end

#appointment_start_dateDateTime

The start date of the date range of the query. Cannot be in the past. Required for recurring appointments.

Returns:

  • (DateTime)


40
41
42
# File 'lib/usps_api/models/slot_availability.rb', line 40

def appointment_start_date
  @appointment_start_date
end

#appointment_typeAppointmentType1

The type of appointment. PALLET = 1, BEDLOAD = 2, DROP_AND_PICK = 3, SPEEDLINE = 4

Returns:



35
36
37
# File 'lib/usps_api/models/slot_availability.rb', line 35

def appointment_type
  @appointment_type
end

#appt_timeString

Appointment time if on recurring appt selection path

Returns:

  • (String)


90
91
92
# File 'lib/usps_api/models/slot_availability.rb', line 90

def appt_time
  @appt_time
end

#appt_tracking_idString

ShipperApptRequestID in xml, CustomerSequenceId on one time and recurring selection paths

Returns:

  • (String)


103
104
105
# File 'lib/usps_api/models/slot_availability.rb', line 103

def appt_tracking_id
  @appt_tracking_id
end

#commentsString

Comments if on recurring appt selection path

Returns:

  • (String)


107
108
109
# File 'lib/usps_api/models/slot_availability.rb', line 107

def comments
  @comments
end

#consignee_facilityConsigneeFacility1

Consignee Facility details.

Returns:



78
79
80
# File 'lib/usps_api/models/slot_availability.rb', line 78

def consignee_facility
  @consignee_facility
end

#day_frequencyDayFrequency

Appointment daily frequency if on recurring appt selection path

Returns:



94
95
96
# File 'lib/usps_api/models/slot_availability.rb', line 94

def day_frequency
  @day_frequency
end

#destination_entryDestinationEntry

Dropship is YES. Origin Entry is NO.

Returns:



50
51
52
# File 'lib/usps_api/models/slot_availability.rb', line 50

def destination_entry
  @destination_entry
end

#detail_infoDetailInfo1

Details of the appointment for the availability request.

Returns:



82
83
84
# File 'lib/usps_api/models/slot_availability.rb', line 82

def detail_info
  @detail_info
end

#dropship_keyString

The dropship key for the appointment.

Returns:

  • (String)


30
31
32
# File 'lib/usps_api/models/slot_availability.rb', line 30

def dropship_key
  @dropship_key
end

#mail_classMailClass1

1 FIRST CLASS MAIL, 2 PERIODICALS, 3 USPS MARKETING MAIL (PREVIOUSLY STANDARD MAIL), 4 PACKAGE SERVICES, 6 PARCEL SELECT, 7 PRIORITY MAIL

Returns:



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

def mail_class
  @mail_class
end

#one_time_apptTrueClass | FalseClass

Determine query path for the search. Either oneTimeAppt or recurringAppt must be set to true.

Returns:

  • (TrueClass | FalseClass)


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

def one_time_appt
  @one_time_appt
end

#perishable_indTrueClass | FalseClass

Is it perishable

Returns:

  • (TrueClass | FalseClass)


58
59
60
# File 'lib/usps_api/models/slot_availability.rb', line 58

def perishable_ind
  @perishable_ind
end

#preferred_apptDateTime

Preferred appointment if on one time appt selection path

Returns:

  • (DateTime)


86
87
88
# File 'lib/usps_api/models/slot_availability.rb', line 86

def preferred_appt
  @preferred_appt
end

#recurring_apptTrueClass | FalseClass

Determine query path for the search. Either oneTimeAppt or recurringAppt must be set to true.

Returns:

  • (TrueClass | FalseClass)


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

def recurring_appt
  @recurring_appt
end

#scheduler_content_idString

value set in recurring appt selection path

Returns:

  • (String)


111
112
113
# File 'lib/usps_api/models/slot_availability.rb', line 111

def scheduler_content_id
  @scheduler_content_id
end

#scheduler_corp_idString

Unique ID of the corporation generated by PostalOne!

Returns:

  • (String)


70
71
72
# File 'lib/usps_api/models/slot_availability.rb', line 70

def scheduler_corp_id
  @scheduler_corp_id
end

#scheduler_cridString

CRID assigned to Scheduler of FAST Appointment

Returns:

  • (String)


74
75
76
# File 'lib/usps_api/models/slot_availability.rb', line 74

def scheduler_crid
  @scheduler_crid
end

#scheduler_idString

Unique ID for mailer scheduler

Returns:

  • (String)


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

def scheduler_id
  @scheduler_id
end

#shipper_appt_request_idString

value set in recurring appt selection path

Returns:

  • (String)


115
116
117
# File 'lib/usps_api/models/slot_availability.rb', line 115

def shipper_appt_request_id
  @shipper_appt_request_id
end

#shipper_multi_stop_idString

value set in one time appt selection path

Returns:

  • (String)


119
120
121
# File 'lib/usps_api/models/slot_availability.rb', line 119

def shipper_multi_stop_id
  @shipper_multi_stop_id
end

#trailer_infoTrailerInfo1

Information about the trailer for the appointment.

Returns:



123
124
125
# File 'lib/usps_api/models/slot_availability.rb', line 123

def trailer_info
  @trailer_info
end

#user_cridString

CRID of the user

Returns:

  • (String)


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

def user_crid
  @user_crid
end

#week_frequencyWeekFrequency

Appointment weekly frequency if on recurring appt selection path

Returns:



98
99
100
# File 'lib/usps_api/models/slot_availability.rb', line 98

def week_frequency
  @week_frequency
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/usps_api/models/slot_availability.rb', line 234

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mail_class = hash.key?('mailClass') ? hash['mailClass'] : nil
  dropship_key = hash.key?('dropshipKey') ? hash['dropshipKey'] : nil
  destination_entry =
    hash.key?('destinationEntry') ? hash['destinationEntry'] : nil
  consignee_facility = ConsigneeFacility1.from_hash(hash['consigneeFacility']) if
    hash['consigneeFacility']
  detail_info = DetailInfo1.from_hash(hash['detailInfo']) if hash['detailInfo']
  one_time_appt = hash.key?('oneTimeAppt') ? hash['oneTimeAppt'] : SKIP
  recurring_appt = hash.key?('recurringAppt') ? hash['recurringAppt'] : SKIP
  appointment_type =
    hash.key?('appointmentType') ? hash['appointmentType'] : SKIP
  appointment_start_date = if hash.key?('appointmentStartDate')
                             (DateTimeHelper.from_rfc3339(hash['appointmentStartDate']) if hash['appointmentStartDate'])
                           else
                             SKIP
                           end
  appointment_end_date = if hash.key?('appointmentEndDate')
                           (DateTimeHelper.from_rfc3339(hash['appointmentEndDate']) if hash['appointmentEndDate'])
                         else
                           SKIP
                         end
  apply_tiers = hash.key?('applyTiers') ? hash['applyTiers'] : SKIP
  perishable_ind = hash.key?('perishableInd') ? hash['perishableInd'] : SKIP
  user_crid = hash.key?('userCRID') ? hash['userCRID'] : SKIP
  scheduler_id = hash.key?('schedulerID') ? hash['schedulerID'] : SKIP
  scheduler_corp_id =
    hash.key?('schedulerCorpID') ? hash['schedulerCorpID'] : SKIP
  scheduler_crid = hash.key?('schedulerCRID') ? hash['schedulerCRID'] : SKIP
  preferred_appt = if hash.key?('preferredAppt')
                     (DateTimeHelper.from_rfc3339(hash['preferredAppt']) if hash['preferredAppt'])
                   else
                     SKIP
                   end
  appt_time = hash.key?('apptTime') ? hash['apptTime'] : SKIP
  day_frequency = hash.key?('dayFrequency') ? hash['dayFrequency'] : SKIP
  week_frequency = hash.key?('weekFrequency') ? hash['weekFrequency'] : SKIP
  appt_tracking_id =
    hash.key?('apptTrackingID') ? hash['apptTrackingID'] : SKIP
  comments = hash.key?('comments') ? hash['comments'] : SKIP
  scheduler_content_id =
    hash.key?('schedulerContentID') ? hash['schedulerContentID'] : SKIP
  shipper_appt_request_id =
    hash.key?('shipperApptRequestID') ? hash['shipperApptRequestID'] : SKIP
  shipper_multi_stop_id =
    hash.key?('shipperMultiStopID') ? hash['shipperMultiStopID'] : SKIP
  trailer_info = TrailerInfo1.from_hash(hash['trailerInfo']) if hash['trailerInfo']

  # 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.
  SlotAvailability.new(mail_class: mail_class,
                       dropship_key: dropship_key,
                       destination_entry: destination_entry,
                       consignee_facility: consignee_facility,
                       detail_info: detail_info,
                       one_time_appt: one_time_appt,
                       recurring_appt: recurring_appt,
                       appointment_type: appointment_type,
                       appointment_start_date: appointment_start_date,
                       appointment_end_date: appointment_end_date,
                       apply_tiers: apply_tiers,
                       perishable_ind: perishable_ind,
                       user_crid: user_crid,
                       scheduler_id: scheduler_id,
                       scheduler_corp_id: scheduler_corp_id,
                       scheduler_crid: scheduler_crid,
                       preferred_appt: preferred_appt,
                       appt_time: appt_time,
                       day_frequency: day_frequency,
                       week_frequency: week_frequency,
                       appt_tracking_id: appt_tracking_id,
                       comments: comments,
                       scheduler_content_id: scheduler_content_id,
                       shipper_appt_request_id: shipper_appt_request_id,
                       shipper_multi_stop_id: shipper_multi_stop_id,
                       trailer_info: trailer_info,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



126
127
128
129
130
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
# File 'lib/usps_api/models/slot_availability.rb', line 126

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['one_time_appt'] = 'oneTimeAppt'
  @_hash['recurring_appt'] = 'recurringAppt'
  @_hash['mail_class'] = 'mailClass'
  @_hash['dropship_key'] = 'dropshipKey'
  @_hash['appointment_type'] = 'appointmentType'
  @_hash['appointment_start_date'] = 'appointmentStartDate'
  @_hash['appointment_end_date'] = 'appointmentEndDate'
  @_hash['destination_entry'] = 'destinationEntry'
  @_hash['apply_tiers'] = 'applyTiers'
  @_hash['perishable_ind'] = 'perishableInd'
  @_hash['user_crid'] = 'userCRID'
  @_hash['scheduler_id'] = 'schedulerID'
  @_hash['scheduler_corp_id'] = 'schedulerCorpID'
  @_hash['scheduler_crid'] = 'schedulerCRID'
  @_hash['consignee_facility'] = 'consigneeFacility'
  @_hash['detail_info'] = 'detailInfo'
  @_hash['preferred_appt'] = 'preferredAppt'
  @_hash['appt_time'] = 'apptTime'
  @_hash['day_frequency'] = 'dayFrequency'
  @_hash['week_frequency'] = 'weekFrequency'
  @_hash['appt_tracking_id'] = 'apptTrackingID'
  @_hash['comments'] = 'comments'
  @_hash['scheduler_content_id'] = 'schedulerContentID'
  @_hash['shipper_appt_request_id'] = 'shipperApptRequestID'
  @_hash['shipper_multi_stop_id'] = 'shipperMultiStopID'
  @_hash['trailer_info'] = 'trailerInfo'
  @_hash
end

.nullablesObject

An array for nullable fields



185
186
187
# File 'lib/usps_api/models/slot_availability.rb', line 185

def self.nullables
  []
end

.optionalsObject

An array for optional fields



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/usps_api/models/slot_availability.rb', line 158

def self.optionals
  %w[
    one_time_appt
    recurring_appt
    appointment_type
    appointment_start_date
    appointment_end_date
    apply_tiers
    perishable_ind
    user_crid
    scheduler_id
    scheduler_corp_id
    scheduler_crid
    preferred_appt
    appt_time
    day_frequency
    week_frequency
    appt_tracking_id
    comments
    scheduler_content_id
    shipper_appt_request_id
    shipper_multi_stop_id
    trailer_info
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/usps_api/models/slot_availability.rb', line 353

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} one_time_appt: #{@one_time_appt.inspect}, recurring_appt:"\
  " #{@recurring_appt.inspect}, mail_class: #{@mail_class.inspect}, dropship_key:"\
  " #{@dropship_key.inspect}, appointment_type: #{@appointment_type.inspect},"\
  " appointment_start_date: #{@appointment_start_date.inspect}, appointment_end_date:"\
  " #{@appointment_end_date.inspect}, destination_entry: #{@destination_entry.inspect},"\
  " apply_tiers: #{@apply_tiers.inspect}, perishable_ind: #{@perishable_ind.inspect},"\
  " user_crid: #{@user_crid.inspect}, scheduler_id: #{@scheduler_id.inspect},"\
  " scheduler_corp_id: #{@scheduler_corp_id.inspect}, scheduler_crid:"\
  " #{@scheduler_crid.inspect}, consignee_facility: #{@consignee_facility.inspect},"\
  " detail_info: #{@detail_info.inspect}, preferred_appt: #{@preferred_appt.inspect},"\
  " appt_time: #{@appt_time.inspect}, day_frequency: #{@day_frequency.inspect},"\
  " week_frequency: #{@week_frequency.inspect}, appt_tracking_id:"\
  " #{@appt_tracking_id.inspect}, comments: #{@comments.inspect}, scheduler_content_id:"\
  " #{@scheduler_content_id.inspect}, shipper_appt_request_id:"\
  " #{@shipper_appt_request_id.inspect}, shipper_multi_stop_id:"\
  " #{@shipper_multi_stop_id.inspect}, trailer_info: #{@trailer_info.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_appointment_end_dateObject



326
327
328
# File 'lib/usps_api/models/slot_availability.rb', line 326

def to_custom_appointment_end_date
  DateTimeHelper.to_rfc3339(appointment_end_date)
end

#to_custom_appointment_start_dateObject



322
323
324
# File 'lib/usps_api/models/slot_availability.rb', line 322

def to_custom_appointment_start_date
  DateTimeHelper.to_rfc3339(appointment_start_date)
end

#to_custom_preferred_apptObject



330
331
332
# File 'lib/usps_api/models/slot_availability.rb', line 330

def to_custom_preferred_appt
  DateTimeHelper.to_rfc3339(preferred_appt)
end

#to_sObject

Provides a human-readable string representation of the object.



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/usps_api/models/slot_availability.rb', line 335

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} one_time_appt: #{@one_time_appt}, recurring_appt: #{@recurring_appt},"\
  " mail_class: #{@mail_class}, dropship_key: #{@dropship_key}, appointment_type:"\
  " #{@appointment_type}, appointment_start_date: #{@appointment_start_date},"\
  " appointment_end_date: #{@appointment_end_date}, destination_entry: #{@destination_entry},"\
  " apply_tiers: #{@apply_tiers}, perishable_ind: #{@perishable_ind}, user_crid:"\
  " #{@user_crid}, scheduler_id: #{@scheduler_id}, scheduler_corp_id: #{@scheduler_corp_id},"\
  " scheduler_crid: #{@scheduler_crid}, consignee_facility: #{@consignee_facility},"\
  " detail_info: #{@detail_info}, preferred_appt: #{@preferred_appt}, appt_time:"\
  " #{@appt_time}, day_frequency: #{@day_frequency}, week_frequency: #{@week_frequency},"\
  " appt_tracking_id: #{@appt_tracking_id}, comments: #{@comments}, scheduler_content_id:"\
  " #{@scheduler_content_id}, shipper_appt_request_id: #{@shipper_appt_request_id},"\
  " shipper_multi_stop_id: #{@shipper_multi_stop_id}, trailer_info: #{@trailer_info},"\
  " additional_properties: #{@additional_properties}>"
end