Class: Samsara::Types::User
- Inherits:
-
Object
- Object
- Samsara::Types::User
- Defined in:
- lib/samsara_api/types/user.rb
Overview
A user object.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #auth_type ⇒ Samsara::Types::UserAuthType readonly
- #email ⇒ String readonly
- #id ⇒ String readonly
- #name ⇒ String readonly
- #roles ⇒ Samsara::Types::USER_ROLES readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(auth_type:, email:, id:, name:, roles:, additional_properties: nil) ⇒ Samsara::Types::User constructor
- #to_json ⇒ String
Constructor Details
#initialize(auth_type:, email:, id:, name:, roles:, additional_properties: nil) ⇒ Samsara::Types::User
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_properties ⇒ OpenStruct (readonly)
Returns 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_type ⇒ Samsara::Types::UserAuthType (readonly)
12 13 14 |
# File 'lib/samsara_api/types/user.rb', line 12 def auth_type @auth_type end |
#email ⇒ String (readonly)
14 15 16 |
# File 'lib/samsara_api/types/user.rb', line 14 def email @email end |
#id ⇒ String (readonly)
16 17 18 |
# File 'lib/samsara_api/types/user.rb', line 16 def id @id end |
#name ⇒ String (readonly)
18 19 20 |
# File 'lib/samsara_api/types/user.rb', line 18 def name @name end |
#roles ⇒ Samsara::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
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
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_json ⇒ String
72 73 74 |
# File 'lib/samsara_api/types/user.rb', line 72 def to_json @_field_set&.to_json end |