Class: IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::ModuleTokenApiModel
- Inherits:
-
BasicActiveModel
- Object
- BasicActiveModel
- IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::ModuleTokenApiModel
- Defined in:
- lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb
Instance Attribute Summary collapse
-
#authorities ⇒ Object
Returns the value of attribute authorities.
-
#clientId ⇒ Object
Returns the value of attribute clientId.
-
#expiration ⇒ Object
Returns the value of attribute expiration.
-
#expired ⇒ Object
Returns the value of attribute expired.
-
#message ⇒ Object
Returns the value of attribute message.
-
#modules ⇒ Object
Returns the value of attribute modules.
-
#tenantId ⇒ Object
Returns the value of attribute tenantId.
-
#token ⇒ Object
Returns the value of attribute token.
-
#tokenType ⇒ Object
Returns the value of attribute tokenType.
-
#username ⇒ Object
Returns the value of attribute username.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Instance Method Summary collapse
- #add_authorities(authorities) ⇒ Object
- #add_errors(json_response) ⇒ Object
- #add_messages(json_response) ⇒ Object
- #add_modules(modules) ⇒ Object
- #as_json(options = {}) ⇒ Object
- #get_authorities ⇒ Object
- #get_modules ⇒ Object
- #has_authorities? ⇒ Boolean
-
#initialize(parsed_response = nil) ⇒ ModuleTokenApiModel
constructor
A new instance of ModuleTokenApiModel.
- #is_member? ⇒ Boolean
- #to_json(*options) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(parsed_response = nil) ⇒ ModuleTokenApiModel
Returns a new instance of ModuleTokenApiModel.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 13 def initialize(parsed_response = nil) if !parsed_response.nil? @username = parsed_response['username'] @clientId = parsed_response['clientId'] @tokenType = parsed_response['tokenType'] @token = parsed_response['token'] @expiration = parsed_response['expiration'] @expired = parsed_response['expired'] @tenantId = parsed_response['tenantId'] @uuid = parsed_response['member']['uuid'] if parsed_response['member'].present? @modules = add_modules(parsed_response['modules']) if parsed_response['modules'].present? @authorities = (parsed_response['authorities']) if parsed_response['authorities'].present? end end |
Instance Attribute Details
#authorities ⇒ Object
Returns the value of attribute authorities.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def @authorities end |
#clientId ⇒ Object
Returns the value of attribute clientId.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def clientId @clientId end |
#expiration ⇒ Object
Returns the value of attribute expiration.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def expiration @expiration end |
#expired ⇒ Object
Returns the value of attribute expired.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def expired @expired end |
#message ⇒ Object
Returns the value of attribute message.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def @message end |
#modules ⇒ Object
Returns the value of attribute modules.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def modules @modules end |
#tenantId ⇒ Object
Returns the value of attribute tenantId.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def tenantId @tenantId end |
#token ⇒ Object
Returns the value of attribute token.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def token @token end |
#tokenType ⇒ Object
Returns the value of attribute tokenType.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def tokenType @tokenType end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def username @username end |
#uuid ⇒ Object
Returns the value of attribute uuid.
9 10 11 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 9 def uuid @uuid end |
Instance Method Details
#add_authorities(authorities) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 50 def () @authorities = [] if .size > 0 .each do |at| auth = IdnSdkRuby::Com::Nbos::Capi::Modules::Core::V0::AuthorityApiModel.new(at["uAuthorityName"], at["displayName"], at["description"]) @authorities << auth end end end |
#add_errors(json_response) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 88 def add_errors(json_response) json_response["errors"].each do |e| property_name = e['propertyName'] msg = e['message'] self.errors[property_name] << msg end end |
#add_messages(json_response) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 96 def (json_response) if json_response["message"].present? @message = json_response["message"] elsif json_response["error"].present? @message = json_response["error"] end end |
#add_modules(modules) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 28 def add_modules(modules) @modules = [] if modules.size > 0 modules.each do |m| mod = IdnSdkRuby::Com::Nbos::Capi::Modules::Core::V0::ModuleApiModel.new(m["uuid"], m["name"]) @modules << mod end end end |
#as_json(options = {}) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 105 def as_json(={}) { username: @username, clientId: @clientId, tokenType: @tokenType, token: @token, expiration: @expiration, expired: @expired, tenantId: @tenantId, modules: @modules, uuid: @uuid } end |
#get_authorities ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 60 def if self..present? ms = [] self..each do |m| ms << m["uAuthorityName"] end ms else [] end end |
#get_modules ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 38 def get_modules if self.modules.present? ms = [] self.modules.each do |m| ms << m["name"] end ms else [] end end |
#has_authorities? ⇒ Boolean
80 81 82 83 84 85 86 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 80 def if self..present? true else false end end |
#is_member? ⇒ Boolean
72 73 74 75 76 77 78 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 72 def is_member? if self.uuid.present? true else false end end |
#to_json(*options) ⇒ Object
119 120 121 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 119 def to_json(*) as_json(*).to_json(*) end |
#to_s ⇒ Object
123 124 125 |
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 123 def to_s to_json end |