Class: OpenfireAdmin::UserAdmin
- Inherits:
-
Object
- Object
- OpenfireAdmin::UserAdmin
- Defined in:
- lib/openfire_admin/user_admin.rb
Instance Method Summary collapse
- #create(username, password, name, email, isadmin = false) ⇒ Object
- #delete(username) ⇒ Object
- #exists?(username) ⇒ Boolean
-
#initialize(client) ⇒ UserAdmin
constructor
A new instance of UserAdmin.
Constructor Details
#initialize(client) ⇒ UserAdmin
Returns a new instance of UserAdmin.
5 6 7 |
# File 'lib/openfire_admin/user_admin.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create(username, password, name, email, isadmin = false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/openfire_admin/user_admin.rb', line 8 def create(username,password,name,email,isadmin=false) params = { "create"=>"Create User", "email"=> email, "name"=> name, "password"=> password, "passwordConfirm"=>password, "username"=>username } params['isadmin'] = "on" if isadmin @client.post("/user-create.jsp", params ) do |res| raise ResponceException.new("can't create user #{username}",res ) unless res.code == "302" and res["location"] =~ /success=true/ end end |
#delete(username) ⇒ Object
21 22 23 24 25 |
# File 'lib/openfire_admin/user_admin.rb', line 21 def delete(username) @client.get("/user-delete.jsp?username=#{username}&delete=Delete+User") do |res| raise ResponceException.new("can't delete user #{username}",res ) unless res.code == "302" and res["location"] =~ /deletesuccess=true/ end end |
#exists?(username) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/openfire_admin/user_admin.rb', line 26 def exists?(username) @client.get("/user-password.jsp?username=#{username}") do |res| res.code == "200" end end |