Class: IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::ModuleTokenApiModel

Inherits:
BasicActiveModel
  • Object
show all
Defined in:
lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_response = nil) ⇒ ModuleTokenApiModel

Returns a new instance of ModuleTokenApiModel.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 11

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?
  end
end

Instance Attribute Details

#clientIdObject

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

#expirationObject

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

#expiredObject

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

#messageObject

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
  @message
end

#modulesObject

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

#tenantIdObject

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

#tokenObject

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

#tokenTypeObject

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

#usernameObject

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

#uuidObject

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_errors(json_response) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 35

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



43
44
45
46
47
48
49
50
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 43

def add_messages(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



25
26
27
28
29
30
31
32
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 25

def add_modules(modules)
  @modules = []
  if modules.size > 0
    modules.each do |m|
      @modules << IdnSdkRuby::Com::Nbos::Capi::Modules::Core::V0::ModuleTokenApiModel.new(m)
    end
  end
end

#as_json(options = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 52

def as_json(options={})
  {
      username: @username,
      clientId: @clientId,
      tokenType: @tokenType,
      token: @token,
      expiration: @expiration,
      expired: @expired,
      tenantId: @tenantId,
      modules: @modules
  }
end

#to_json(*options) ⇒ Object



65
66
67
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 65

def to_json(*options)
  as_json(*options).to_json(*options)
end

#to_sObject



69
70
71
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb', line 69

def to_s
  to_json
end