Class: DatabasusRuby::Users
- Includes:
- Endpoint
- Defined in:
- lib/databasus_ruby/objects/users.rb,
sig/databasus_ruby.rbs
Overview
The signed-in user, instance-wide user administration and instance settings.
client.users.me.email
client.users.list(query: "ops", limit: 25).each { |user| ... }
The #list / #get / #activate / #deactivate / #change_role and settings methods are ADMIN-only and answer 403 for a MEMBER token.
Constant Summary collapse
- ROLES =
%w[ADMIN MEMBER].freeze
Instance Attribute Summary
Attributes included from Endpoint
Instance Method Summary collapse
-
#activate(id) ⇒ Boolean
POST /users/id/activate (ADMIN).
-
#change_password(new_password:) ⇒ Object
PUT /users/change-password.
-
#change_role(id, role:) ⇒ Boolean
PUT /users/id/role (ADMIN) — role is one of ROLES.
-
#deactivate(id) ⇒ Boolean
POST /users/id/deactivate (ADMIN).
-
#get(id) ⇒ Object
(also: #find)
GET /users/id (ADMIN).
-
#invite(email:, intended_workspace_id: nil, intended_workspace_role: nil) ⇒ Object
POST /users/invite.
-
#list(limit: nil, offset: nil, before_date: nil, query: nil) ⇒ Collection
(also: #all)
GET /users (ADMIN).
-
#me ⇒ Object
GET /users/me.
-
#settings ⇒ Object
GET /users/settings (ADMIN) — instance-wide registration settings.
-
#update_me(name: nil, email: nil) ⇒ Object
PUT /users/me.
-
#update_settings(**attributes) ⇒ Object
PUT /users/settings (ADMIN).
Methods included from Endpoint
#acknowledged, #build, #collection, #compact, #escape, #http_delete, #http_get, #http_post, #http_put, #initialize, #inspect, #object, #single_value, #with_default_workspace
Methods inherited from Object
#==, #[], #hash, #initialize, #inspect, #key?, #keys, #method_missing, #respond_to_missing?, #to_h
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DatabasusRuby::Object
Instance Method Details
#activate(id) ⇒ Boolean
POST /users/id/activate (ADMIN)
55 56 57 |
# File 'lib/databasus_ruby/objects/users.rb', line 55 def activate(id) acknowledged(http_post("users/#{escape(id)}/activate")) end |
#change_password(new_password:) ⇒ Object
PUT /users/change-password
28 29 30 |
# File 'lib/databasus_ruby/objects/users.rb', line 28 def change_password(new_password:) object(http_put("users/change-password", { newPassword: new_password })) end |
#change_role(id, role:) ⇒ Boolean
PUT /users/id/role (ADMIN) — role is one of ROLES.
65 66 67 |
# File 'lib/databasus_ruby/objects/users.rb', line 65 def change_role(id, role:) acknowledged(http_put("users/#{escape(id)}/role", { role: role })) end |
#deactivate(id) ⇒ Boolean
POST /users/id/deactivate (ADMIN)
60 61 62 |
# File 'lib/databasus_ruby/objects/users.rb', line 60 def deactivate(id) acknowledged(http_post("users/#{escape(id)}/deactivate")) end |
#get(id) ⇒ Object Also known as: find
GET /users/id (ADMIN)
49 50 51 |
# File 'lib/databasus_ruby/objects/users.rb', line 49 def get(id) object(http_get("users/#{escape(id)}")) end |
#invite(email:, intended_workspace_id: nil, intended_workspace_role: nil) ⇒ Object
POST /users/invite
33 34 35 36 37 38 39 |
# File 'lib/databasus_ruby/objects/users.rb', line 33 def invite(email:, intended_workspace_id: nil, intended_workspace_role: nil) object(http_post("users/invite", { email: email, intendedWorkspaceId: intended_workspace_id, intendedWorkspaceRole: intended_workspace_role })) end |
#list(limit: nil, offset: nil, before_date: nil, query: nil) ⇒ Collection Also known as: all
GET /users (ADMIN)
42 43 44 45 |
# File 'lib/databasus_ruby/objects/users.rb', line 42 def list(limit: nil, offset: nil, before_date: nil, query: nil) response = http_get("users", { limit: limit, offset: offset, beforeDate: before_date, query: query }) collection(response, key: "users") end |
#me ⇒ Object
GET /users/me
18 19 20 |
# File 'lib/databasus_ruby/objects/users.rb', line 18 def me object(http_get("users/me")) end |
#settings ⇒ Object
GET /users/settings (ADMIN) — instance-wide registration settings.
70 71 72 |
# File 'lib/databasus_ruby/objects/users.rb', line 70 def settings object(http_get("users/settings")) end |
#update_me(name: nil, email: nil) ⇒ Object
PUT /users/me
23 24 25 |
# File 'lib/databasus_ruby/objects/users.rb', line 23 def update_me(name: nil, email: nil) object(http_put("users/me", { name: name, email: email })) end |
#update_settings(**attributes) ⇒ Object
PUT /users/settings (ADMIN)
75 76 77 |
# File 'lib/databasus_ruby/objects/users.rb', line 75 def update_settings(**attributes) object(http_put("users/settings", attributes)) end |