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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_response = nil, is_new = true) ⇒ MemberApiModel

Returns a new instance of MemberApiModel.



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

def initialize(parsed_response = nil, is_new = true)
  if !parsed_response.nil?
    member_details = is_new ? parsed_response["member"] : parsed_response
    @isExternal = member_details["isExternal"]
    @id =  member_details["id"]
    @uuid = member_details["uuid"]
    @description = member_details["description"]
    @email = member_details["email"]
    @firstName = member_details["firstName"]
    @lastName = member_details["lastName"]
    @phone = member_details["phone"]
    add_socialAccounts(member_details["socialAccounts"])
    add_emailConnects(member_details["emailConnects"])
    @token = IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel.new(parsed_response["token"])
  end
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def description
  @description
end

#emailObject

Returns the value of attribute email.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def email
  @email
end

#emailConnectsObject

Returns the value of attribute emailConnects.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def emailConnects
  @emailConnects
end

#firstNameObject

Returns the value of attribute firstName.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def firstName
  @firstName
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def id
  @id
end

#isExternalObject

Returns the value of attribute isExternal.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def isExternal
  @isExternal
end

#lastNameObject

Returns the value of attribute lastName.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def lastName
  @lastName
end

#messageObject

Returns the value of attribute message.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def message
  @message
end

#phoneObject

Returns the value of attribute phone.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def phone
  @phone
end

#socialAccountsObject

Returns the value of attribute socialAccounts.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def socialAccounts
  @socialAccounts
end

#tokenObject

Returns the value of attribute token.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def token
  @token
end

#uuidObject

Returns the value of attribute uuid.



9
10
11
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 9

def uuid
  @uuid
end

Instance Method Details

#add_emailConnects(email_connects) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 38

def add_emailConnects(email_connects)
  @emailConnects = []
  if email_connects.size > 0
    email_connects.each do |ec|
      @emailConnects << IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::EmailConnectApiModel.new(ec)
    end
  end
end

#add_errors(json_response) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 47

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



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

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_socialAccounts(accounts) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 29

def add_socialAccounts(accounts)
  @socialAccounts = []
  if accounts.size > 0
    accounts.each do |sp|
      @socialAccounts << IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::SocialAccountApiModel.new(sp)
    end
  end
end

#as_json(options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 64

def as_json(options={})
  {
      id: @id,
      email: @email,
      firstName: @firstName,
      lastName: @lastName,
      phone: @phone,
      description: @description,
      uuid: @uuid,
      isExternal: @isExternal,
      socialAccounts: @socialAccounts,
      emailConnects: @emailConnects,
      token: @token
  }
end

#to_json(*options) ⇒ Object



80
81
82
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 80

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

#to_sObject



84
85
86
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb', line 84

def to_s
  to_json
end