class Datacentred::Request::Users

RESTful API requests for the user endpoints.

Public Class Methods

create(params) click to toggle source
Create a new user.

  POST /api/users

@param [Hash] params User attributes.
@raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes.
@raise [Errors::Unauthorized] Raised if credentials aren't valid.

 @return [Hash] New user.

# File lib/datacentred/request/users.rb, line 14
def create(params)
  post('users', 'user' => params)['user']
end
destroy(id) click to toggle source

Permanently remove the specified user.

DELETE /api/users/82fa8de8f09102cc

@param [String] id The unique identifier for this user. @raise [Errors::NotFound] Raised if the user couldn't be found. @raise [Errors::UnprocessableEntity] Raised if validations fail for the specified user. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [nil] Confirms the user was destroyed.

# File lib/datacentred/request/users.rb, line 63
def destroy(id)
  delete("users/#{id}")
end
list() click to toggle source

List all available users.

GET /api/users

@raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [[Hash]] A collection of all users on this account.

# File lib/datacentred/request/users.rb, line 24
def list
  get('users')['users']
end
show(id) click to toggle source

Find a user by unique ID.

GET /api/users/82fa8de8f09102cc

@param [String] id The unique identifier for this user. @raise [Errors::NotFound] Raised if the user couldn't be found. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Hash] The user, if it exists.

# File lib/datacentred/request/users.rb, line 36
def show(id)
  get("users/#{id}")['user']
end
update(id, params) click to toggle source

Update a user by unique ID.

PUT /api/users/82fa8de8f09102cc

@param [String] id The unique identifier for this user. @param [Hash] params User attributes. @raise [Errors::UnprocessableEntity] Raised if validations fail for the supplied attributes. @raise [Errors::NotFound] Raised if the user couldn't be found. @raise [Errors::Unauthorized] Raised if credentials aren't valid. @return [Hash] The updated user.

# File lib/datacentred/request/users.rb, line 50
def update(id, params)
  put("users/#{id}", 'user' => params)['user']
end