Class: Crisphive::Technician

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Technician

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::Technician` 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::Technician`. 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?(:'address')
    self.address = attributes[:'address']
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#addressObject

Technician's start-location postal address.



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

def address
  @address
end

#assignment_tierObject

Smart-assignment tier, or null if unset.



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

def assignment_tier
  @assignment_tier
end

#buddy_idsObject

UUIDs of this technician's buddies (the techs they prefer to work alongside).



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

def buddy_ids
  @buddy_ids
end

#business_group_idObject

UUID of the permission group (role) this technician is assigned to.



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

def business_group_id
  @business_group_id
end

#business_idObject

UUID of the business this technician belongs to.



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

def business_id
  @business_id
end

#created_atObject

When the technician record was created (RFC3339).



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

def created_at
  @created_at
end

#deleted_atObject

Set (RFC3339) only when the technician has been soft-removed; omitted otherwise.



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

def deleted_at
  @deleted_at
end

#emailObject

Email address; null if not set.



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

def email
  @email
end

#full_nameObject

Technician's full name.



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

def full_name
  @full_name
end

#idObject

Technician membership UUID — the stable identifier used in every technician endpoint.



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

def id
  @id
end

#job_titleObject

Free-form job title (e.g. "Senior HVAC Technician"). Empty if unset.



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

def job_title
  @job_title
end

#join_dateObject

Date the technician joined (YYYY-MM-DD); null if unset.



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

def join_date
  @join_date
end

#last_login_atObject

When the technician last logged in (RFC3339); null if never.



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

def 
  @last_login_at
end

#leadsObject

Leads this technician is a buddy of (id + name).



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

def leads
  @leads
end

#phoneObject

Phone number in the form it was supplied; null if not set.



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

def phone
  @phone
end

#roleObject

Resolved role/group name (e.g. "Technician", "Owner").



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

def role
  @role
end

#service_areasObject

Service areas this technician is assigned to (id + name).



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

def service_areas
  @service_areas
end

#start_location_latObject

Start-location latitude in decimal degrees; null if no coordinates are saved.



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

def start_location_lat
  @start_location_lat
end

#start_location_longObject

Start-location longitude in decimal degrees; null if no coordinates are saved.



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

def start_location_long
  @start_location_long
end

#start_location_typeObject

Where the technician's day starts: "home" (their address) or "office" (the business address). Null if unset.



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

def start_location_type
  @start_location_type
end

#statusObject

Membership lifecycle status.



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

def status
  @status
end

#updated_atObject

When the technician record was last modified (RFC3339).



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

def updated_at
  @updated_at
end

#user_idObject

UUID of the underlying user account.



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

def user_id
  @user_id
end

#vehicle_idsObject

UUIDs of the vehicles this technician uses.



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

def vehicle_ids
  @vehicle_ids
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



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/crisphive/models/technician.rb', line 412

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



143
144
145
# File 'lib/crisphive/models/technician.rb', line 143

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/crisphive/models/technician.rb', line 113

def self.attribute_map
  {
    :'address' => :'address',
    :'assignment_tier' => :'assignment_tier',
    :'buddy_ids' => :'buddy_ids',
    :'business_group_id' => :'business_group_id',
    :'business_id' => :'business_id',
    :'created_at' => :'created_at',
    :'deleted_at' => :'deleted_at',
    :'email' => :'email',
    :'full_name' => :'full_name',
    :'id' => :'id',
    :'job_title' => :'job_title',
    :'join_date' => :'join_date',
    :'last_login_at' => :'last_login_at',
    :'leads' => :'leads',
    :'phone' => :'phone',
    :'role' => :'role',
    :'service_areas' => :'service_areas',
    :'start_location_lat' => :'start_location_lat',
    :'start_location_long' => :'start_location_long',
    :'start_location_type' => :'start_location_type',
    :'status' => :'status',
    :'updated_at' => :'updated_at',
    :'user_id' => :'user_id',
    :'vehicle_ids' => :'vehicle_ids'
  }
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



388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/crisphive/models/technician.rb', line 388

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



178
179
180
181
# File 'lib/crisphive/models/technician.rb', line 178

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

.openapi_typesObject

Attribute type mapping.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/crisphive/models/technician.rb', line 148

def self.openapi_types
  {
    :'address' => :'TechnicianAddress',
    :'assignment_tier' => :'String',
    :'buddy_ids' => :'Array<String>',
    :'business_group_id' => :'String',
    :'business_id' => :'String',
    :'created_at' => :'Time',
    :'deleted_at' => :'Time',
    :'email' => :'String',
    :'full_name' => :'String',
    :'id' => :'String',
    :'job_title' => :'String',
    :'join_date' => :'Date',
    :'last_login_at' => :'Time',
    :'leads' => :'Array<TechnicianLeadRef>',
    :'phone' => :'String',
    :'role' => :'String',
    :'service_areas' => :'Array<TechnicianServiceAreaRef>',
    :'start_location_lat' => :'Float',
    :'start_location_long' => :'Float',
    :'start_location_type' => :'String',
    :'status' => :'TechnicianStatus',
    :'updated_at' => :'Time',
    :'user_id' => :'String',
    :'vehicle_ids' => :'Array<String>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/crisphive/models/technician.rb', line 344

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      address == o.address &&
      assignment_tier == o.assignment_tier &&
      buddy_ids == o.buddy_ids &&
      business_group_id == o.business_group_id &&
      business_id == o.business_id &&
      created_at == o.created_at &&
      deleted_at == o.deleted_at &&
      email == o.email &&
      full_name == o.full_name &&
      id == o.id &&
      job_title == o.job_title &&
      join_date == o.join_date &&
       == o. &&
      leads == o.leads &&
      phone == o.phone &&
      role == o.role &&
      service_areas == o.service_areas &&
      start_location_lat == o.start_location_lat &&
      start_location_long == o.start_location_long &&
      start_location_type == o.start_location_type &&
      status == o.status &&
      updated_at == o.updated_at &&
      user_id == o.user_id &&
      vehicle_ids == o.vehicle_ids
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



483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/crisphive/models/technician.rb', line 483

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


375
376
377
# File 'lib/crisphive/models/technician.rb', line 375

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



381
382
383
# File 'lib/crisphive/models/technician.rb', line 381

def hash
  [address, assignment_tier, buddy_ids, business_group_id, business_id, created_at, deleted_at, email, full_name, id, job_title, join_date, , leads, phone, role, service_areas, start_location_lat, start_location_long, start_location_type, status, updated_at, user_id, vehicle_ids].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



305
306
307
308
309
# File 'lib/crisphive/models/technician.rb', line 305

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



459
460
461
# File 'lib/crisphive/models/technician.rb', line 459

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



465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/crisphive/models/technician.rb', line 465

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



453
454
455
# File 'lib/crisphive/models/technician.rb', line 453

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



313
314
315
316
317
318
319
320
# File 'lib/crisphive/models/technician.rb', line 313

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  assignment_tier_validator = EnumAttributeValidator.new('String', ["lead", "buddy", "float"])
  return false unless assignment_tier_validator.valid?(@assignment_tier)
  start_location_type_validator = EnumAttributeValidator.new('String', ["home", "office"])
  return false unless start_location_type_validator.valid?(@start_location_type)
  true
end