Module: ZQuickblox::User

Defined in:
lib/zquickblox/user.rb,
lib/zquickblox/user/find_user_request.rb,
lib/zquickblox/user/login_user_request.rb,
lib/zquickblox/user/create_user_request.rb,
lib/zquickblox/user/delete_user_request.rb

Defined Under Namespace

Classes: CreateUserRequest, DeleteUserRequest, FindUserRequest, LoginUserRequest, User

Class Method Summary collapse

Class Method Details

.create(params) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/zquickblox/user.rb', line 8

def create(params)
  user = User.new(params)
  params = user.build_params
  request = ZQuickblox::User::CreateUserRequest.new(params)
  run_request(request)
  user = User.new(ZQuickblox::Util.symbolize_keys(request.response_body["user"]))
  return user
end

.delete(login, password, id) ⇒ Object



25
26
27
28
29
30
# File 'lib/zquickblox/user.rb', line 25

def delete(, password, id)
  request = ZQuickblox::User::DeleteUserRequest.new(id)
  run_request(request, , password)
  return nil if request.response.status != 200
  return {}
end

.find(login) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/zquickblox/user.rb', line 17

def find()
  request = ZQuickblox::User::FindUserRequest.new()
  run_request(request)
  return nil if request.response.status == 404
  user = User.new(ZQuickblox::Util.symbolize_keys(request.response_body["user"]))
  return user
end

.run_request(request, login = nil, password = nil) ⇒ Object



32
33
34
35
36
# File 'lib/zquickblox/user.rb', line 32

def run_request(request, =nil, password=nil)
  session = ZQuickblox::Session.create(, password)
  request.header("QB-Token", session.token)
  request.execute
end