Class: Runcible::Resources::User

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

Overview

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_http_auth_header, #add_oauth_header, #call, #combine_get_params, #config, #format_payload_json, #generate_log_message, #generate_payload, #get_response, #initialize, #lazy_config=, #log_debug, #log_exception, #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



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

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)


50
51
52
53
# File 'lib/runcible/resources/user.rb', line 50

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)


67
68
69
# File 'lib/runcible/resources/user.rb', line 67

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)


59
60
61
# File 'lib/runcible/resources/user.rb', line 59

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

#retrieve_allRestClient::Response

Retrieves all users

Returns:

  • (RestClient::Response)


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

def retrieve_all
  call(:get, path)
end