module Nearmiss::Client::Users
Methods for the Users
API
Public Instance Methods
# File lib/nearmiss-ruby/client/users.rb, line 61 def delete_user(user, options = {}) delete "users/#{user}", options end
Edit a user
@param options [Hash] User information. @option options [String] :email Email of user @option options [String] :name Name of user @option options [String] :nickname Nickname of user @option options [Integer] :role Set to admin or not @option options [String] :phone_number Phone number of user @option options [String] :image URL of image of user @option options [String] :language Code “en”, “de”, “es” @return
[Sawyer::Resource] Edited user info
@example Update a user
@client.edit_user('some_id', { email: "mklooth@webcor.com", name: "Markus Klooth" })
# File lib/nearmiss-ruby/client/users.rb, line 51 def edit_user(user, options = {}) patch "update_user/#{user}", options end
# File lib/nearmiss-ruby/client/users.rb, line 56 def update_email(user, options = {}) end
Get a single user
@param user [String] Nearmiss
user email or id. @return [Sawyer::Resource] @example
Nearmiss.user("31817811-dce4-48c4-aa5f-f49603c5abee") or Nearmiss.user("m4rkuskk+a@gmail.com")
# File lib/nearmiss-ruby/client/users.rb, line 24 def user(user=nil, options = {}) if user.nil? get "me", options else get "users/#{user}", options end # get User.path(user), options end
List users
@note Logged in user must be an admin to see all users
@return [Array<Sawyer::Resource>] List of projects
# File lib/nearmiss-ruby/client/users.rb, line 13 def users(options = {}) paginate "users", options end
Validate user username and password
@param options [Hash] User credentials @option options [String] :email Nearmiss
login email @option options [String] :password Nearmiss
password @return [Boolean] True if credentials are valid
# File lib/nearmiss-ruby/client/users.rb, line 71 def validate_credentials(options = {}) !self.class.new(options).user.nil? rescue Nearmiss::Unauthorized false end