Class: Jiralicious::User
- Defined in:
- lib/jiralicious/user.rb,
lib/jiralicious/user/avatar.rb
Overview
The User class rolls up the functionality of user management. This class contains methods to manage Users from Ruby via the API.
Defined Under Namespace
Classes: Avatar
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.assignable_multiProjectSearch(projectKeys, options = {}) ⇒ Object
Returns a list of users matching the criteria.
-
.assignable_search(options = {}) ⇒ Object
Returns a list of users matching the criteria.
-
.find(username) ⇒ Object
Retrieves the user by UserName.
-
.picker(query, options = {}) ⇒ Object
Uses the user picker to find specified users.
-
.search(username, options = {}) ⇒ Object
Uses the user search to find specified users by username.
Instance Method Summary collapse
-
#initialize(decoded_json = nil) ⇒ User
constructor
Initialization Method.
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find_all, handler, issueKey_test, #loaded?, #method_missing, #numeric?, parent_name, #parent_name, #properties_from_hash, #reload
Methods included from Parsers::FieldParser
Constructor Details
#initialize(decoded_json = nil) ⇒ User
Initialization Method
- Arguments
-
:decoded_json (optional) rubyized json object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jiralicious/user.rb', line 16 def initialize(decoded_json = nil) @loaded = false if !decoded_json.nil? if decoded_json.is_a? Hash decoded_json = properties_from_hash(decoded_json) super(decoded_json) parse!(decoded_json) self.each do |k, v| if v.is_a? Hash self[k] = self.class.new(v) elsif v.is_a? Array v.each_index do |i| if v[i].is_a? Hash v[i] = self.class.new(v[i]) end end self[k] = v end end @loaded = true else i = 0; decoded_json.each do |list| if !list['id'].nil? if numeric? list['id'] id = :"id_#{list['id']}" else id = :"#{list['id']}" end else id = :"_#{i}" i += 1 end self.class.property id self[id] = self.class.new(list) end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jiralicious::Base
Class Method Details
.assignable_multiProjectSearch(projectKeys, options = {}) ⇒ Object
Returns a list of users matching the criteria
- Arguments
-
:projectKey (required) Should be upper case
:username (optional) Must be correct username, no partials
:startAt (optional) Integer
:maxResults (optional) Integer
83 84 85 86 87 |
# File 'lib/jiralicious/user.rb', line 83 def assignable_multiProjectSearch(projectKeys, = {}) .merge!({:projectKeys=>projectKeys.upcase}) response = fetch({:method => :get, :key => "assignable/multiProjectSearch", :body_to_params => true, :body => }) return self.new(response.parsed_response) end |
.assignable_search(options = {}) ⇒ Object
Returns a list of users matching the criteria
- Arguments
-
:project (required) Should be upper case
OR:issueKey (required) Should be upper case
:username (optional) Must be correct username,
no partials, cannot be by itself:startAt (optional) Integer
:maxResults (optional) Integer
:ActionDescriptorId (optional) Integer
108 109 110 111 112 113 |
# File 'lib/jiralicious/user.rb', line 108 def assignable_search( = {}) [:project] = [:project].upcase unless [:project].nil? [:issueKey] = [:issueKey].upcase unless [:issueKey].nil? response = fetch({:method => :get, :key => "assignable/search", :body_to_params => true, :body => }) return self.new(response.parsed_response) end |
.find(username) ⇒ Object
Retrieves the user by UserName.
A valid request will return the user details. An invalid request will throw an error.
- Arguments
-
:username (required) Must be correct username, no partials
66 67 68 69 |
# File 'lib/jiralicious/user.rb', line 66 def find(username) response = fetch({:url => "#{Jiralicious.rest_path}/#{endpoint_name}", :method => :get, :body_to_params => true, :body => {:username => username}}) return self.new(response.parsed_response) end |
.picker(query, options = {}) ⇒ Object
Uses the user picker to find specified users
- Arguments
-
:query (required) Name of user or username part or full
:maxResults (optional) Integer
:showAvatar (optional) Boolean, default false
:exclude (optional) Users to exclude
127 128 129 130 131 |
# File 'lib/jiralicious/user.rb', line 127 def picker(query, ={}) .merge!({:query => query}) response = fetch({:method => :get, :key => "picker", :body_to_params => true, :body => }) return self.new(response.parsed_response) end |
.search(username, options = {}) ⇒ Object
Uses the user search to find specified users by username
- Arguments
-
:username (required) Name of user or username part or full
:startAt (optional) Integer
:maxResults (optional) Integer
:includeActive (optional) Boolean, default true
:includeInactive (optional) Boolean, default true
147 148 149 150 151 |
# File 'lib/jiralicious/user.rb', line 147 def search(username, ={}) .merge!({:username => username}) response = fetch({:method => :get, :key => "search", :body_to_params => true, :body => }) return self.new(response.parsed_response) end |