Class: Thron::Gateway::VUserManager
- Defined in:
- lib/thron/gateway/v_user_manager.rb
Constant Summary collapse
- PACKAGE =
Package.new(:xsso, :resources, self.service_name)
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #check_credentials(options = {}) ⇒ Object
- #create_user(options = {}) ⇒ Object
- #find_users(options = {}) ⇒ Object
- #temporary_token(options = {}) ⇒ Object
- #update_capabilities_and_roles(options = {}) ⇒ Object
- #update_external_id(options = {}) ⇒ Object
- #update_image(options = {}) ⇒ Object
- #update_password(options = {}) ⇒ Object
- #update_settings(options = {}) ⇒ Object
- #update_status(options = {}) ⇒ Object
- #update_user(options = {}) ⇒ Object
- #upgrade_user(options = {}) ⇒ Object
- #user_detail(options = {}) ⇒ Object
Methods inherited from Session
Methods included from Pageable
Methods inherited from Base
#check_session, client_id, #client_id, service_name
Methods included from Routable
Constructor Details
This class inherits a constructor from Thron::Gateway::Session
Class Method Details
.routes ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/thron/gateway/v_user_manager.rb', line 12 def self.routes @routes ||= { create_user: Route::factory(name: 'create', package: PACKAGE), user_detail: Route::factory(name: 'detail', package: PACKAGE, verb: Route::Verbs::GET), find_users: Route::factory(name: 'findByProperties', package: PACKAGE), check_credentials: Route::factory(name: 'login', package: PACKAGE), temporary_token: Route::factory(name: 'resetPassword', package: PACKAGE), update_password: Route::factory(name: 'changePassword', package: PACKAGE), update_status: Route::factory(name: 'changeUserStatus', package: PACKAGE), update_capabilities_and_roles: Route::factory(name: 'updateCapabilitiesAndRoles', package: PACKAGE), update_external_id: Route::lazy_factory(name: 'updateExternalId', package: PACKAGE), update_image: Route::factory(name: 'updateImage', package: PACKAGE), update_settings: Route::factory(name: 'updateSettings', package: PACKAGE), update_user: Route::lazy_factory(name: 'updateUser', package: PACKAGE), upgrade_user: Route::factory(name: 'upgradeUser', package: PACKAGE) } end |
Instance Method Details
#check_credentials(options = {}) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/thron/gateway/v_user_manager.rb', line 82 def check_credentials( = {}) username = [:username] password = [:password] query = { clientId: client_id, username: username, password: password } route(to: __callee__, query: query, token_id: token_id, dash: false) do |response| user = response.body.delete('user') { {} } response.body = Entity::Base::factory(response.body.merge!(user)) end end |
#create_user(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/thron/gateway/v_user_manager.rb', line 30 def create_user( = {}) username = [:username] password = [:password] data = [:data] body = { clientId: client_id, newUser: { username: username, password: password } }.merge(data) route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('user') { {} }) end end |
#find_users(options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/thron/gateway/v_user_manager.rb', line 63 def find_users( = {}) criteria = .fetch(:criteria) { {} } order_by = [:order_by] fields_option = .fetch(:fields_option) { {} } offset = [:offset].to_i limit = [:limit].to_i body = { clientId: client_id, criteria: criteria, orderBy: order_by, fieldsOption: fields_option, offset: offset.to_i, numberOfResult: limit.to_i } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('users') { [] }) end end |
#temporary_token(options = {}) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/thron/gateway/v_user_manager.rb', line 96 def temporary_token( = {}) username = [:username] body = { clientId: client_id, username: username, } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = response.body['tmpToken'] end end |
#update_capabilities_and_roles(options = {}) ⇒ Object
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/thron/gateway/v_user_manager.rb', line 129 def update_capabilities_and_roles( = {}) username = [:username] capabilities = [:capabilities] body = { clientId: client_id, username: username, userCapabilities: capabilities } route(to: __callee__, body: body, token_id: token_id) end |
#update_external_id(options = {}) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/thron/gateway/v_user_manager.rb', line 140 def update_external_id( = {}) username = [:username] external_id = [:external_id] body = { externalId: external_id } route(to: __callee__, body: body, token_id: token_id, params: [client_id, username]) end |
#update_image(options = {}) ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/thron/gateway/v_user_manager.rb', line 149 def update_image( = {}) username = [:username] image = [:image] body = { clientId: client_id, username: username, buffer: image } route(to: __callee__, body: body, token_id: token_id) end |
#update_password(options = {}) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/thron/gateway/v_user_manager.rb', line 107 def update_password( = {}) username = [:username] password = [:password] query = { clientId: client_id, username: username, newpassword: password } route(to: __callee__, query: query, token_id: token_id, dash: false) end |
#update_settings(options = {}) ⇒ Object
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/thron/gateway/v_user_manager.rb', line 160 def update_settings( = {}) username = [:username] settings = [:settings] body = { clientId: client_id, username: username, settings: settings } route(to: __callee__, body: body, token_id: token_id) end |
#update_status(options = {}) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/thron/gateway/v_user_manager.rb', line 118 def update_status( = {}) username = [:username] data = [:data] body = { clientId: client_id, username: username, properties: data } route(to: __callee__, body: body, token_id: token_id) end |
#update_user(options = {}) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/thron/gateway/v_user_manager.rb', line 171 def update_user( = {}) username = [:username] data = [:data] body = { update: data } route(to: __callee__, body: body, token_id: token_id, params: [client_id, username]) end |
#upgrade_user(options = {}) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/thron/gateway/v_user_manager.rb', line 180 def upgrade_user( = {}) username = [:username] password = [:password] data = [:data] body = { clientId: client_id, username: username, newPassword: password }.merge(data) route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('user') { {} }) end end |
#user_detail(options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/thron/gateway/v_user_manager.rb', line 46 def user_detail( = {}) username = [:username] extra = .fetch(:extra) { {} } offset = [:offset].to_i limit = [:limit].to_i query = { clientId: client_id, username: username, offset: offset.to_i, numberOfResults: limit.to_i }.merge(extra) route(to: __callee__, query: query, token_id: token_id, dash: false) do |response| user = response.body.delete('user') { {} } response.body = Entity::Base::factory(response.body.merge!(user)) end end |