Class: Logan::Project
- Inherits:
-
Object
- Object
- Logan::Project
- Includes:
- HashConstructed, ResponseHandler
- Defined in:
- lib/logan/project.rb
Instance Attribute Summary collapse
-
#app_url ⇒ Object
Returns the value of attribute app_url.
-
#archived ⇒ Object
Returns the value of attribute archived.
-
#color ⇒ Object
Returns the value of attribute color.
-
#description ⇒ Object
Returns the value of attribute description.
-
#draft ⇒ Object
Returns the value of attribute draft.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_client_project ⇒ Object
Returns the value of attribute is_client_project.
-
#name ⇒ Object
Returns the value of attribute name.
-
#starred ⇒ Object
Returns the value of attribute starred.
-
#template ⇒ Object
Returns the value of attribute template.
-
#trashed ⇒ Object
Returns the value of attribute trashed.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes included from HashConstructed
Instance Method Summary collapse
- #accesses ⇒ Object
- #add_client_by_email(email) ⇒ Object
- #add_client_by_id(id) ⇒ Object
- #add_user_by_email(email) ⇒ Object
- #add_user_by_id(id) ⇒ Object
-
#all_todolists ⇒ Array<Logan::TodoList>
get both active and completed todo lists for this project from Basecamp API.
-
#completed_todolists ⇒ Array<Logan::TodoList>
get completed todo lists for this project from Basecamp API.
-
#completed_todos ⇒ Array<Logan::Todo>
returns the array of completed todos - potentially synchronously downloaded from API.
- #completed_todos! ⇒ Object
-
#create_message(subject, content, subscribers, private) ⇒ Logan::Message
create a message via Basecamp API.
-
#create_todolist(todo_list) ⇒ Logan::TodoList
create a todo list in this project via Basecamp API.
-
#publish ⇒ Logan::Project
publish this project from Basecamp API.
-
#remaining_todos(&block) ⇒ Array<Logan::Todo>
returns the array of remaining todos - potentially synchronously downloaded from API.
- #remaining_todos!(&block) ⇒ Object
-
#todolist(list_id) ⇒ Logan::TodoList
get an individual todo list for this project from Basecamp API.
-
#todolists ⇒ Array<Logan::TodoList>
get active todo lists for this project from Basecamp API.
-
#todos ⇒ Array<Logan::Todo>
returns the array of todos - potentially synchronously downloaded from API.
- #todos! ⇒ Object
-
#trashed_todos ⇒ Array<Logan::Todo>
returns the array of trashed todos - potentially synchronously downloaded from API.
- #trashed_todos! ⇒ Object
Methods included from ResponseHandler
#handle_error, #handle_response, #success?
Methods included from HashConstructed
Instance Attribute Details
#app_url ⇒ Object
Returns the value of attribute app_url.
15 16 17 |
# File 'lib/logan/project.rb', line 15 def app_url @app_url end |
#archived ⇒ Object
Returns the value of attribute archived.
17 18 19 |
# File 'lib/logan/project.rb', line 17 def archived @archived end |
#color ⇒ Object
Returns the value of attribute color.
22 23 24 |
# File 'lib/logan/project.rb', line 22 def color @color end |
#description ⇒ Object
Returns the value of attribute description.
12 13 14 |
# File 'lib/logan/project.rb', line 12 def description @description end |
#draft ⇒ Object
Returns the value of attribute draft.
20 21 22 |
# File 'lib/logan/project.rb', line 20 def draft @draft end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/logan/project.rb', line 10 def id @id end |
#is_client_project ⇒ Object
Returns the value of attribute is_client_project.
21 22 23 |
# File 'lib/logan/project.rb', line 21 def is_client_project @is_client_project end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/logan/project.rb', line 11 def name @name end |
#starred ⇒ Object
Returns the value of attribute starred.
18 19 20 |
# File 'lib/logan/project.rb', line 18 def starred @starred end |
#template ⇒ Object
Returns the value of attribute template.
16 17 18 |
# File 'lib/logan/project.rb', line 16 def template @template end |
#trashed ⇒ Object
Returns the value of attribute trashed.
19 20 21 |
# File 'lib/logan/project.rb', line 19 def trashed @trashed end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
13 14 15 |
# File 'lib/logan/project.rb', line 13 def updated_at @updated_at end |
#url ⇒ Object
Returns the value of attribute url.
14 15 16 |
# File 'lib/logan/project.rb', line 14 def url @url end |
Instance Method Details
#accesses ⇒ Object
86 87 88 89 |
# File 'lib/logan/project.rb', line 86 def accesses response = Logan::Client.get "/projects/#{@id}/accesses.json" response.parsed_response.map { |h| p = Logan::Person.new(h) } end |
#add_client_by_email(email) ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/logan/project.rb', line 118 def add_client_by_email(email) post_params = { :body => { email_addresses: [email] }.to_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/client_accesses.json", post_params end |
#add_client_by_id(id) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/logan/project.rb', line 100 def add_client_by_id(id) post_params = { :body => { ids: [id] }.to_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/client_accesses.json", post_params end |
#add_user_by_email(email) ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/logan/project.rb', line 109 def add_user_by_email(email) post_params = { :body => { email_addresses: [email] }.to_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/accesses.json", post_params end |
#add_user_by_id(id) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/logan/project.rb', line 91 def add_user_by_id(id) post_params = { :body => { ids: [id] }.to_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/accesses.json", post_params end |
#all_todolists ⇒ Array<Logan::TodoList>
get both active and completed todo lists for this project from Basecamp API
59 60 61 |
# File 'lib/logan/project.rb', line 59 def all_todolists todolists + completed_todolists end |
#completed_todolists ⇒ Array<Logan::TodoList>
get completed todo lists for this project from Basecamp API
49 50 51 52 53 54 |
# File 'lib/logan/project.rb', line 49 def completed_todolists completed_response = Logan::Client.get "/projects/#{@id}/todolists/completed.json" lists_array = completed_response.parsed_response.map do |h| Logan::TodoList.new h.merge({ :project_id => @id }) end end |
#completed_todos ⇒ Array<Logan::Todo>
returns the array of completed todos - potentially synchronously downloaded from API
176 177 178 179 |
# File 'lib/logan/project.rb', line 176 def completed_todos return @completed_todos if @completed_todos completed_todos! end |
#completed_todos! ⇒ Object
181 182 183 184 185 |
# File 'lib/logan/project.rb', line 181 def completed_todos! response = Logan::Client.get "/projects/#{@id}/todos/completed.json" @completed_todos = handle_response(response, Proc.new {|h| Logan::Todo.new(h.merge({ :project_id => @id })) }) end |
#create_message(subject, content, subscribers, private) ⇒ Logan::Message
create a message via Basecamp API
134 135 136 137 138 139 140 141 142 |
# File 'lib/logan/project.rb', line 134 def (subject, content, subscribers, private) post_params = { :body => {subject: subject, content: content, subscribers: subscribers, private: private}.to_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/messages.json", post_params Logan::Project.new response end |
#create_todolist(todo_list) ⇒ Logan::TodoList
create a todo list in this project via Basecamp API
76 77 78 79 80 81 82 83 84 |
# File 'lib/logan/project.rb', line 76 def create_todolist(todo_list) post_params = { :body => todo_list.post_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/todolists.json", post_params Logan::TodoList.new response.merge({ :project_id => @id }) end |
#publish ⇒ Logan::Project
publish this project from Basecamp API
37 38 39 40 41 42 43 44 |
# File 'lib/logan/project.rb', line 37 def publish post_params = { :body => {}.to_json, :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'}) } response = Logan::Client.post "/projects/#{@id}/publish.json", post_params end |
#remaining_todos(&block) ⇒ Array<Logan::Todo>
returns the array of remaining todos - potentially synchronously downloaded from API
148 149 150 151 |
# File 'lib/logan/project.rb', line 148 def remaining_todos &block return @remaining_todos if @remaining_todos remaining_todos! &block end |
#remaining_todos!(&block) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/logan/project.rb', line 153 def remaining_todos! &block @remaining_todos = [] if block_given? page = 1 while true response = Logan::Client.get "/projects/#{@id}/todos/remaining.json?page=#{page}" list = handle_response(response, Proc.new {|h| Logan::Todo.new(h.merge({ :project_id => @id })) }) @remaining_todos << list page += 1 break if list.size < 50 end @remaining_todos = @remaining_todos.flatten else response = Logan::Client.get "/projects/#{@id}/todos/remaining.json" @remaining_todos = handle_response(response, Proc.new {|h| Logan::Todo.new(h.merge({ :project_id => @id })) }) end @remaining_todos end |
#todolist(list_id) ⇒ Logan::TodoList
get an individual todo list for this project from Basecamp API
67 68 69 70 |
# File 'lib/logan/project.rb', line 67 def todolist(list_id) response = Logan::Client.get "/projects/#{@id}/todolists/#{list_id}.json" Logan::TodoList.new response.parsed_response.merge({ :project_id => @id }) end |
#todolists ⇒ Array<Logan::TodoList>
get active todo lists for this project from Basecamp API
27 28 29 30 31 32 |
# File 'lib/logan/project.rb', line 27 def todolists active_response = Logan::Client.get "/projects/#{@id}/todolists.json" lists_array = active_response.parsed_response.map do |h| Logan::TodoList.new h.merge({ :project_id => @id }) end end |
#todos ⇒ Array<Logan::Todo>
returns the array of todos - potentially synchronously downloaded from API
204 205 206 207 |
# File 'lib/logan/project.rb', line 204 def todos return @todos if @todos todos! end |
#todos! ⇒ Object
209 210 211 212 213 |
# File 'lib/logan/project.rb', line 209 def todos! response = Logan::Client.get "/projects/#{@id}/todos.json" @todos = handle_response(response, Proc.new {|h| Logan::Todo.new(h.merge({ :project_id => @id })) }) end |
#trashed_todos ⇒ Array<Logan::Todo>
returns the array of trashed todos - potentially synchronously downloaded from API
190 191 192 193 |
# File 'lib/logan/project.rb', line 190 def trashed_todos return @trashed_todos if @trashed_todos trashed_todos! end |