Class: Runcible::Resources::User

Inherits:
Base
  • Object
show all
Defined in:
lib/runcible/resources/user.rb

Overview

Instance Attribute Summary

Attributes inherited from Base

#logs

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #exception_to_log, #format_payload_json, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #log_info, #logger, #path, #process_response, #required_params

Constructor Details

This class inherits a constructor from Runcible::Base

Class Method Details

.path(login = nil) ⇒ String

Generates the API path for Users

Parameters:

  • login (String) (defaults to: nil)

    the user’s login

Returns:

  • (String)

    the user path, may contain the login if passed



9
10
11
# File 'lib/runcible/resources/user.rb', line 9

def self.path( = nil)
  .nil? ? 'users/' : "users/#{}/"
end

Instance Method Details

#create(login, optional = {}) ⇒ RestClient::Response

Creates a user

Parameters:

  • login (String)

    the login requested for the user

  • optional (Hash) (defaults to: {})

    container for all optional parameters

Returns:

  • (RestClient::Response)


25
26
27
28
# File 'lib/runcible/resources/user.rb', line 25

def create(, optional = {})
  required = required_params(binding.send(:local_variables), binding)
  call(:post, path, :payload => { :required => required, :optional => optional })
end

#delete(login) ⇒ RestClient::Response

Deletes a user

Parameters:

  • login (String)

    the login of the user being deleted

Returns:

  • (RestClient::Response)


42
43
44
# File 'lib/runcible/resources/user.rb', line 42

def delete()
  call(:delete, path())
end

#retrieve(login) ⇒ RestClient::Response

Retrieves a user

Parameters:

  • login (String)

    the login of the user being retrieved

Returns:

  • (RestClient::Response)


34
35
36
# File 'lib/runcible/resources/user.rb', line 34

def retrieve()
  call(:get, path())
end

#retrieve_allRestClient::Response

Retrieves all users

Returns:

  • (RestClient::Response)


16
17
18
# File 'lib/runcible/resources/user.rb', line 16

def retrieve_all
  call(:get, path)
end