Class: App42::User::UserService
- Inherits:
-
Object
- Object
- App42::User::UserService
- Defined in:
- lib/user/UserService.rb
Overview
Creates User for the App. App42 Cloud API’s provides a complete User Management for any Mobile or Web App. It supports User registration, retrieval, state management e.g. lock, delete and Authentication.
Along with User Management the platform provides API’s for persistent SessionManagement
Instance Method Summary collapse
-
#assign_roles(user_name, role_list) ⇒ Object
Add Role for the App.
-
#authenticate(uName, pwd) ⇒ Object
Authenticate user based on userName and password.
-
#change_user_password(user_name, old_password, new_password) ⇒ Object
Change the password for user based on the userName.
-
#create_or_update_profile(user) ⇒ Object
Creates or Updates User Profile.
-
#create_user(user_name, pwd, email_address) ⇒ Object
Variable should be snake case.
-
#create_user_with_role(user_name, pwd, email_address, role_list) ⇒ Object
Create User for the App.
-
#delete_user(user_name) ⇒ Object
Deletes a particular user based on userName.
-
#fill_params_with_profile_data(profileData) ⇒ Object
Builds a Parameter string from the profileData.
-
#get_all_users ⇒ Object
Gets All users details.
-
#get_all_users_by_paging(max, offset) ⇒ Object
Gets All users By Paging.
-
#get_all_users_count ⇒ Object
Gets the count of all the users.
-
#get_locked_users ⇒ Object
Gets All the locked users details.
-
#get_locked_users_by_paging(max, offset) ⇒ Object
Gets All the locked users By paging details.
-
#get_locked_users_count ⇒ Object
Gets the count of all the locked users.
-
#get_roles_by_user(user_name) ⇒ Object
Get Roles based on userName.
-
#get_user(user_name) ⇒ Object
Gets user details based on userName.
-
#get_user_by_email_id(email_id) ⇒ Object
Gets user details based on emailId.
-
#get_users_by_profile_data(profileData) ⇒ Object
Get Users based on Profile Data.
-
#get_users_by_role(role) ⇒ Object
Get Users based on Role.
-
#initialize(api_key, secret_key, base_url) ⇒ UserService
constructor
this is a constructor that takes.
-
#lock_user(user_name) ⇒ Object
Locks the user based on the userName.
-
#reset_user_password(user_name, password) ⇒ Object
Updates the User based on userName.
-
#revoke_all_roles(user_name) ⇒ Object
Revokes the specified role from the user.
-
#revoke_role(user_name, role) ⇒ Object
Revokes the specified role from the user.
-
#unlock_user(user_name) ⇒ Object
Unlock the user based on the userName.
-
#update_email(user_name, email_id) ⇒ Object
Updates the User based on userName.
Constructor Details
#initialize(api_key, secret_key, base_url) ⇒ UserService
this is a constructor that takes
36 37 38 39 40 41 42 43 |
# File 'lib/user/UserService.rb', line 36 def initialize(api_key, secret_key, base_url) puts "UserService->initialize" @api_key = api_key @secret_key = secret_key @base_url = base_url @resource = "user" @version = "1.0" end |
Instance Method Details
#assign_roles(user_name, role_list) ⇒ Object
Add Role for the App
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 |
# File 'lib/user/UserService.rb', line 1115 def assign_roles(user_name, role_list) puts "assignRoles Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(role_list, "RoleList") raise App42Exception.new("RoleList cannot be empty.Please assign at least one role") if role_list.size == 0 begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => user_name, "roles" => { "role" => role_list }}}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/assignrole" response = connection.post(signature, resource_url, query_params, body) user = UserResponseBuilder.new() usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#authenticate(uName, pwd) ⇒ Object
Authenticate user based on userName and password
if authentication fails or username/password is blank or null
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/user/UserService.rb', line 350 def authenticate(uName, pwd) puts "authenticateUser Called " puts "Base url #{@base_url}" response,usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(uName, "UserName") util.throwExceptionIfNullOrBlank(pwd, "Password") begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => uName, "password" => pwd }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/authenticate" response = connection.post(signature, resource_url, query_params, body) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise e end return usr end |
#change_user_password(user_name, old_password, new_password) ⇒ Object
Change the password for user based on the userName.
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
# File 'lib/user/UserService.rb', line 665 def change_user_password(user_name, old_password, new_password) puts "changeUserPassword Called " puts "Base url #{@base_url}" response = nil responseObj = App42Response.new() util = Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(old_password, "Old Password") util.throwExceptionIfNullOrBlank(new_password, "New Password") responseObj = App42Response.new if(old_password == new_password) raise App42Exception.new("Old password and new password are same") end begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => user_name, "oldPassword" => old_password, "newPassword" => new_password }}}.to_json query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/changeUserPassword" response = connection.put(signature, resource_url, query_params, body) responseObj.strResponse=(response) responseObj.isResponseSuccess=(true) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return responseObj end |
#create_or_update_profile(user) ⇒ Object
Creates or Updates User Profile. First time the Profile for the user is created and in future calls user profile will be updated. This will always update the profile with new value passed in profile object. Call to this method should have all the values you want to retain in user profile object, otherwise old values of profile will get updated with null.
Method only updates the profile of user, passing email/password in user object does not have any significance for this method call.
contain the userName and profile object in it.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/user/UserService.rb', line 279 def create_or_update_profile(user) puts "Base url #{@base_url}" response = nil userResponse = nil userResponse = User.new util = Util.new util.throwExceptionIfNullOrBlank(user, "User") util.throwExceptionIfNullOrBlank(user.userName, "UserName") util.throwExceptionIfNullOrBlank(user.profile, "Profile Data") begin connection = App42::Connection::RESTConnection.new(@base_url) profile = user.profile() profileObj = {} profileObj.store("firstName", profile.firstName()) profileObj.store("lastName", profile.lastName()) profileObj.store("sex", profile.sex()) profileObj.store("mobile", profile.mobile()) profileObj.store("line1", profile.line1()) profileObj.store("line2", profile.line2()) profileObj.store("city", profile.city()) profileObj.store("state", profile.state()) profileObj.store("country", profile.country()) profileObj.store("pincode", profile.pincode()) profileObj.store("homeLandLine", profile.homeLandLine()) profileObj.store("officeLandLine", profile.officeLandLine()) if profile.dateOfBirth != nil profileObj.store("dateOfBirth", util.(profile.dateOfBirth)) end body = { 'app42'=>{"user"=>{ "userName"=>user.userName, "profileData"=>profileObj } } }.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/profile" response = connection.put(signature, resource_url, query_params, body) user = UserResponseBuilder.new userResponse = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise e end return userResponse end |
#create_user(user_name, pwd, email_address) ⇒ Object
Variable should be snake case
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/user/UserService.rb', line 61 def create_user(user_name, pwd, email_address) puts "Create User Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(pwd, "Password") util.throwExceptionIfEmailNotValid(email_address, "EmailAddress") util.throwExceptionIfNullOrBlank(email_address, "EmailAddress") begin connection = App42::Connection::RESTConnection.new @base_url body = {'app42' => {"user"=> { "userName" => user_name, "password" => pwd, "email" => email_address }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts params puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}" response = connection.post(signature, resource_url, query_params, body) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#create_user_with_role(user_name, pwd, email_address, role_list) ⇒ Object
Create User for the App
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
# File 'lib/user/UserService.rb', line 799 def create_user_with_role(user_name, pwd, email_address, role_list) puts "Create User Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(pwd, "Password") util.throwExceptionIfEmailNotValid(email_address, "EmailAddress") util.throwExceptionIfNullOrBlank(email_address, "EmailAddress") util.throwExceptionIfNullOrBlank(role_list, "RoleList") raise App42Exception.new("RoleList cannot be empty.Please assign at least one role") if role_list.size == 0 begin connection = App42::Connection::RESTConnection.new(@base_url) role_array = [] for role in role_list do role_array.push(role) end body = {'app42' => {"user"=> { "email" => email_address, "password" => pwd, "userName" => user_name, "roles" => { "role" => role_array }}}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/role" response = connection.post(signature, resource_url, query_params, body) user = UserResponseBuilder.new() usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#delete_user(user_name) ⇒ Object
Deletes a particular user based on userName.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/user/UserService.rb', line 229 def delete_user(user_name) puts "Delete User Called " puts "Base url #{@base_url}" response ,response_obj, util = nil, App42Response.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("userName", user_name) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/#{user_name}" response = connection.delete(signature, resource_url, query_params) response_obj.strResponse=(response) response_obj.isResponseSuccess=(true) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return response_obj end |
#fill_params_with_profile_data(profileData) ⇒ Object
Builds a Parameter string from the profileData.
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 |
# File 'lib/user/UserService.rb', line 1163 def fill_params_with_profile_data(profileData) profileDataCond = "" if profileData.city != nil && !profileData.city != "" profileDataCond += "city:"+ profileData.city()+"!" end if profileData.country != nil && !profileData.country != "" profileDataCond += "country:"+ profileData.country()+"!" end if profileData.dateOfBirth != nil && !profileData.dateOfBirth != "" profileDataCond += "date_of_birth:"+ profileData.dateOfBirth()+"!" end if profileData.firstName != nil && !profileData.firstName != "" profileDataCond += "first_name:"+ profileData.firstName()+"!" end if profileData.lastName != nil && !profileData.lastName != "" profileDataCond += "last_name:"+ profileData.lastName()+"!" end if profileData.homeLandLine != nil && !profileData.homeLandLine != "" profileDataCond += "home_land_line:"+ profileData.homeLandLine()+"!" end if profileData.line1 != nil && !profileData.line1 != "" profileDataCond += "line1:"+ profileData.line1()+"!" end if profileData.line2() != nil && !profileData.line2 != "" profileDataCond += "line2:"+ profileData.line2()+"!" end if profileData.mobile != nil && !profileData.mobile != "" profileDataCond += "mobile:"+ profileData.mobile()+"!" end if profileData.officeLandLine() != nil && !profileData.officeLandLine.equals("") profileDataCond += "office_land_line:"+ profileData.officeLandLine()+"!" end if profileData.pincode != nil && !profileData.pincode != "" profileDataCond += "pincode:"+ profileData.pincode()+"!" end if profileData.sex != nil && !profileData.sex != "" profileDataCond += "sex:"+ profileData.sex()+"!" end if profileData.state != nil && !profileData.state != "" profileDataCond += "state:"+ profileData.state()+"!" end return profileDataCond end |
#get_all_users ⇒ Object
Gets All users details
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/user/UserService.rb', line 149 def get_all_users() puts "Get All Users Called" puts "Base url #{@base_url}" response, userList = nil user_list, util = [], Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new user_list = user.buildArrayResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return user_list end |
#get_all_users_by_paging(max, offset) ⇒ Object
Gets All users By Paging
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
# File 'lib/user/UserService.rb', line 574 def get_all_users_by_paging(max, offset) puts "getAllUsersByPaging Called " puts "Base url #{@base_url}" response, usr = nil user_list, util = User.new, Util.new util.validateMax(max) util.throwExceptionIfNullOrBlank(max, "Max") util.throwExceptionIfNullOrBlank(offset, "Offset") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("max", "" + (max.to_i).to_s) params.store("offset", "" + (offset.to_i).to_s) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/paging/#{(max.to_i).to_s}/#{(offset.to_i).to_s}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new user_list = user.buildArrayResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return user_list end |
#get_all_users_count ⇒ Object
Gets the count of all the users
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'lib/user/UserService.rb', line 714 def get_all_users_count puts "getAllUsersCount Called " puts "Base url #{@base_url}" response = nil responseObj, util = App42Response.new, Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/count/all" response = connection.get(signature, resource_url, query_params) responseObj.strResponse=(response) responseObj.isResponseSuccess=(true) responseObj = UserResponseBuilder.new() responseObj.getTotalRecords(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return responseObj end |
#get_locked_users ⇒ Object
Gets All the locked users details
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/user/UserService.rb', line 393 def get_locked_users() puts "Get Locked Users Called" puts "Base url #{@base_url}" response, user_list = nil user_list, util = [], Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/locked" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new user_list = user.buildArrayResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return user_list end |
#get_locked_users_by_paging(max, offset) ⇒ Object
Gets All the locked users By paging details
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/user/UserService.rb', line 619 def get_locked_users_by_paging(max, offset) puts "get_locked_users_by_paging Called " puts "Base url #{@base_url}" response, user, user_list, util = nil,nil, User.new, Util.new util.validateMax(max) util.throwExceptionIfNullOrBlank(max, "Max") util.throwExceptionIfNullOrBlank(offset, "Offset") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("max", "" + (max.to_i).to_s) params.store("offset", "" + (offset.to_i).to_s) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/locked/#{(max.to_i).to_s}/#{(offset.to_i).to_s}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new user_list = user.buildArrayResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return user_list end |
#get_locked_users_count ⇒ Object
Gets the count of all the locked users
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/user/UserService.rb', line 751 def get_locked_users_count() puts "getLockedUsersCount Called " puts "Base url #{@base_url}" response = nil responseObj = App42Response.new() util = Util.new begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/count/locked" response = connection.get(signature, resource_url, query_params) responseObj.strResponse=(response) responseObj.isResponseSuccess=(true) responseObj = UserResponseBuilder.new() responseObj.getTotalRecords(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return responseObj end |
#get_roles_by_user(user_name) ⇒ Object
Get Roles based on userName
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
# File 'lib/user/UserService.rb', line 856 def get_roles_by_user(user_name) puts "getRolesByUser Called " puts "Base url #{@base_url}" response, user = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("userName", user_name) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/#{user_name}/roles" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new() usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#get_user(user_name) ⇒ Object
Gets user details based on userName
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/user/UserService.rb', line 112 def get_user(user_name) puts "Get User Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("userName", user_name) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/#{user_name}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#get_user_by_email_id(email_id) ⇒ Object
Gets user details based on emailId
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/user/UserService.rb', line 188 def get_user_by_email_id(email_id) puts "Get All Users Called" puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfEmailNotValid(email_id, "EmailId") util.throwExceptionIfNullOrBlank(email_id, "EmailId") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("emailId", email_id) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/email/#{email_id}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#get_users_by_profile_data(profileData) ⇒ Object
Get Users based on Profile Data
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
# File 'lib/user/UserService.rb', line 1020 def get_users_by_profile_data(profileData) puts "get_users_by_profile_data Called " puts "Base url #{@base_url}" response = nil userList = nil userList = [] util = Util.new parameters = "" parameters = fill_params_with_profile_data(profileData) begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/profile/#{parameters}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new() userList = user.buildArrayResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return userList end |
#get_users_by_role(role) ⇒ Object
Get Users based on Role
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
# File 'lib/user/UserService.rb', line 897 def get_users_by_role(role) puts "get_users_by_role Called " puts "Base url #{@base_url}" response, usr = nil userList, util = [], Util.new util.throwExceptionIfNullOrBlank(role, "Role") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("role", role) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/role/#{role}" response = connection.get(signature, resource_url, query_params) user = UserResponseBuilder.new() userList = user.buildArrayResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return userList end |
#lock_user(user_name) ⇒ Object
Locks the user based on the userName. Apps can use these feature to lock a user because of reasons specific to their usercase e.g. If payment not received and the App wants the user to be inactive
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/user/UserService.rb', line 483 def lock_user(user_name) puts "Lock User Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => user_name }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/lock" response = connection.put(signature, resource_url, query_params, body) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#reset_user_password(user_name, password) ⇒ Object
Updates the User based on userName. Note: Only email can be updated. Username cannot be updated.
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 |
# File 'lib/user/UserService.rb', line 1066 def reset_user_password(user_name,password) puts "resetUserPassword Called " puts "Base url #{@base_url}" response = nil responseObj, util = App42Response.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(password, "password") begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => user_name, "password" => password }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/resetUserPassword" response = connection.put(signature, resource_url, query_params, body) responseObj.strResponse=(response) responseObj.isResponseSuccess=(true) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return responseObj end |
#revoke_all_roles(user_name) ⇒ Object
Revokes the specified role from the user.
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 |
# File 'lib/user/UserService.rb', line 980 def revoke_all_roles(user_name) puts "revoke_all_roles Called " puts "Base url #{@base_url}" response, response_obj, util = nil, App42Response.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("userName", user_name) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/#{user_name}/revoke" response = connection.delete(signature, resource_url, query_params) response_obj.strResponse=(response) response_obj.isResponseSuccess=(true) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return response_obj end |
#revoke_role(user_name, role) ⇒ Object
Revokes the specified role from the user.
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
# File 'lib/user/UserService.rb', line 938 def revoke_role(user_name, role) puts "revoke_role Called " puts "Base url #{@base_url}" response, responseObj, util = nil, App42Response.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(role, "Role") begin connection = App42::Connection::RESTConnection.new(@base_url) query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("role", role) params.store("userName", user_name) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/#{user_name}/revoke/#{role}" response = connection.delete(signature, resource_url, query_params) responseObj.strResponse=(response) responseObj.isResponseSuccess=(true) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return responseObj end |
#unlock_user(user_name) ⇒ Object
Unlock the user based on the userName. Apps can use these feature to unlock a user because of reasons specific to their usercase e.g. If payment received and the App wants to the user to be active.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/user/UserService.rb', line 528 def unlock_user(user_name) puts "unlockUser Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => user_name }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/unlock" response = connection.put(signature, resource_url, query_params, body) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |
#update_email(user_name, email_id) ⇒ Object
Updates the User based on userName. Note: Only email can be updated. Username cannot be updated.
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/user/UserService.rb', line 434 def update_email(user_name, email_id) puts "Update User Called " puts "Base url #{@base_url}" response, usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(user_name, "UserName") util.throwExceptionIfNullOrBlank(email_id, "EmailAddress") util.throwExceptionIfNullOrBlank(email_id, "Email Address") begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => user_name, "email" => email_id }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) puts query_params signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}" response = connection.put(signature, resource_url, query_params, body) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise App42Exception.new(e) end return usr end |