Class: UspsApi::UspsSummary

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

Overview

UspsSummary 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(destination_discount_indicator: SKIP, zone_skipping_indicator: SKIP, full_service_indicator: SKIP, e_induction_indicator: SKIP, pallets: SKIP, bedload: SKIP, perishable: SKIP, mail_class: SKIP, rate_type: SKIP, in_home_start: SKIP, in_home_end: SKIP, processing_category: SKIP, news_indicator: SKIP, priority_mail_indicator: SKIP, verification_location: SKIP, mail_content_name: SKIP, mail_preparer_id: SKIP, mail_preparer_crid: SKIP, scheduler_content_id: SKIP, consignee_content_id: SKIP, additional_properties: nil) ⇒ UspsSummary

Returns a new instance of UspsSummary.



155
156
157
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
183
184
185
186
187
188
189
190
191
192
# File 'lib/usps_api/models/usps_summary.rb', line 155

def initialize(destination_discount_indicator: SKIP,
               zone_skipping_indicator: SKIP, full_service_indicator: SKIP,
               e_induction_indicator: SKIP, pallets: SKIP, bedload: SKIP,
               perishable: SKIP, mail_class: SKIP, rate_type: SKIP,
               in_home_start: SKIP, in_home_end: SKIP,
               processing_category: SKIP, news_indicator: SKIP,
               priority_mail_indicator: SKIP, verification_location: SKIP,
               mail_content_name: SKIP, mail_preparer_id: SKIP,
               mail_preparer_crid: SKIP, scheduler_content_id: SKIP,
               consignee_content_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  unless destination_discount_indicator == SKIP
    @destination_discount_indicator =
      destination_discount_indicator
  end
  @zone_skipping_indicator = zone_skipping_indicator unless zone_skipping_indicator == SKIP
  @full_service_indicator = full_service_indicator unless full_service_indicator == SKIP
  @e_induction_indicator = e_induction_indicator unless e_induction_indicator == SKIP
  @pallets = pallets unless pallets == SKIP
  @bedload = bedload unless bedload == SKIP
  @perishable = perishable unless perishable == SKIP
  @mail_class = mail_class unless mail_class == SKIP
  @rate_type = rate_type unless rate_type == SKIP
  @in_home_start = in_home_start unless in_home_start == SKIP
  @in_home_end = in_home_end unless in_home_end == SKIP
  @processing_category = processing_category unless processing_category == SKIP
  @news_indicator = news_indicator unless news_indicator == SKIP
  @priority_mail_indicator = priority_mail_indicator unless priority_mail_indicator == SKIP
  @verification_location = verification_location unless verification_location == SKIP
  @mail_content_name = mail_content_name unless mail_content_name == SKIP
  @mail_preparer_id = mail_preparer_id unless mail_preparer_id == SKIP
  @mail_preparer_crid = mail_preparer_crid unless mail_preparer_crid == SKIP
  @scheduler_content_id = scheduler_content_id unless scheduler_content_id == SKIP
  @consignee_content_id = consignee_content_id unless consignee_content_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#bedloadBedload

Details and properties of the bedload for the appointment.

Returns:



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

def bedload
  @bedload
end

#consignee_content_idString

Consignee Content ID for this USPSSummary object

Returns:

  • (String)


95
96
97
# File 'lib/usps_api/models/usps_summary.rb', line 95

def consignee_content_id
  @consignee_content_id
end

#destination_discount_indicatorDestinationDiscountIndicator

Indicator whether this is dropship (NO) or origin entry (YES) appointment. Required for Create actions.



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

def destination_discount_indicator
  @destination_discount_indicator
end

#e_induction_indicatorEInductionIndicator

Yes/No indicator representing if IMCB is part of an eInduction Content

Returns:



28
29
30
# File 'lib/usps_api/models/usps_summary.rb', line 28

def e_induction_indicator
  @e_induction_indicator
end

#full_service_indicatorFullServiceIndicator

Indicate content is full service



24
25
26
# File 'lib/usps_api/models/usps_summary.rb', line 24

def full_service_indicator
  @full_service_indicator
end

#in_home_endDateTime

End Date of Appointment in Home DELIVERY

Returns:

  • (DateTime)


59
60
61
# File 'lib/usps_api/models/usps_summary.rb', line 59

def in_home_end
  @in_home_end
end

#in_home_startDateTime

Start Date of Appointment in Home DELIVERY

Returns:

  • (DateTime)


55
56
57
# File 'lib/usps_api/models/usps_summary.rb', line 55

def in_home_start
  @in_home_start
end

#mail_classMailClass

Required for Create actions.| Numbers represent the mailClass within legacy systems for understanding 1 FIRST CLASS MAIL 2 PERIODICALS 3 USPS MARKETING MAIL (PREVIOUSLY STANDARD MAIL) 4 PACKAGE SERVICES 6 PARCEL SELECT 7 PRIORITY MAIL

Returns:



47
48
49
# File 'lib/usps_api/models/usps_summary.rb', line 47

def mail_class
  @mail_class
end

#mail_content_nameString

Shipper assigned name to content

Returns:

  • (String)


79
80
81
# File 'lib/usps_api/models/usps_summary.rb', line 79

def mail_content_name
  @mail_content_name
end

#mail_preparer_cridString

CRID of the mail preparer

Returns:

  • (String)


87
88
89
# File 'lib/usps_api/models/usps_summary.rb', line 87

def mail_preparer_crid
  @mail_preparer_crid
end

#mail_preparer_idString

The unique ID of the mail preparer

Returns:

  • (String)


83
84
85
# File 'lib/usps_api/models/usps_summary.rb', line 83

def mail_preparer_id
  @mail_preparer_id
end

#news_indicatorNewsIndicator

Indicator for Newspaper. Required for Create actions.

Returns:



67
68
69
# File 'lib/usps_api/models/usps_summary.rb', line 67

def news_indicator
  @news_indicator
end

#palletsArray[Pallet]

Details and properties of the pallets for the appointment.

Returns:



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

def pallets
  @pallets
end

#perishablePerishable

Is it perishable. Required for Create actions.

Returns:



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

def perishable
  @perishable
end

#priority_mail_indicatorPriorityMailIndicator

Priority Mail Indicator. Required for Create actions.



71
72
73
# File 'lib/usps_api/models/usps_summary.rb', line 71

def priority_mail_indicator
  @priority_mail_indicator
end

#processing_categoryProcessingCategory

Mail shape category. Required for Create actions.

Returns:



63
64
65
# File 'lib/usps_api/models/usps_summary.rb', line 63

def processing_category
  @processing_category
end

#rate_typeRateType

Rate type describes mail class and mail shape combination

Returns:



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

def rate_type
  @rate_type
end

#scheduler_content_idString

The unique ID of the Scheduler

Returns:

  • (String)


91
92
93
# File 'lib/usps_api/models/usps_summary.rb', line 91

def scheduler_content_id
  @scheduler_content_id
end

#verification_locationVerificationLocation

Verified Location for BMEU or DMU for FAST appointment



75
76
77
# File 'lib/usps_api/models/usps_summary.rb', line 75

def verification_location
  @verification_location
end

#zone_skipping_indicatorZoneSkippingIndicator

Zone Skip in the Content of the appointment. Required for Create actions.



20
21
22
# File 'lib/usps_api/models/usps_summary.rb', line 20

def zone_skipping_indicator
  @zone_skipping_indicator
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
232
233
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
# File 'lib/usps_api/models/usps_summary.rb', line 195

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  destination_discount_indicator =
    hash.key?('destinationDiscountIndicator') ? hash['destinationDiscountIndicator'] : SKIP
  zone_skipping_indicator =
    hash.key?('zoneSkippingIndicator') ? hash['zoneSkippingIndicator'] : SKIP
  full_service_indicator =
    hash.key?('fullServiceIndicator') ? hash['fullServiceIndicator'] : SKIP
  e_induction_indicator =
    hash.key?('eInductionIndicator') ? hash['eInductionIndicator'] : SKIP
  # Parameter is an array, so we need to iterate through it
  pallets = nil
  unless hash['pallets'].nil?
    pallets = []
    hash['pallets'].each do |structure|
      pallets << (Pallet.from_hash(structure) if structure)
    end
  end

  pallets = SKIP unless hash.key?('pallets')
  bedload = Bedload.from_hash(hash['bedload']) if hash['bedload']
  perishable = hash.key?('perishable') ? hash['perishable'] : SKIP
  mail_class = hash.key?('mailClass') ? hash['mailClass'] : SKIP
  rate_type = hash.key?('rateType') ? hash['rateType'] : SKIP
  in_home_start = if hash.key?('inHomeStart')
                    (DateTimeHelper.from_rfc3339(hash['inHomeStart']) if hash['inHomeStart'])
                  else
                    SKIP
                  end
  in_home_end = if hash.key?('inHomeEnd')
                  (DateTimeHelper.from_rfc3339(hash['inHomeEnd']) if hash['inHomeEnd'])
                else
                  SKIP
                end
  processing_category =
    hash.key?('processingCategory') ? hash['processingCategory'] : SKIP
  news_indicator = hash.key?('newsIndicator') ? hash['newsIndicator'] : SKIP
  priority_mail_indicator =
    hash.key?('priorityMailIndicator') ? hash['priorityMailIndicator'] : SKIP
  verification_location =
    hash.key?('verificationLocation') ? hash['verificationLocation'] : SKIP
  mail_content_name =
    hash.key?('mailContentName') ? hash['mailContentName'] : SKIP
  mail_preparer_id =
    hash.key?('mailPreparerID') ? hash['mailPreparerID'] : SKIP
  mail_preparer_crid =
    hash.key?('mailPreparerCRID') ? hash['mailPreparerCRID'] : SKIP
  scheduler_content_id =
    hash.key?('schedulerContentID') ? hash['schedulerContentID'] : SKIP
  consignee_content_id =
    hash.key?('consigneeContentID') ? hash['consigneeContentID'] : 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.
  UspsSummary.new(destination_discount_indicator: destination_discount_indicator,
                  zone_skipping_indicator: zone_skipping_indicator,
                  full_service_indicator: full_service_indicator,
                  e_induction_indicator: e_induction_indicator,
                  pallets: pallets,
                  bedload: bedload,
                  perishable: perishable,
                  mail_class: mail_class,
                  rate_type: rate_type,
                  in_home_start: in_home_start,
                  in_home_end: in_home_end,
                  processing_category: processing_category,
                  news_indicator: news_indicator,
                  priority_mail_indicator: priority_mail_indicator,
                  verification_location: verification_location,
                  mail_content_name: mail_content_name,
                  mail_preparer_id: mail_preparer_id,
                  mail_preparer_crid: mail_preparer_crid,
                  scheduler_content_id: scheduler_content_id,
                  consignee_content_id: consignee_content_id,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/usps_api/models/usps_summary.rb', line 98

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['destination_discount_indicator'] =
    'destinationDiscountIndicator'
  @_hash['zone_skipping_indicator'] = 'zoneSkippingIndicator'
  @_hash['full_service_indicator'] = 'fullServiceIndicator'
  @_hash['e_induction_indicator'] = 'eInductionIndicator'
  @_hash['pallets'] = 'pallets'
  @_hash['bedload'] = 'bedload'
  @_hash['perishable'] = 'perishable'
  @_hash['mail_class'] = 'mailClass'
  @_hash['rate_type'] = 'rateType'
  @_hash['in_home_start'] = 'inHomeStart'
  @_hash['in_home_end'] = 'inHomeEnd'
  @_hash['processing_category'] = 'processingCategory'
  @_hash['news_indicator'] = 'newsIndicator'
  @_hash['priority_mail_indicator'] = 'priorityMailIndicator'
  @_hash['verification_location'] = 'verificationLocation'
  @_hash['mail_content_name'] = 'mailContentName'
  @_hash['mail_preparer_id'] = 'mailPreparerID'
  @_hash['mail_preparer_crid'] = 'mailPreparerCRID'
  @_hash['scheduler_content_id'] = 'schedulerContentID'
  @_hash['consignee_content_id'] = 'consigneeContentID'
  @_hash
end

.nullablesObject

An array for nullable fields



151
152
153
# File 'lib/usps_api/models/usps_summary.rb', line 151

def self.nullables
  []
end

.optionalsObject

An array for optional fields



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/usps_api/models/usps_summary.rb', line 125

def self.optionals
  %w[
    destination_discount_indicator
    zone_skipping_indicator
    full_service_indicator
    e_induction_indicator
    pallets
    bedload
    perishable
    mail_class
    rate_type
    in_home_start
    in_home_end
    processing_category
    news_indicator
    priority_mail_indicator
    verification_location
    mail_content_name
    mail_preparer_id
    mail_preparer_crid
    scheduler_content_id
    consignee_content_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/usps_api/models/usps_summary.rb', line 305

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} destination_discount_indicator: #{@destination_discount_indicator.inspect},"\
  " zone_skipping_indicator: #{@zone_skipping_indicator.inspect}, full_service_indicator:"\
  " #{@full_service_indicator.inspect}, e_induction_indicator:"\
  " #{@e_induction_indicator.inspect}, pallets: #{@pallets.inspect}, bedload:"\
  " #{@bedload.inspect}, perishable: #{@perishable.inspect}, mail_class:"\
  " #{@mail_class.inspect}, rate_type: #{@rate_type.inspect}, in_home_start:"\
  " #{@in_home_start.inspect}, in_home_end: #{@in_home_end.inspect}, processing_category:"\
  " #{@processing_category.inspect}, news_indicator: #{@news_indicator.inspect},"\
  " priority_mail_indicator: #{@priority_mail_indicator.inspect}, verification_location:"\
  " #{@verification_location.inspect}, mail_content_name: #{@mail_content_name.inspect},"\
  " mail_preparer_id: #{@mail_preparer_id.inspect}, mail_preparer_crid:"\
  " #{@mail_preparer_crid.inspect}, scheduler_content_id: #{@scheduler_content_id.inspect},"\
  " consignee_content_id: #{@consignee_content_id.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_in_home_endObject



284
285
286
# File 'lib/usps_api/models/usps_summary.rb', line 284

def to_custom_in_home_end
  DateTimeHelper.to_rfc3339(in_home_end)
end

#to_custom_in_home_startObject



280
281
282
# File 'lib/usps_api/models/usps_summary.rb', line 280

def to_custom_in_home_start
  DateTimeHelper.to_rfc3339(in_home_start)
end

#to_sObject

Provides a human-readable string representation of the object.



289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/usps_api/models/usps_summary.rb', line 289

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} destination_discount_indicator: #{@destination_discount_indicator},"\
  " zone_skipping_indicator: #{@zone_skipping_indicator}, full_service_indicator:"\
  " #{@full_service_indicator}, e_induction_indicator: #{@e_induction_indicator}, pallets:"\
  " #{@pallets}, bedload: #{@bedload}, perishable: #{@perishable}, mail_class: #{@mail_class},"\
  " rate_type: #{@rate_type}, in_home_start: #{@in_home_start}, in_home_end: #{@in_home_end},"\
  " processing_category: #{@processing_category}, news_indicator: #{@news_indicator},"\
  " priority_mail_indicator: #{@priority_mail_indicator}, verification_location:"\
  " #{@verification_location}, mail_content_name: #{@mail_content_name}, mail_preparer_id:"\
  " #{@mail_preparer_id}, mail_preparer_crid: #{@mail_preparer_crid}, scheduler_content_id:"\
  " #{@scheduler_content_id}, consignee_content_id: #{@consignee_content_id},"\
  " additional_properties: #{@additional_properties}>"
end