Class: Jiralicious::User::Avatar
- Defined in:
- lib/jiralicious/user/avatar.rb
Overview
Avatars in the Project class.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.avatars(username, options = {}) ⇒ Object
Gets a list of avatars.
-
.post(username, options = {}) ⇒ Object
Converts the temporary avatar to a real avatar.
-
.put(username, options = {}) ⇒ Object
Update Avatar information.
-
.remove(username, id) ⇒ Object
Deletes or removes the avatar from the project.
-
.temporary(username, options = {}) ⇒ Object
Creates temporary avatar.
Instance Method Summary collapse
-
#initialize(decoded_json = nil) ⇒ Avatar
constructor
Initialization Method.
Methods inherited from Base
#all, #endpoint_name, endpoint_name, fetch, find, 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) ⇒ Avatar
Initialization Method
- Arguments
-
:decoded_json (optional) decoded json object
15 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 |
# File 'lib/jiralicious/user/avatar.rb', line 15 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
.avatars(username, options = {}) ⇒ Object
Gets a list of avatars
- Arguments
-
:username (required) user name
122 123 124 125 126 |
# File 'lib/jiralicious/user/avatar.rb', line 122 def avatars(username, = {}) .merge!({:username => username}) response = fetch({:method => :get, :body_to_params => true, :url => "#{Jiralicious.rest_path}/#{parent_name}/#{endpoint_name}s", :body => }) return self.new(response.parsed_response) end |
.post(username, options = {}) ⇒ Object
Converts the temporary avatar to a real avatar
- Arguments
-
:username (required) username to change
:cropperWidth (optional) width of the avatar
:cropperOffsetX (optional) X offset on image
:cropperOffsetY (optional) Y offset on image
:needsCropping (optional) boolean if it needs cropping
70 71 72 73 |
# File 'lib/jiralicious/user/avatar.rb', line 70 def post(username, = {}) .merge!({:username => username}) response = fetch({:method => :post, :parent_uri => "#{parent_name}/", :body => }) end |
.put(username, options = {}) ⇒ Object
Update Avatar information
- Arguments
-
:username (required) project key
:options (optional) not documented
83 84 85 86 |
# File 'lib/jiralicious/user/avatar.rb', line 83 def put(username, = {}) .merge!({:username => username}) response = fetch({:method => :put, :parent_uri => "#{parent_name}/", :body => }) end |
.remove(username, id) ⇒ Object
Deletes or removes the avatar from the project
- Arguments
-
:username (required) project key
:id (required) avatar id
112 113 114 |
# File 'lib/jiralicious/user/avatar.rb', line 112 def remove(username, id) response = fetch({:method => :delete, :body_to_params => true, :parent_uri => "#{parent_name}/", :key => "#{id}", :body => {:username => username}}) end |
.temporary(username, options = {}) ⇒ Object
Creates temporary avatar
- Arguments
-
:username (required) project key
:filename (optional) file to upload
:size (optional) size of the file
98 99 100 101 102 |
# File 'lib/jiralicious/user/avatar.rb', line 98 def temporary(username, = {}) .merge!({:username => username}) response = fetch({:method => :post, :parent_uri => "#{parent_name}/", :key => 'temporary', :body => }) return self.new(response.parsed_response) end |