module Toolhound::Client::Users

Methods for the Users API

Public Instance Methods

delete_user(user, options = {}) click to toggle source
# File lib/toolhound-ruby/client/users.rb, line 61
def delete_user(user, options = {})
  delete "users/#{user}", options
end
edit_user(user, options = {}) click to toggle source

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/toolhound-ruby/client/users.rb, line 51
def edit_user(user, options = {})
  patch "update_user/#{user}", options
end
Also aliased as: update_user
list_users(options = {})
Alias for: users
update_email(user, options = {}) click to toggle source
# File lib/toolhound-ruby/client/users.rb, line 56
def update_email(user, options = {})

end
update_user(user, options = {})
Alias for: edit_user
user(user=nil, options = {}) click to toggle source

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/toolhound-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
users(options = {}) click to toggle source

List users

@note Logged in user must be an admin to see all users

@return [Array<Sawyer::Resource>] List of projects

# File lib/toolhound-ruby/client/users.rb, line 13
def users(options = {})
  paginate "users", options
end
Also aliased as: list_users
validate_credentials(options = {}) click to toggle source

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/toolhound-ruby/client/users.rb, line 71
def validate_credentials(options = {})
  !self.class.new(options).user.nil?
rescue Toolhound::Unauthorized
  false
end