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

Inherits:
Object
  • Object
show all
Includes:
HTTMultiParty
Defined in:
lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb

Constant Summary collapse

FACEBOOK_LOGIN_URI =

Api Server Social Authentication End Point URIs

"/api/identity/v0/auth/social/facebook/connect"
GOOGLE_LOGIN_URI =
"/api/identity/v0/auth/social/googlePlus/connect"
TWITER_LOGIN_URI =
"/api/identity/v0/auth/social/twitter/connect"
GITHUB_LOGIN_URI =
"/api/identity/v0/auth/social/gitHub/connect"
LINKEDIN_LOGIN_URI =
"/api/identity/v0/auth/social/linkedIn/connect"
INSTAGRAM_LOGIN_URI =
"/api/identity/v0/auth/social/instagram/connect"
INVALID_SOCIAL_URI =
"/api/identity/v0/auth/social/invalid/connect"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIdentityRemoteApi

Returns a new instance of IdentityRemoteApi.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 30

def initialize()
	@baseIdentityUrl = "/api/identity/v0"
	@tokenUrl = "/oauth/token"
	@tokenVerifyUrl = "/api/oauth/v0/tokens"
	@loginUrl = @baseIdentityUrl + "/auth/login"
	@signupUrl = @baseIdentityUrl + "/users/signup"
	@profileUrl = @baseIdentityUrl + "/users"
	@forgotUrl = @baseIdentityUrl + "/auth/forgotPassword"
	@changeUrl = @baseIdentityUrl + "/auth/changePassword"
	@logoutUrl = @baseIdentityUrl + "/auth/logout"
	@connectUrl = @baseIdentityUrl + "/auth/social/{connectService}/connect"
	@authorizeUrl = @baseIdentityUrl + "/auth/social/{authorizeService}/authorize"
	@socialLoginUrl = @baseIdentityUrl + "/auth/social/{loginService}/login"
end

Instance Attribute Details

#authorizeUrlObject

Returns the value of attribute authorizeUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def authorizeUrl
  @authorizeUrl
end

#baseIdentityUrlObject

Returns the value of attribute baseIdentityUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def baseIdentityUrl
  @baseIdentityUrl
end

#changeUrlObject

Returns the value of attribute changeUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def changeUrl
  @changeUrl
end

#connectUrlObject

Returns the value of attribute connectUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def connectUrl
  @connectUrl
end

#forgotUrlObject

Returns the value of attribute forgotUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def forgotUrl
  @forgotUrl
end

#host_urlObject

Returns the value of attribute host_url.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def host_url
  @host_url
end

#loginUrlObject

Returns the value of attribute loginUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def loginUrl
  @loginUrl
end

#logoutUrlObject

Returns the value of attribute logoutUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def logoutUrl
  @logoutUrl
end

#profileUrlObject

Returns the value of attribute profileUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def profileUrl
  @profileUrl
end

#signupUrlObject

Returns the value of attribute signupUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def signupUrl
  @signupUrl
end

#socialLoginUrlObject

Returns the value of attribute socialLoginUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def socialLoginUrl
  @socialLoginUrl
end

#tokenUrlObject

Returns the value of attribute tokenUrl.



11
12
13
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 11

def tokenUrl
  @tokenUrl
end

Instance Method Details

#authorizeObject



83
84
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 83

def authorize
end

#connect(authorization, oauth_details, connectService, clientId) ⇒ Object



86
87
88
89
90
91
92
93
94
95
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 86

def connect(authorization, oauth_details, connectService, clientId)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	@connect_service = (connectService)
	body = { :clientId => clientId,
					 :accessToken => oauth_details[:credentials][:token],
					 :expiresIn => "#{oauth_details[:credentials][:expires_at]}"
	}
	response = self.class.send("post", @host_url+@connect_service, :body => body.to_json, :headers => {"Authorization" => "Bearer " + authorization})
	return response
end

#get_social_login_uri(provider) ⇒ Object

Method to return end point URI for specific social login



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 117

def (provider)
	case provider
		when "facebook"
			FACEBOOK_LOGIN_URI
		when "google_oauth2"
			GOOGLE_LOGIN_URI
		when "twitter"
			TWITER_LOGIN_URI
		when "github"
			GITHUB_LOGIN_URI
		when "linkedin"
			LINKEDIN_LOGIN_URI
		when "instagram"
			INSTAGRAM_LOGIN_URI
		else
			INVALID_SOCIAL_URI
	end
end

#getMemberDetails(authorization, uuid) ⇒ Object



103
104
105
106
107
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 103

def getMemberDetails(authorization, uuid)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	response = self.class.send("get", @host_url+@profileUrl+"/#{uuid}", :headers => {"Authorization" => "Bearer " + authorization})
	return response
end

#getToken(clientId, clientSecret, grantType, scope = nil) ⇒ Object



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

def getToken(clientId, clientSecret, grantType, scope = nil)
	scope = scope.nil? ? [] : scope
	body = {:client_id => clientId, :client_secret => clientSecret, :grant_type => grantType, :scope => scope}
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	response = self.class.send("post", @host_url+@tokenUrl, :body => body, :headers => {"Accept" => "application/json"})
	return response
end

#login(authorization, loginModel) ⇒ Object



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

def (authorization, loginModel)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	body = loginModel.to_s
	response = self.class.send("post", @host_url+@loginUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
	return response
end

#logout(authorization) ⇒ Object



97
98
99
100
101
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 97

def logout(authorization)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil? #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
	response = self.class.send("get", @host_url+@logoutUrl, :headers => {"Authorization" => "Bearer " + authorization})
	return response
end

#refreshAccessTokenObject



53
54
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 53

def refreshAccessToken
end

#resetCredentialsObject



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

def resetCredentials
end

#signup(authorization, memberSignupModel) ⇒ Object



63
64
65
66
67
68
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 63

def (authorization, memberSignupModel)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	body = memberSignupModel.to_s
	response = self.class.send("post", @host_url+@signupUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
	return response
end

#socialWebViewLoginObject



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

def socialWebViewLogin
end

#tokenVerify(authorization, tokenToVerify, module_key) ⇒ Object



136
137
138
139
140
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 136

def tokenVerify(authorization, tokenToVerify, module_key)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	response = self.class.send("get", @host_url+@tokenVerifyUrl+"/#{tokenToVerify}", :headers => {"Authorization" => "Bearer " + authorization, "X-N-ModuleKey" => module_key})
	return response
end

#updateCredentials(authorization, updatePasswordApiModel) ⇒ Object



73
74
75
76
77
78
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 73

def updateCredentials(authorization,updatePasswordApiModel)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	body = updatePasswordApiModel.to_s
	response = self.class.send("post", @host_url+@changeUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
	return response
end

#updateMemberDetails(authorization, uuid, memberApiModel) ⇒ Object



109
110
111
112
113
114
# File 'lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api.rb', line 109

def updateMemberDetails(authorization, uuid, memberApiModel)
	@host_url = "http://api.qa1.nbos.io" if @host_url.nil?
	body = memberApiModel.to_s
	response = self.class.send("put", @host_url+@profileUrl+"/#{uuid}", :body => body, :headers => {"Authorization" => "Bearer " + authorization})
	return response
end