Class: Samsara::Types::FormsPersonObjectResponseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/forms_person_object_response_body.rb

Overview

Tracked or untracked (i.e. manually entered) person object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry_type:, name: OMIT, polymorphic_user_id: OMIT, additional_properties: nil) ⇒ Samsara::Types::FormsPersonObjectResponseBody

Parameters:



30
31
32
33
34
35
36
37
38
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 30

def initialize(entry_type:, name: OMIT, polymorphic_user_id: OMIT, additional_properties: nil)
  @entry_type = entry_type
  @name = name if name != OMIT
  @polymorphic_user_id = polymorphic_user_id if polymorphic_user_id != OMIT
  @additional_properties = additional_properties
  @_field_set = { "entryType": entry_type, "name": name, "polymorphicUserId": polymorphic_user_id }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



18
19
20
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 18

def additional_properties
  @additional_properties
end

#entry_type ⇒ Samsara::Types::FormsPersonObjectResponseBodyEntryType (readonly)

Returns The type of entry for the person. Valid values: tracked, untracked.

Returns:



12
13
14
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 12

def entry_type
  @entry_type
end

#name ⇒ String (readonly)

Returns Name of an untracked (i.e. manually entered) person.

Returns:

  • (String) —

    Name of an untracked (i.e. manually entered) person.



14
15
16
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 14

def name
  @name
end

#polymorphic_user_id ⇒ Samsara::Types::FormsPolymorphicUserObjectResponseBody (readonly)



16
17
18
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 16

def polymorphic_user_id
  @polymorphic_user_id
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::FormsPersonObjectResponseBody

Parameters:

  • json_object (String)

Returns:



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 43

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  entry_type = parsed_json["entryType"]
  name = parsed_json["name"]
  unless parsed_json["polymorphicUserId"].nil?
    polymorphic_user_id = parsed_json["polymorphicUserId"].to_json
    polymorphic_user_id = Samsara::Types::FormsPolymorphicUserObjectResponseBody.from_json(json_object: polymorphic_user_id)
  else
    polymorphic_user_id = nil
  end
  new(
    entry_type: entry_type,
    name: name,
    polymorphic_user_id: polymorphic_user_id,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


73
74
75
76
77
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 73

def self.validate_raw(obj:)
  obj.entry_type.is_a?(Samsara::Types::FormsPersonObjectResponseBodyEntryType) != false || raise("Passed value for field obj.entry_type is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.polymorphic_user_id.nil? || Samsara::Types::FormsPolymorphicUserObjectResponseBody.validate_raw(obj: obj.polymorphic_user_id)
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


64
65
66
# File 'lib/samsara_api/types/forms_person_object_response_body.rb', line 64

def to_json
  @_field_set&.to_json
end