Module: Ohmage::API::User

Included in:
Ohmage::API
Defined in:
lib/ohmage/user.rb

Instance Method Summary collapse

Instance Method Details

#user_create(params = {}) ⇒ Object

ohmage user/create call



33
34
35
36
37
# File 'lib/ohmage/user.rb', line 33

def user_create(params = {})
  request = Ohmage::Request.new(self, :post, 'user/create', params)
  request.perform
  user_read(user_list: params[:username])
end

#user_delete(params = {}) ⇒ Object



58
59
60
61
# File 'lib/ohmage/user.rb', line 58

def user_delete(params = {})
  request = Ohmage::Request.new(self, :post, 'user/delete', params)
  request.perform
end

#user_info_readObject

ohmage user_info/read call



23
24
25
26
# File 'lib/ohmage/user.rb', line 23

def 
  request = Ohmage::Request.new(self, :post, 'user_info/read', {})
  Ohmage::User.new(request.perform[:data])
end

#user_password(params = {}) ⇒ Object

is this method name odd?



50
51
52
53
54
55
56
# File 'lib/ohmage/user.rb', line 50

def user_password(params = {}) # is this method name odd?
  # this api call demands current user's info.
  params[:user] = user
  params[:password] = password
  request = Ohmage::Request.new(self, :post, 'user/change_password', params)
  request.perform
end

#user_read(params = {}) ⇒ Object

ohmage user/read call



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

def user_read(params = {})
  request = Ohmage::Request.new(self, :post, 'user/read', params)
  t = []
  request.perform[:data].each do |k, v|
    t << Ohmage::User.new(k => v)
  end
  t
end

#user_search(params = {}) ⇒ Object

ohmage user/search call. Admin only api



80
81
82
83
84
85
86
87
88
# File 'lib/ohmage/user.rb', line 80

def user_search(params = {})
  request = Ohmage::Request.new(self, :post, 'user/search', params)
  # TODO: make a utility to abstract creation of array of base objects
  t = []
  request.perform[:data].each do |k, v|
    t << Ohmage::User.new(k => v)
  end
  t
end

#user_setup(params = {}) ⇒ Object

ohmage user/setup call



68
69
70
71
72
73
# File 'lib/ohmage/user.rb', line 68

def user_setup(params = {})
  # server bug returns empty page if user setup disabled.
  return false unless server_config[:user_setup_enabled]
  request = Ohmage::Request.new(self, :post, 'user/setup', params)
  request.perform
end

#user_update(params = {}) ⇒ Object

ohmage user/update call



44
45
46
47
48
# File 'lib/ohmage/user.rb', line 44

def user_update(params = {})
  request = Ohmage::Request.new(self, :post, 'user/update', params)
  request.perform
  user_read(user_list: params[:username])
end