idn_sdk_ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/idn_sdk_ruby.gemspec +32 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/abstract_api_context.rb +25 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/api_context.rb +50 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/idn_sdk.rb +26 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/in_memory_api_context.rb +57 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/network_api.rb +73 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/network_callback.rb +4 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/api/v0/token_api_model.rb +54 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/core/v0/module_api_model.rb +27 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/basic_active_model.rb +20 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/email_connect_api_model.rb +43 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_api.rb +168 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_ids_registry.rb +21 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb +146 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/login_model.rb +57 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb +95 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_signup_model.rb +60 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/new_member_api_model.rb +36 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/reset_password_model.rb +17 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/social_account_api_model.rb +47 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/social_connect_api_model.rb +18 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/update_password_api_model.rb +54 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/ids/v0/ids.rb +56 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/ids/v0/ids_api.rb +48 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/ids/v0/ids_api_model.rb +26 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/ids/v0/ids_client.rb +19 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/ids/v0/ids_remote_api.rb +42 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_api.rb +62 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_api_model.rb +63 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_details.rb +17 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_file_details.rb +39 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_ids_registry.rb +20 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_info.rb +17 -0
- data/lib/idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_remote_api.rb +47 -0
- data/lib/idn_sdk_ruby/version.rb +3 -0
- data/lib/idn_sdk_ruby.rb +33 -0
- metadata +201 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
module IdnSdkRuby
|
2
|
+
module Com
|
3
|
+
module Nbos
|
4
|
+
module Capi
|
5
|
+
module Modules
|
6
|
+
module Identity
|
7
|
+
module V0
|
8
|
+
class IdentityApi < IdnSdkRuby::Com::Nbos::Capi::Api::V0::NetworkApi
|
9
|
+
attr_accessor :remoteApiObj
|
10
|
+
|
11
|
+
def initialize()
|
12
|
+
super()
|
13
|
+
setModuleName("identity")
|
14
|
+
setRemoteApiClass(IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::IdentityRemoteApi)
|
15
|
+
@remoteApiObj = getRemoteApiClass().new
|
16
|
+
end
|
17
|
+
|
18
|
+
def getClientToken()
|
19
|
+
remoteApi = @remoteApiObj
|
20
|
+
map = @apiContext.getClientCredentials()
|
21
|
+
clientId = map["client_id"]
|
22
|
+
secret = map["client_secret"]
|
23
|
+
response = remoteApi.getToken(clientId, secret, "client_credentials")
|
24
|
+
if response.code == 200
|
25
|
+
tokenApiModel = IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel.new(response.parsed_response)
|
26
|
+
@apiContext.setClientToken(tokenApiModel)
|
27
|
+
return tokenApiModel
|
28
|
+
else
|
29
|
+
return response.parsed_response
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def login(loginModel)
|
34
|
+
remoteApi = @remoteApiObj
|
35
|
+
authorization = @apiContext.getClientToken.getAccess_token()
|
36
|
+
response = remoteApi.login(authorization, loginModel)
|
37
|
+
if response.code == 200
|
38
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response)
|
39
|
+
@apiContext.setUserToken('identity', memberApiModel.token.getAccess_token)
|
40
|
+
{ status: 200, member: memberApiModel}
|
41
|
+
elsif response.code == 400
|
42
|
+
loginModel.add_errors(response.parsed_response)
|
43
|
+
{ status: 400, member: nil, login: loginModel}
|
44
|
+
else
|
45
|
+
loginModel.add_messages(response.parsed_response)
|
46
|
+
{ status: response.code, login: loginModel}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def signup(memberSignupModel)
|
51
|
+
remoteApi = @remoteApiObj
|
52
|
+
authorization = @apiContext.getClientToken.getAccess_token()
|
53
|
+
response = remoteApi.signup(authorization, memberSignupModel)
|
54
|
+
|
55
|
+
if response.code == 200
|
56
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response)
|
57
|
+
@apiContext.setUserToken('identity', memberApiModel.token.getAccess_token)
|
58
|
+
{status: 200, member: memberApiModel}
|
59
|
+
elsif response.code == 400
|
60
|
+
memberSignupModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberSignupModel.new
|
61
|
+
memberSignupModel.add_errors(response.parsed_response)
|
62
|
+
{status: response.code, member: memberSignupModel}
|
63
|
+
else
|
64
|
+
memberSignupModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberSignupModel.new
|
65
|
+
memberSignupModel.add_messages(response.parsed_response)
|
66
|
+
{status: response.code, member: memberApiModel}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def connect(oauth_details, connectService)
|
71
|
+
remoteApi = @remoteApiObj
|
72
|
+
authorization = @apiContext.getClientToken.getAccess_token()
|
73
|
+
map = @apiContext.getClientCredentials()
|
74
|
+
clientId = map["client_id"]
|
75
|
+
response = remoteApi.connect(authorization, oauth_details, connectService, clientId)
|
76
|
+
|
77
|
+
if response.code == 200
|
78
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response)
|
79
|
+
@apiContext.setUserToken('identity', memberApiModel.token.getAccess_token)
|
80
|
+
{ status: 200, login: memberApiModel}
|
81
|
+
elsif response.code == 400
|
82
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new
|
83
|
+
memberApiModel.add_errors(response.parsed_response)
|
84
|
+
{ status: 400, login: memberApiModel}
|
85
|
+
else
|
86
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new
|
87
|
+
memberApiModel.add_messages(response.parsed_response)
|
88
|
+
{ status: response.code, login: memberApiModel}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def authorize(authorizeService, code, state, callback)
|
93
|
+
end
|
94
|
+
|
95
|
+
def getMemberDetails(uuid)
|
96
|
+
remoteApi = @remoteApiObj
|
97
|
+
authorization = @apiContext.getUserToken('identity')
|
98
|
+
response = remoteApi.getMemberDetails(authorization, uuid)
|
99
|
+
|
100
|
+
if response.code == 200
|
101
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response, false)
|
102
|
+
{status: 200, member: memberApiModel}
|
103
|
+
else
|
104
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(nil, false)
|
105
|
+
memberApiModel.add_messages(response.parsed_response)
|
106
|
+
{ status: response.code, member: memberApiModel}
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def updateMemberDetails(uuid, memberApiModel)
|
111
|
+
remoteApi = @remoteApiObj
|
112
|
+
authorization = @apiContext.getUserToken('identity')
|
113
|
+
response = remoteApi.updateMemberDetails(authorization, uuid, memberApiModel)
|
114
|
+
|
115
|
+
if response.code == 200
|
116
|
+
memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response, false)
|
117
|
+
{status: 200, member: memberApiModel}
|
118
|
+
elsif response.code == 400
|
119
|
+
memberApiModel.add_errors(api_response.parsed_response)
|
120
|
+
{status: 400, member: memberApiModel}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def updateCredentials(updatePasswordApiModel)
|
125
|
+
remoteApi = @remoteApiObj
|
126
|
+
authorization = @apiContext.getUserToken('identity')
|
127
|
+
response = remoteApi.updateCredentials(authorization, updatePasswordApiModel)
|
128
|
+
|
129
|
+
if response.code == 400
|
130
|
+
updatePasswordApiModel.add_errors(response.parsed_response)
|
131
|
+
{ status: 400, login: updatePasswordApiModel}
|
132
|
+
else
|
133
|
+
updatePasswordApiModel.add_messages(response.parsed_response)
|
134
|
+
{ status: response.code, login: updatePasswordApiModel}
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def resetCredentials(resetPasswordModel, callback)
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
def logout
|
143
|
+
remoteApi = @remoteApiObj
|
144
|
+
authorization = @apiContext.getUserToken('identity')
|
145
|
+
response = remoteApi.logout(authorization)
|
146
|
+
loginModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::LoginModel.new
|
147
|
+
if response.code == 200
|
148
|
+
@apiContext.setUserToken('identity', nil)
|
149
|
+
loginModel.add_messages(response.parsed_response)
|
150
|
+
{status: 200, login: loginModel}
|
151
|
+
else
|
152
|
+
loginModel.add_messages(response.parsed_response)
|
153
|
+
{status: response.code, login: loginModel}
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def socialWebViewLogin(connectService, callback)
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_api"
|
2
|
+
|
3
|
+
module IdnSdkRuby
|
4
|
+
module Com
|
5
|
+
module Nbos
|
6
|
+
module Capi
|
7
|
+
module Modules
|
8
|
+
module Identity
|
9
|
+
module V0
|
10
|
+
class IdentityIdsRegistry
|
11
|
+
def initialize()
|
12
|
+
IdnSdkRuby::Com::Nbos::Capi::Modules::Ids::V0::Ids.register("identity", IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::IdentityApi)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'httmultiparty'
|
2
|
+
|
3
|
+
module IdnSdkRuby
|
4
|
+
module Com
|
5
|
+
module Nbos
|
6
|
+
module Capi
|
7
|
+
module Modules
|
8
|
+
module Identity
|
9
|
+
module V0
|
10
|
+
class IdentityRemoteApi
|
11
|
+
attr_accessor :baseIdentityUrl, :tokenUrl, :loginUrl, :logoutUrl, :signupUrl,
|
12
|
+
:connectUrl, :authorizeUrl, :profileUrl, :forgotUrl, :changeUrl,
|
13
|
+
:socialLoginUrl, :host_url
|
14
|
+
|
15
|
+
# Api Server Social Authentication End Point URIs
|
16
|
+
FACEBOOK_LOGIN_URI = "/api/identity/v0/auth/social/facebook/connect"
|
17
|
+
GOOGLE_LOGIN_URI = "/api/identity/v0/auth/social/googlePlus/connect"
|
18
|
+
TWITER_LOGIN_URI = "/api/identity/v0/auth/social/twitter/connect"
|
19
|
+
GITHUB_LOGIN_URI = "/api/identity/v0/auth/social/gitHub/connect"
|
20
|
+
LINKEDIN_LOGIN_URI = "/api/identity/v0/auth/social/linkedIn/connect"
|
21
|
+
INSTAGRAM_LOGIN_URI = "/api/identity/v0/auth/social/instagram/connect"
|
22
|
+
INVALID_SOCIAL_URI = "/api/identity/v0/auth/social/invalid/connect"
|
23
|
+
|
24
|
+
include HTTMultiParty
|
25
|
+
|
26
|
+
headers 'Accept' => 'application/json', 'Content-Type' => 'application/json'
|
27
|
+
|
28
|
+
debug_output $stdout
|
29
|
+
|
30
|
+
def initialize()
|
31
|
+
@baseIdentityUrl = "/api/identity/v0"
|
32
|
+
@tokenUrl = "/oauth/token"
|
33
|
+
@loginUrl = @baseIdentityUrl + "/auth/login"
|
34
|
+
@signupUrl = @baseIdentityUrl + "/users/signup"
|
35
|
+
@profileUrl = @baseIdentityUrl + "/users"
|
36
|
+
@forgotUrl = @baseIdentityUrl + "/auth/forgotPassword"
|
37
|
+
@changeUrl = @baseIdentityUrl + "/auth/changePassword"
|
38
|
+
@logoutUrl = @baseIdentityUrl + "/auth/logout"
|
39
|
+
@connectUrl = @baseIdentityUrl + "/auth/social/{connectService}/connect"
|
40
|
+
@authorizeUrl = @baseIdentityUrl + "/auth/social/{authorizeService}/authorize"
|
41
|
+
@socialLoginUrl = @baseIdentityUrl + "/auth/social/{loginService}/login"
|
42
|
+
end
|
43
|
+
|
44
|
+
def getToken(clientId, clientSecret, grantType)
|
45
|
+
query_params = {:client_id => clientId, :client_secret => clientSecret, :grant_type => grantType}
|
46
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
47
|
+
response = self.class.send("get", @host_url+@tokenUrl, :query => query_params)
|
48
|
+
return response
|
49
|
+
end
|
50
|
+
|
51
|
+
def refreshAccessToken
|
52
|
+
end
|
53
|
+
|
54
|
+
def login(authorization, loginModel)
|
55
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
56
|
+
body = loginModel.to_s
|
57
|
+
#response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
|
58
|
+
response = self.class.send("post", @host_url+@loginUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
|
59
|
+
return response
|
60
|
+
end
|
61
|
+
|
62
|
+
def signup(authorization, memberSignupModel)
|
63
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
64
|
+
body = memberSignupModel.to_s
|
65
|
+
#response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
|
66
|
+
response = self.class.send("post", @host_url+@signupUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
|
67
|
+
return response
|
68
|
+
end
|
69
|
+
|
70
|
+
def resetCredentials
|
71
|
+
end
|
72
|
+
|
73
|
+
def updateCredentials(authorization,updatePasswordApiModel)
|
74
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
75
|
+
#response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
|
76
|
+
body = updatePasswordApiModel.to_s
|
77
|
+
response = self.class.send("post", @host_url+@changeUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
|
78
|
+
return response
|
79
|
+
end
|
80
|
+
|
81
|
+
def socialWebViewLogin
|
82
|
+
end
|
83
|
+
|
84
|
+
def authorize
|
85
|
+
end
|
86
|
+
|
87
|
+
def connect(authorization, oauth_details, connectService, clientId)
|
88
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
89
|
+
@connect_service = get_social_login_uri(connectService)
|
90
|
+
body = { :clientId => clientId,
|
91
|
+
:accessToken => oauth_details[:credentials][:token],
|
92
|
+
:expiresIn => "#{oauth_details[:credentials][:expires_at]}"
|
93
|
+
}
|
94
|
+
response = self.class.send("post", @host_url+@connect_service, :body => body.to_json, :headers => {"Authorization" => "Bearer " + authorization})
|
95
|
+
return response
|
96
|
+
end
|
97
|
+
|
98
|
+
def logout(authorization)
|
99
|
+
@host_url = "http://localhost:8080" if @host_url.nil? #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
|
100
|
+
response = self.class.send("get", @host_url+@logoutUrl, :headers => {"Authorization" => "Bearer " + authorization})
|
101
|
+
return response
|
102
|
+
end
|
103
|
+
|
104
|
+
def getMemberDetails(authorization, uuid)
|
105
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
106
|
+
#response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
|
107
|
+
response = self.class.send("get", @host_url+@profileUrl+"/#{uuid}", :headers => {"Authorization" => "Bearer " + authorization})
|
108
|
+
return response
|
109
|
+
end
|
110
|
+
|
111
|
+
def updateMemberDetails(authorization, uuid, memberApiModel)
|
112
|
+
@host_url = "http://localhost:8080" if @host_url.nil?
|
113
|
+
#response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
|
114
|
+
body = memberApiModel.to_s
|
115
|
+
response = self.class.send("put", @host_url+@profileUrl+"/#{uuid}", :body => body, :headers => {"Authorization" => "Bearer " + authorization})
|
116
|
+
return response
|
117
|
+
end
|
118
|
+
|
119
|
+
# Method to return end point URI for specific social login
|
120
|
+
def get_social_login_uri(provider)
|
121
|
+
case provider
|
122
|
+
when "facebook"
|
123
|
+
FACEBOOK_LOGIN_URI
|
124
|
+
when "google_oauth2"
|
125
|
+
GOOGLE_LOGIN_URI
|
126
|
+
when "twitter"
|
127
|
+
TWITER_LOGIN_URI
|
128
|
+
when "github"
|
129
|
+
GITHUB_LOGIN_URI
|
130
|
+
when "linkedin"
|
131
|
+
LINKEDIN_LOGIN_URI
|
132
|
+
when "instagram"
|
133
|
+
INSTAGRAM_LOGIN_URI
|
134
|
+
else
|
135
|
+
INVALID_SOCIAL_URI
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/basic_active_model"
|
2
|
+
module IdnSdkRuby
|
3
|
+
module Com
|
4
|
+
module Nbos
|
5
|
+
module Capi
|
6
|
+
module Modules
|
7
|
+
module Identity
|
8
|
+
module V0
|
9
|
+
class LoginModel < IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::BasicActiveModel
|
10
|
+
attr_accessor :username, :password, :messageCode, :message
|
11
|
+
|
12
|
+
def initialize(name = nil, code = nil)
|
13
|
+
@username = name
|
14
|
+
@password = code
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_errors(json_response)
|
18
|
+
json_response["errors"].each do |e|
|
19
|
+
property_name = e['propertyName']
|
20
|
+
msg = e['message']
|
21
|
+
self.errors[property_name] << msg
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_messages(json_response)
|
26
|
+
if json_response["message"].present?
|
27
|
+
@message = json_response["message"]
|
28
|
+
elsif json_response["error"].present?
|
29
|
+
@message = json_response["error"]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def as_json(options={})
|
35
|
+
{
|
36
|
+
username: @username,
|
37
|
+
password: @password,
|
38
|
+
messageCode: @messageCode,
|
39
|
+
message: @message
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_json(*options)
|
44
|
+
as_json(*options).to_json(*options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
to_json
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module IdnSdkRuby
|
2
|
+
module Com
|
3
|
+
module Nbos
|
4
|
+
module Capi
|
5
|
+
module Modules
|
6
|
+
module Identity
|
7
|
+
module V0
|
8
|
+
class MemberApiModel < IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::BasicActiveModel
|
9
|
+
attr_accessor :id, :email, :firstName, :lastName, :phone, :description, :uuid, :isExternal,
|
10
|
+
:socialAccounts, :emailConnects, :token, :message
|
11
|
+
|
12
|
+
def initialize(parsed_response = nil, is_new = true)
|
13
|
+
if !parsed_response.nil?
|
14
|
+
member_details = is_new ? parsed_response["member"] : parsed_response
|
15
|
+
@isExternal = member_details["isExternal"]
|
16
|
+
@id = member_details["id"]
|
17
|
+
@uuid = member_details["uuid"]
|
18
|
+
@description = member_details["description"]
|
19
|
+
@email = member_details["email"]
|
20
|
+
@firstName = member_details["firstName"]
|
21
|
+
@lastName = member_details["lastName"]
|
22
|
+
@phone = member_details["phone"]
|
23
|
+
add_socialAccounts(member_details["socialAccounts"])
|
24
|
+
add_emailConnects(member_details["emailConnects"])
|
25
|
+
token_details = parsed_response["token"].nil? ? nil : parsed_response["token"]
|
26
|
+
@token = IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel.new(parsed_response["token"])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_socialAccounts(accounts)
|
31
|
+
@socialAccounts = []
|
32
|
+
if accounts.size > 0
|
33
|
+
accounts.each do |sp|
|
34
|
+
@socialAccounts << IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::SocialAccountApiModel.new(sp)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_emailConnects(email_connects)
|
40
|
+
@emailConnects = []
|
41
|
+
if email_connects.size > 0
|
42
|
+
email_connects.each do |ec|
|
43
|
+
@emailConnects << IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::EmailConnectApiModel.new(ec)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_errors(json_response)
|
49
|
+
json_response["errors"].each do |e|
|
50
|
+
property_name = e['propertyName']
|
51
|
+
msg = e['message']
|
52
|
+
self.errors[property_name] << msg
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_messages(json_response)
|
57
|
+
if json_response["message"].present?
|
58
|
+
@message = json_response["message"]
|
59
|
+
elsif json_response["error"].present?
|
60
|
+
@message = json_response["error"]
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def as_json(options={})
|
66
|
+
{
|
67
|
+
id: @id,
|
68
|
+
email: @email,
|
69
|
+
firstName: @firstName,
|
70
|
+
lastName: @lastName,
|
71
|
+
phone: @phone,
|
72
|
+
description: @description,
|
73
|
+
uuid: @uuid,
|
74
|
+
isExternal: @isExternal,
|
75
|
+
socialAccounts: @socialAccounts,
|
76
|
+
emailConnects: @emailConnects,
|
77
|
+
token: @token
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_json(*options)
|
82
|
+
as_json(*options).to_json(*options)
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_s
|
86
|
+
to_json
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module IdnSdkRuby
|
2
|
+
module Com
|
3
|
+
module Nbos
|
4
|
+
module Capi
|
5
|
+
module Modules
|
6
|
+
module Identity
|
7
|
+
module V0
|
8
|
+
class MemberSignupModel < IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::BasicActiveModel
|
9
|
+
attr_accessor :username, :email, :password, :firstName, :lastName, :jsonAttributes, :message
|
10
|
+
|
11
|
+
def initialize(userName = nil, passWord = nil, eMail = nil, first_name = nil, last_name = nil)
|
12
|
+
@username = userName
|
13
|
+
@email = eMail
|
14
|
+
@password = passWord
|
15
|
+
@firstName = first_name
|
16
|
+
@lastName = last_name
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_errors(json_response)
|
20
|
+
json_response["errors"].each do |e|
|
21
|
+
property_name = e['propertyName']
|
22
|
+
msg = e['message']
|
23
|
+
self.errors[property_name] << msg
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_messages(json_response)
|
28
|
+
if json_response["message"].present?
|
29
|
+
@message = json_response["message"]
|
30
|
+
elsif json_response["error"].present?
|
31
|
+
@message = json_response["error"]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def as_json(options={})
|
37
|
+
{
|
38
|
+
username: @username,
|
39
|
+
password: @password,
|
40
|
+
firstName: @firstName,
|
41
|
+
lastName: @lastName,
|
42
|
+
email: @email
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_json(*options)
|
47
|
+
as_json(*options).to_json(*options)
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
to_json
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module IdnSdkRuby
|
2
|
+
module Com
|
3
|
+
module Nbos
|
4
|
+
module Capi
|
5
|
+
module Modules
|
6
|
+
module Identity
|
7
|
+
module V0
|
8
|
+
class NewMemberApiModel
|
9
|
+
attr_accessor :member, :token
|
10
|
+
def initialize(parsed_response = nil)
|
11
|
+
if parsed_response !=nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def as_json(options={})
|
16
|
+
{
|
17
|
+
member: @member,
|
18
|
+
roken: @token
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*options)
|
23
|
+
as_json(*options).to_json(*options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module IdnSdkRuby
|
2
|
+
module Com
|
3
|
+
module Nbos
|
4
|
+
module Capi
|
5
|
+
module Modules
|
6
|
+
module Identity
|
7
|
+
module V0
|
8
|
+
|
9
|
+
class SocialAccountApiModel
|
10
|
+
attr_accessor :id, :email, :socialType, :imageUrl, :accessToken
|
11
|
+
|
12
|
+
def initialize(social_params = nil)
|
13
|
+
if social_params != nil
|
14
|
+
@id = social_params["id"]
|
15
|
+
@email = social_params["email"]
|
16
|
+
@socialType = social_params["socialType"]
|
17
|
+
@imageUrl = social_params["imageUrl"]
|
18
|
+
@accessToken = social_params["accessToken"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def as_json(options={})
|
24
|
+
{
|
25
|
+
id: @id,
|
26
|
+
email: @email,
|
27
|
+
socialType: @socialType,
|
28
|
+
imageUrl: @imageUrl,
|
29
|
+
accessToken: @accessToken
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_json(*options)
|
34
|
+
as_json(*options).to_json(*options)
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module IdnSdkRuby
|
2
|
+
module Com
|
3
|
+
module Nbos
|
4
|
+
module Capi
|
5
|
+
module Modules
|
6
|
+
module Identity
|
7
|
+
module V0
|
8
|
+
class SocialConnectApiModel
|
9
|
+
attr_accessor :clientId, :accessToken, :expiresIn
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|