class Thron::Gateway::UsersGroupManager

Constants

PACKAGE

Public Class Methods

routes() click to toggle source
# 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

Public Instance Methods

create_group(options = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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