Class: Crisphive::JobRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/crisphive/models/job_request.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ JobRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/crisphive/models/job_request.rb', line 210

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::JobRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::JobRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'action_audit')
    if (value = attributes[:'action_audit']).is_a?(Hash)
      self.action_audit = value
    end
  end

  if attributes.key?(:'address')
    self.address = attributes[:'address']
  end

  if attributes.key?(:'archive')
    self.archive = attributes[:'archive']
  end

  if attributes.key?(:'assigned_vehicle')
    self.assigned_vehicle = attributes[:'assigned_vehicle']
  end

  if attributes.key?(:'assignment')
    self.assignment = attributes[:'assignment']
  end

  if attributes.key?(:'business_id')
    self.business_id = attributes[:'business_id']
  end

  if attributes.key?(:'completed_at')
    self.completed_at = attributes[:'completed_at']
  end

  if attributes.key?(:'completed_by_user_id')
    self.completed_by_user_id = attributes[:'completed_by_user_id']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'crew')
    if (value = attributes[:'crew']).is_a?(Array)
      self.crew = value
    end
  end

  if attributes.key?(:'current_status')
    self.current_status = attributes[:'current_status']
  end

  if attributes.key?(:'customer')
    self.customer = attributes[:'customer']
  end

  if attributes.key?(:'customer_url')
    self.customer_url = attributes[:'customer_url']
  end

  if attributes.key?(:'deleted_at')
    self.deleted_at = attributes[:'deleted_at']
  end

  if attributes.key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'job_type_id')
    self.job_type_id = attributes[:'job_type_id']
  end

  if attributes.key?(:'job_type_name')
    self.job_type_name = attributes[:'job_type_name']
  end

  if attributes.key?(:'next_actions')
    if (value = attributes[:'next_actions']).is_a?(Array)
      self.next_actions = value
    end
  end

  if attributes.key?(:'priority')
    self.priority = attributes[:'priority']
  end

  if attributes.key?(:'quote')
    self.quote = attributes[:'quote']
  end

  if attributes.key?(:'rating')
    self.rating = attributes[:'rating']
  end

  if attributes.key?(:'schedule')
    self.schedule = attributes[:'schedule']
  end

  if attributes.key?(:'short_code')
    self.short_code = attributes[:'short_code']
  end

  if attributes.key?(:'skills')
    if (value = attributes[:'skills']).is_a?(Array)
      self.skills = value
    end
  end

  if attributes.key?(:'status_version')
    self.status_version = attributes[:'status_version']
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end

  if attributes.key?(:'workflow_id')
    self.workflow_id = attributes[:'workflow_id']
  end

  if attributes.key?(:'workflow_name')
    self.workflow_name = attributes[:'workflow_name']
  end
end

Instance Attribute Details

#action_auditObject

ActionAudit is the per-action audit log keyed by action_key. complete fixed action không xuất hiện ở đây — actor lookup qua CompletedByUserID.



19
20
21
# File 'lib/crisphive/models/job_request.rb', line 19

def action_audit
  @action_audit
end

#addressObject

The job's service address snapshot.



22
23
24
# File 'lib/crisphive/models/job_request.rb', line 22

def address
  @address
end

#archiveObject

The job's archive state.



25
26
27
# File 'lib/crisphive/models/job_request.rb', line 25

def archive
  @archive
end

#assigned_vehicleObject

AssignedVehicle is the carpool vehicle (the lead drives). Omitted when the job has no vehicle.



28
29
30
# File 'lib/crisphive/models/job_request.rb', line 28

def assigned_vehicle
  @assigned_vehicle
end

#assignmentObject

Who/what is assigned to the job.



31
32
33
# File 'lib/crisphive/models/job_request.rb', line 31

def assignment
  @assignment
end

#business_idObject

UUID of the owning business.



34
35
36
# File 'lib/crisphive/models/job_request.rb', line 34

def business_id
  @business_id
end

#completed_atObject

When the job was completed (UTC); null until completed.



37
38
39
# File 'lib/crisphive/models/job_request.rb', line 37

def completed_at
  @completed_at
end

#completed_by_user_idObject

UUID of the user who fired complete; null until completed.



40
41
42
# File 'lib/crisphive/models/job_request.rb', line 40

def completed_by_user_id
  @completed_by_user_id
end

#created_atObject

When the job was created (UTC).



43
44
45
# File 'lib/crisphive/models/job_request.rb', line 43

def created_at
  @created_at
end

#crewObject

Crew is the multi-person crew on the job (lead first). A single-person job has one member. Omitted when no session plan exists.



46
47
48
# File 'lib/crisphive/models/job_request.rb', line 46

def crew
  @crew
end

#current_statusObject

The job's current workflow status.



49
50
51
# File 'lib/crisphive/models/job_request.rb', line 49

def current_status
  @current_status
end

#customerObject

The job's customer contact snapshot.



52
53
54
# File 'lib/crisphive/models/job_request.rb', line 52

def customer
  @customer
end

#customer_urlObject

Ready-to-share customer URL embedding the magic token. Omitted if not issued.



55
56
57
# File 'lib/crisphive/models/job_request.rb', line 55

def customer_url
  @customer_url
end

#deleted_atObject

When the job was soft-deleted (UTC); omitted unless deleted.



58
59
60
# File 'lib/crisphive/models/job_request.rb', line 58

def deleted_at
  @deleted_at
end

#descriptionObject

Free-text job description; null if none.



61
62
63
# File 'lib/crisphive/models/job_request.rb', line 61

def description
  @description
end

#idObject

Job request UUID.



64
65
66
# File 'lib/crisphive/models/job_request.rb', line 64

def id
  @id
end

#job_type_idObject

UUID of the job type, or null if unclassified.



67
68
69
# File 'lib/crisphive/models/job_request.rb', line 67

def job_type_id
  @job_type_id
end

#job_type_nameObject

Job type display name (resolved to locale). Omitted if unclassified.



70
71
72
# File 'lib/crisphive/models/job_request.rb', line 70

def job_type_name
  @job_type_name
end

#next_actionsObject

The action(s) the job is currently waiting on. Omitted in a terminal status.



73
74
75
# File 'lib/crisphive/models/job_request.rb', line 73

def next_actions
  @next_actions
end

#priorityObject

Job priority.



76
77
78
# File 'lib/crisphive/models/job_request.rb', line 76

def priority
  @priority
end

#quoteObject

The time-bundle quoted for the job.



79
80
81
# File 'lib/crisphive/models/job_request.rb', line 79

def quote
  @quote
end

#ratingObject

The customer's rating of the completed job.



82
83
84
# File 'lib/crisphive/models/job_request.rb', line 82

def rating
  @rating
end

#scheduleObject

When/how the job is scheduled and its per-day plan.



85
86
87
# File 'lib/crisphive/models/job_request.rb', line 85

def schedule
  @schedule
end

#short_codeObject

Human-friendly short code. Omitted if not assigned.



88
89
90
# File 'lib/crisphive/models/job_request.rb', line 88

def short_code
  @short_code
end

#skillsObject

Desired skills for the job (resolved id+name).



91
92
93
# File 'lib/crisphive/models/job_request.rb', line 91

def skills
  @skills
end

#status_versionObject

Optimistic-lock version; pass back as status_version on transitions to avoid races.



94
95
96
# File 'lib/crisphive/models/job_request.rb', line 94

def status_version
  @status_version
end

#updated_atObject

When the job was last modified (UTC).



97
98
99
# File 'lib/crisphive/models/job_request.rb', line 97

def updated_at
  @updated_at
end

#workflow_idObject

UUID of the workflow snapshot driving this job's state machine.



100
101
102
# File 'lib/crisphive/models/job_request.rb', line 100

def workflow_id
  @workflow_id
end

#workflow_nameObject

Workflow display name.



103
104
105
# File 'lib/crisphive/models/job_request.rb', line 103

def workflow_name
  @workflow_name
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/crisphive/models/job_request.rb', line 450

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Crisphive.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



163
164
165
# File 'lib/crisphive/models/job_request.rb', line 163

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



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
156
157
158
159
160
# File 'lib/crisphive/models/job_request.rb', line 128

def self.attribute_map
  {
    :'action_audit' => :'action_audit',
    :'address' => :'address',
    :'archive' => :'archive',
    :'assigned_vehicle' => :'assigned_vehicle',
    :'assignment' => :'assignment',
    :'business_id' => :'business_id',
    :'completed_at' => :'completed_at',
    :'completed_by_user_id' => :'completed_by_user_id',
    :'created_at' => :'created_at',
    :'crew' => :'crew',
    :'current_status' => :'current_status',
    :'customer' => :'customer',
    :'customer_url' => :'customer_url',
    :'deleted_at' => :'deleted_at',
    :'description' => :'description',
    :'id' => :'id',
    :'job_type_id' => :'job_type_id',
    :'job_type_name' => :'job_type_name',
    :'next_actions' => :'next_actions',
    :'priority' => :'priority',
    :'quote' => :'quote',
    :'rating' => :'rating',
    :'schedule' => :'schedule',
    :'short_code' => :'short_code',
    :'skills' => :'skills',
    :'status_version' => :'status_version',
    :'updated_at' => :'updated_at',
    :'workflow_id' => :'workflow_id',
    :'workflow_name' => :'workflow_name'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/crisphive/models/job_request.rb', line 426

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



203
204
205
206
# File 'lib/crisphive/models/job_request.rb', line 203

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



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
# File 'lib/crisphive/models/job_request.rb', line 168

def self.openapi_types
  {
    :'action_audit' => :'Hash<String, JobRequestActionAuditEntry>',
    :'address' => :'JobRequestAddressSummary',
    :'archive' => :'JobRequestArchiveSummary',
    :'assigned_vehicle' => :'JobRequestAssignedVehicle',
    :'assignment' => :'JobRequestAssignmentSummary',
    :'business_id' => :'String',
    :'completed_at' => :'Time',
    :'completed_by_user_id' => :'String',
    :'created_at' => :'Time',
    :'crew' => :'Array<JobRequestCrewMember>',
    :'current_status' => :'JobRequestStatusSummary',
    :'customer' => :'JobRequestCustomerSummary',
    :'customer_url' => :'String',
    :'deleted_at' => :'Time',
    :'description' => :'String',
    :'id' => :'String',
    :'job_type_id' => :'String',
    :'job_type_name' => :'String',
    :'next_actions' => :'Array<JobRequestActionSummary>',
    :'priority' => :'String',
    :'quote' => :'JobRequestQuoteSummary',
    :'rating' => :'JobRequestRatingSummary',
    :'schedule' => :'JobRequestSchedule',
    :'short_code' => :'String',
    :'skills' => :'Array<JobRequestSkillSummary>',
    :'status_version' => :'Integer',
    :'updated_at' => :'Time',
    :'workflow_id' => :'String',
    :'workflow_name' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/crisphive/models/job_request.rb', line 377

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      action_audit == o.action_audit &&
      address == o.address &&
      archive == o.archive &&
      assigned_vehicle == o.assigned_vehicle &&
      assignment == o.assignment &&
      business_id == o.business_id &&
      completed_at == o.completed_at &&
      completed_by_user_id == o.completed_by_user_id &&
      created_at == o.created_at &&
      crew == o.crew &&
      current_status == o.current_status &&
      customer == o.customer &&
      customer_url == o.customer_url &&
      deleted_at == o.deleted_at &&
      description == o.description &&
      id == o.id &&
      job_type_id == o.job_type_id &&
      job_type_name == o.job_type_name &&
      next_actions == o.next_actions &&
      priority == o.priority &&
      quote == o.quote &&
      rating == o.rating &&
      schedule == o.schedule &&
      short_code == o.short_code &&
      skills == o.skills &&
      status_version == o.status_version &&
      updated_at == o.updated_at &&
      workflow_id == o.workflow_id &&
      workflow_name == o.workflow_name
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/crisphive/models/job_request.rb', line 521

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


413
414
415
# File 'lib/crisphive/models/job_request.rb', line 413

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



419
420
421
# File 'lib/crisphive/models/job_request.rb', line 419

def hash
  [action_audit, address, archive, assigned_vehicle, assignment, business_id, completed_at, completed_by_user_id, created_at, crew, current_status, customer, customer_url, deleted_at, description, id, job_type_id, job_type_name, next_actions, priority, quote, rating, schedule, short_code, skills, status_version, updated_at, workflow_id, workflow_name].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



350
351
352
353
354
# File 'lib/crisphive/models/job_request.rb', line 350

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



497
498
499
# File 'lib/crisphive/models/job_request.rb', line 497

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/crisphive/models/job_request.rb', line 503

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



491
492
493
# File 'lib/crisphive/models/job_request.rb', line 491

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



358
359
360
361
362
363
# File 'lib/crisphive/models/job_request.rb', line 358

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  priority_validator = EnumAttributeValidator.new('String', ["normal", "emergency"])
  return false unless priority_validator.valid?(@priority)
  true
end