Class: Samsara::Types::User

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

Overview

A user object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_type:, email:, id:, name:, roles:, additional_properties: nil) ⇒ Samsara::Types::User

Parameters:



36
37
38
39
40
41
42
43
44
# File 'lib/samsara_api/types/user.rb', line 36

def initialize(auth_type:, email:, id:, name:, roles:, additional_properties: nil)
  @auth_type = auth_type
  @email = email
  @id = id
  @name = name
  @roles = roles
  @additional_properties = additional_properties
  @_field_set = { "authType": auth_type, "email": email, "id": id, "name": name, "roles": roles }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



22
23
24
# File 'lib/samsara_api/types/user.rb', line 22

def additional_properties
  @additional_properties
end

#auth_typeSamsara::Types::UserAuthType (readonly)



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

def auth_type
  @auth_type
end

#emailString (readonly)

Returns:

  • (String)


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

def email
  @email
end

#idString (readonly)

Returns:

  • (String)


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

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


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

def name
  @name
end

#rolesSamsara::Types::USER_ROLES (readonly)



20
21
22
# File 'lib/samsara_api/types/user.rb', line 20

def roles
  @roles
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/samsara_api/types/user.rb', line 49

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  auth_type = parsed_json["authType"]
  email = parsed_json["email"]
  id = parsed_json["id"]
  name = parsed_json["name"]
  roles = parsed_json["roles"]&.map do | item |
  item = item.to_json
  Samsara::Types::UserRoleAssignment.from_json(json_object: item)
end
  new(
    auth_type: auth_type,
    email: email,
    id: id,
    name: name,
    roles: roles,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


81
82
83
84
85
86
87
# File 'lib/samsara_api/types/user.rb', line 81

def self.validate_raw(obj:)
  obj.auth_type.is_a?(Samsara::Types::UserAuthType) != false || raise("Passed value for field obj.auth_type is not the expected type, validation failed.")
  obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id 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.roles.is_a?(Array) != false || raise("Passed value for field obj.roles is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


72
73
74
# File 'lib/samsara_api/types/user.rb', line 72

def to_json
  @_field_set&.to_json
end