Module: DiscourseApi::API::Users
- Included in:
- Client
- Defined in:
- lib/discourse_api/api/users.rb
Instance Method Summary collapse
- #activate(id) ⇒ Object
-
#create_user(*args) ⇒ Object
Create a user.
- #update_avatar(username, file) ⇒ Object
- #update_email(username, email) ⇒ Object
- #update_user(username, params = {}) ⇒ Object
- #update_username(username, new_username) ⇒ Object
- #user(username, *args) ⇒ Object
Instance Method Details
#activate(id) ⇒ Object
4 5 6 |
# File 'lib/discourse_api/api/users.rb', line 4 def activate(id) put "/admin/users/#{id}/activate", api_key: api_key, api_username: api_username end |
#create_user(*args) ⇒ Object
Create a user
30 31 32 33 34 35 36 37 38 |
# File 'lib/discourse_api/api/users.rb', line 30 def create_user(*args) # First retrieve the honeypot values response = get("/users/hp.json") args.first[:password_confirmation] = response[:body]['value'] args.first[:challenge] = response[:body]['challenge'].reverse # POST the args post("/users", args) end |
#update_avatar(username, file) ⇒ Object
13 14 15 |
# File 'lib/discourse_api/api/users.rb', line 13 def update_avatar(username, file) put("/users/#{username}/preferences/avatar", { file: file, api_key: api_key }) end |
#update_email(username, email) ⇒ Object
17 18 19 |
# File 'lib/discourse_api/api/users.rb', line 17 def update_email(username, email) put("/users/#{username}/preferences/email", { email: email, api_key: api_key }) end |
#update_user(username, params = {}) ⇒ Object
21 22 23 |
# File 'lib/discourse_api/api/users.rb', line 21 def update_user(username, params={}) put("/users/#{username}", params) end |
#update_username(username, new_username) ⇒ Object
25 26 27 |
# File 'lib/discourse_api/api/users.rb', line 25 def update_username(username, new_username) put("/users/#{username}/preferences/username", { new_username: new_username, api_key: api_key }) end |
#user(username, *args) ⇒ Object
8 9 10 11 |
# File 'lib/discourse_api/api/users.rb', line 8 def user(username, *args) response = get("/users/#{username}.json", args) response[:body]['user'] end |