Class: ShellCardManagementApIs::Role

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_card_management_ap_is/models/role.rb

Overview

Role Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(role_name = SKIP, is_customer_admin = true, is_customer_user = false, is_shell_admin = false, is_service_account = false, is_user_admin = true) ⇒ Role

Returns a new instance of Role.



67
68
69
70
71
72
73
74
75
76
# File 'lib/shell_card_management_ap_is/models/role.rb', line 67

def initialize(role_name = SKIP, is_customer_admin = true,
               is_customer_user = false, is_shell_admin = false,
                = false, is_user_admin = true)
  @role_name = role_name unless role_name == SKIP
  @is_customer_admin = is_customer_admin unless is_customer_admin == SKIP
  @is_customer_user = is_customer_user unless is_customer_user == SKIP
  @is_shell_admin = is_shell_admin unless is_shell_admin == SKIP
  @is_service_account =  unless  == SKIP
  @is_user_admin = is_user_admin unless is_user_admin == SKIP
end

Instance Attribute Details

#is_customer_adminTrueClass | FalseClass

Whether the role is an administrator.

Returns:

  • (TrueClass | FalseClass)


18
19
20
# File 'lib/shell_card_management_ap_is/models/role.rb', line 18

def is_customer_admin
  @is_customer_admin
end

#is_customer_userTrueClass | FalseClass

Whether the role is a customer user.

Returns:

  • (TrueClass | FalseClass)


22
23
24
# File 'lib/shell_card_management_ap_is/models/role.rb', line 22

def is_customer_user
  @is_customer_user
end

#is_service_accountTrueClass | FalseClass

True/False. True if the role is Service accounts, else false.

Returns:

  • (TrueClass | FalseClass)


31
32
33
# File 'lib/shell_card_management_ap_is/models/role.rb', line 31

def 
  @is_service_account
end

#is_shell_adminTrueClass | FalseClass

True if the role is Shell user, else false.

Returns:

  • (TrueClass | FalseClass)


26
27
28
# File 'lib/shell_card_management_ap_is/models/role.rb', line 26

def is_shell_admin
  @is_shell_admin
end

#is_user_adminTrueClass | FalseClass

True/False. True, if the role allows user administration, else false.

Returns:

  • (TrueClass | FalseClass)


36
37
38
# File 'lib/shell_card_management_ap_is/models/role.rb', line 36

def is_user_admin
  @is_user_admin
end

#role_nameString

Role Name of the user

Returns:

  • (String)


14
15
16
# File 'lib/shell_card_management_ap_is/models/role.rb', line 14

def role_name
  @role_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/shell_card_management_ap_is/models/role.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  role_name = hash.key?('RoleName') ? hash['RoleName'] : SKIP
  is_customer_admin = hash['IsCustomerAdmin'] ||= true
  is_customer_user = hash['IsCustomerUser'] ||= false
  is_shell_admin = hash['IsShellAdmin'] ||= false
   = hash['IsServiceAccount'] ||= false
  is_user_admin = hash['IsUserAdmin'] ||= true

  # Create object from extracted values.
  Role.new(role_name,
           is_customer_admin,
           is_customer_user,
           is_shell_admin,
           ,
           is_user_admin)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/shell_card_management_ap_is/models/role.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['role_name'] = 'RoleName'
  @_hash['is_customer_admin'] = 'IsCustomerAdmin'
  @_hash['is_customer_user'] = 'IsCustomerUser'
  @_hash['is_shell_admin'] = 'IsShellAdmin'
  @_hash['is_service_account'] = 'IsServiceAccount'
  @_hash['is_user_admin'] = 'IsUserAdmin'
  @_hash
end

.nullablesObject

An array for nullable fields



63
64
65
# File 'lib/shell_card_management_ap_is/models/role.rb', line 63

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
57
58
59
60
# File 'lib/shell_card_management_ap_is/models/role.rb', line 51

def self.optionals
  %w[
    role_name
    is_customer_admin
    is_customer_user
    is_shell_admin
    is_service_account
    is_user_admin
  ]
end