Class: Thron::Gateway::UsersGroupManager
- Inherits:
-
Session
show all
- Defined in:
- lib/thron/gateway/users_group_manager.rb
Constant Summary
collapse
- PACKAGE =
Package.new(:xsso, :resources, self.service_name)
Constants inherited
from Base
Base::NO_ACTIVE_SESSION
Instance Attribute Summary
Attributes inherited from Base
#token_id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Session
#initialize
Methods included from Pageable
included
Methods inherited from Base
#check_session, client_id, #client_id, service_name
Methods included from Routable
included, info, #route
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(options = {})
data = options[: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(options = {})
criteria = options.fetch(:criteria) { {} }
order_by = options[:order_by]
fields_option = options.fetch(:fields_option) { {} }
offset = options[:offset].to_i
limit = options[: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(options = {})
group_id = options[:group_id]
fields_option = options.fetch(:fields_option) { {} }
offset = options[:offset].to_i
limit = options[: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(options = {})
group_id = options[:group_id]
force = options.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(options = {})
group_id = options[:group_id]
data = options[: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(options = {})
group_id = options[:group_id]
external_id = options[:external_id]
body = {
externalId: external_id
}
route(to: __callee__, body: body, token_id: token_id, params: [client_id, group_id])
end
|