Class: Thron::Gateway::UsersGroupManager
- Defined in:
- lib/thron/gateway/users_group_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
- #create_group(options = {}) ⇒ Object
- #find_groups(options = {}) ⇒ Object
- #group_detail(options = {}) ⇒ Object
- #remove_group(options = {}) ⇒ Object
- #update_group(options = {}) ⇒ Object
- #update_group_external_id(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
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/thron/gateway/users_group_manager.rb', line 11 def self.routes @routes ||= { create_group: Route::factory(name: 'createGroup', package: PACKAGE), remove_group: Route::factory(name: 'removeGroup', package: PACKAGE), group_detail: Route::factory(name: 'detailGroup', package: PACKAGE), find_groups: Route::factory(name: 'findGroupsByProperties', package: PACKAGE), link_users_to_group: Route::factory(name: 'linkUserToGroup', package: PACKAGE), unlink_users_to_group: Route::factory(name: 'unlinkUserToGroup', package: PACKAGE), update_group: Route::lazy_factory(name: 'update', package: PACKAGE), update_group_external_id: Route::lazy_factory(name: 'updateExternalId', package: PACKAGE) } end |
Instance Method Details
#create_group(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/thron/gateway/users_group_manager.rb', line 24 def create_group( = {}) data = [:data] body = { clientId: client_id, usersGroup: data } route(to: __callee__, body: body, token_id: token_id) do |response| response.body = Entity::Base::factory(response.body.fetch('group') { {} }) end end |
#find_groups(options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/thron/gateway/users_group_manager.rb', line 64 def find_groups( = {}) 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('groups') { [] }) end end |
#group_detail(options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/thron/gateway/users_group_manager.rb', line 46 def group_detail( = {}) group_id = [:group_id] fields_option = .fetch(:fields_option) { {} } offset = [:offset].to_i limit = [:limit].to_i body = { clientId: client_id, groupId: group_id, offset: offset.to_i, numberOfResult: limit.to_i, fieldsOption: fields_option } route(to: __callee__, body: body, token_id: token_id) do |response| group = response.body.delete('group') { {} } response.body = Entity::Base::factory(response.body.merge!(group)) end end |
#remove_group(options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/thron/gateway/users_group_manager.rb', line 35 def remove_group( = {}) group_id = [:group_id] force = .fetch(:force) { false } body = { clientId: client_id, groupId: group_id, force: force } route(to: __callee__, body: body, token_id: token_id) end |
#update_group(options = {}) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/thron/gateway/users_group_manager.rb', line 98 def update_group( = {}) group_id = [:group_id] data = [:data] body = { update: data } route(to: __callee__, body: body, token_id: token_id, params: [client_id, group_id]) end |
#update_group_external_id(options = {}) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/thron/gateway/users_group_manager.rb', line 107 def update_group_external_id( = {}) group_id = [:group_id] external_id = [:external_id] body = { externalId: external_id } route(to: __callee__, body: body, token_id: token_id, params: [client_id, group_id]) end |