Class: Podio::Task
Overview
Instance Attribute Summary
#attributes
Class Method Summary
collapse
-
.complete(id) ⇒ Object
-
.count_by_ref(ref_type, ref_id) ⇒ Object
-
.create(attributes, options = {}) ⇒ Object
-
.create_with_ref(ref_type, ref_id, attributes, options = {}) ⇒ Object
-
.delete(id) ⇒ Object
-
.delete_reference(task_id) ⇒ Object
-
.find(id, options = {}) ⇒ Object
-
.find_all(options = {}) ⇒ Object
-
.find_for_reference(ref_type, ref_id) ⇒ Object
-
.find_personal_summary(options = {}) ⇒ Object
-
.find_summary(options = {}) ⇒ Object
-
.find_summary_for_org(org_id, options = {}) ⇒ Object
-
.find_summary_for_reference(ref_type, ref_id, options = {}) ⇒ Object
-
.incomplete(id) ⇒ Object
-
.rank(id, before_task_id, after_task_id) ⇒ Object
-
.update(id, attributes, options = {}) ⇒ Object
-
.update_assignee(id, user_id) ⇒ Object
-
.update_description(id, description) ⇒ Object
-
.update_due_date(id, due_date) ⇒ Object
-
.update_due_on(id, options) ⇒ Object
-
.update_labels(id, label_ids) ⇒ Object
-
.update_private(id, private_flag) ⇒ Object
-
.update_reference(id, ref_type, ref_id) ⇒ Object
-
.update_text(id, text) ⇒ Object
Instance Method Summary
collapse
#remove_nil_values, #update_attributes
#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, has_many, has_one, #hash, #initialize, #initialize_attributes, klass_from_string, list, member, #new_record?, output_attribute_as_json, #parent_model, #persisted?, property, #to_param
Class Method Details
.complete(id) ⇒ Object
185
186
187
|
# File 'lib/podio/models/task.rb', line 185
def complete(id)
Podio.connection.post("/task/#{id}/complete").body
end
|
.count_by_ref(ref_type, ref_id) ⇒ Object
261
262
263
|
# File 'lib/podio/models/task.rb', line 261
def count_by_ref(ref_type, ref_id)
Podio.connection.get("/task/#{ref_type}/#{ref_id}/count").body['count']
end
|
.create(attributes, options = {}) ⇒ Object
106
107
108
109
110
111
112
113
|
# File 'lib/podio/models/task.rb', line 106
def create(attributes, options = {})
response = Podio.connection.post do |req|
req.url("/task/", options)
req.body = attributes
end
list [response.body].flatten
end
|
.create_with_ref(ref_type, ref_id, attributes, options = {}) ⇒ Object
116
117
118
119
120
121
122
123
|
# File 'lib/podio/models/task.rb', line 116
def create_with_ref(ref_type, ref_id, attributes, options = {})
response = Podio.connection.post do |req|
req.url("/task/#{ref_type}/#{ref_id}/", options)
req.body = attributes
end
list [response.body].flatten
end
|
.delete(id) ⇒ Object
180
181
182
|
# File 'lib/podio/models/task.rb', line 180
def delete(id)
Podio.connection.delete("/task/#{id}").status
end
|
.delete_reference(task_id) ⇒ Object
170
171
172
|
# File 'lib/podio/models/task.rb', line 170
def delete_reference(task_id)
Podio.connection.delete("/task/#{task_id}/ref").status
end
|
.find(id, options = {}) ⇒ Object
200
201
202
|
# File 'lib/podio/models/task.rb', line 200
def find(id, options = {})
member Podio.connection.get("/task/#{id}", options).body
end
|
.find_all(options = {}) ⇒ Object
210
211
212
213
214
|
# File 'lib/podio/models/task.rb', line 210
def find_all(options={})
list Podio.connection.get { |req|
req.url('/task/', options)
}.body
end
|
.find_for_reference(ref_type, ref_id) ⇒ Object
205
206
207
|
# File 'lib/podio/models/task.rb', line 205
def find_for_reference(ref_type, ref_id)
list Podio.connection.get("/task/#{ref_type}/#{ref_id}/").body
end
|
.find_personal_summary(options = {}) ⇒ Object
250
251
252
253
254
255
256
257
258
|
# File 'lib/podio/models/task.rb', line 250
def find_personal_summary(options={})
response = Podio.connection.get { |req|
req.url("/task/personal/summary", options)
}.body
response['overdue']['tasks'] = list(response['overdue']['tasks'])
response['today']['tasks'] = list(response['today']['tasks'])
response['other']['tasks'] = list(response['other']['tasks'])
response
end
|
.find_summary(options = {}) ⇒ Object
217
218
219
220
221
222
223
224
225
|
# File 'lib/podio/models/task.rb', line 217
def find_summary(options={})
response = Podio.connection.get { |req|
req.url("/task/summary", options)
}.body
response['overdue']['tasks'] = list(response['overdue']['tasks'])
response['today']['tasks'] = list(response['today']['tasks'])
response['other']['tasks'] = list(response['other']['tasks'])
response
end
|
.find_summary_for_org(org_id, options = {}) ⇒ Object
228
229
230
231
232
233
234
235
236
|
# File 'lib/podio/models/task.rb', line 228
def find_summary_for_org(org_id, options={})
response = Podio.connection.get { |req|
req.url("/task/org/#{org_id}/summary", options)
}.body
response['overdue']['tasks'] = list(response['overdue']['tasks'])
response['today']['tasks'] = list(response['today']['tasks'])
response['other']['tasks'] = list(response['other']['tasks'])
response
end
|
.find_summary_for_reference(ref_type, ref_id, options = {}) ⇒ Object
239
240
241
242
243
244
245
246
247
|
# File 'lib/podio/models/task.rb', line 239
def find_summary_for_reference(ref_type, ref_id, options={})
response = Podio.connection.get { |req|
req.url("/task/#{ref_type}/#{ref_id}/summary", options)
}.body
response['overdue']['tasks'] = list(response['overdue']['tasks'])
response['today']['tasks'] = list(response['today']['tasks'])
response['other']['tasks'] = list(response['other']['tasks'])
response
end
|
.incomplete(id) ⇒ Object
190
191
192
|
# File 'lib/podio/models/task.rb', line 190
def incomplete(id)
Podio.connection.post("/task/#{id}/incomplete").body
end
|
.rank(id, before_task_id, after_task_id) ⇒ Object
195
196
197
|
# File 'lib/podio/models/task.rb', line 195
def rank(id, before_task_id, after_task_id)
Podio.connection.post("/task/#{id}/rank", {:before => before_task_id, :after => after_task_id}).body
end
|
.update(id, attributes, options = {}) ⇒ Object
126
127
128
129
130
131
132
133
|
# File 'lib/podio/models/task.rb', line 126
def update(id, attributes, options = {})
response = Podio.connection.put do |req|
req.url("/task/#{id}", options)
req.body = attributes
end
member response.body
end
|
.update_assignee(id, user_id) ⇒ Object
160
161
162
|
# File 'lib/podio/models/task.rb', line 160
def update_assignee(id, user_id)
Podio.connection.post("/task/#{id}/assign", {:responsible => user_id}).status
end
|
.update_description(id, description) ⇒ Object
136
137
138
|
# File 'lib/podio/models/task.rb', line 136
def update_description(id, description)
Podio.connection.put("/task/#{id}/description", {:description => description}).status
end
|
.update_due_date(id, due_date) ⇒ Object
150
151
152
|
# File 'lib/podio/models/task.rb', line 150
def update_due_date(id, due_date)
Podio.connection.put("/task/#{id}/due_date", {:due_date => due_date}).status
end
|
.update_due_on(id, options) ⇒ Object
155
156
157
|
# File 'lib/podio/models/task.rb', line 155
def update_due_on(id, options)
Podio.connection.put("/task/#{id}/due_on", options).status
end
|
.update_labels(id, label_ids) ⇒ Object
175
176
177
|
# File 'lib/podio/models/task.rb', line 175
def update_labels(id, label_ids)
Podio.connection.put("/task/#{id}/label/", label_ids).status
end
|
.update_private(id, private_flag) ⇒ Object
146
147
148
|
# File 'lib/podio/models/task.rb', line 146
def update_private(id, private_flag)
Podio.connection.put("/task/#{id}/private", {:private => private_flag}).status
end
|
.update_reference(id, ref_type, ref_id) ⇒ Object
165
166
167
|
# File 'lib/podio/models/task.rb', line 165
def update_reference(id, ref_type, ref_id)
Podio.connection.put("/task/#{id}/ref", {:ref_type => ref_type, :ref_id => ref_id}).status
end
|
.update_text(id, text) ⇒ Object
141
142
143
|
# File 'lib/podio/models/task.rb', line 141
def update_text(id, text)
Podio.connection.put("/task/#{id}/text", {:text => text}).status
end
|
Instance Method Details
#complete ⇒ Object
90
91
92
|
# File 'lib/podio/models/task.rb', line 90
def complete
self.class.complete(self.id)
end
|
#create ⇒ Object
54
55
56
57
58
|
# File 'lib/podio/models/task.rb', line 54
def create
result = self.create_multiple self.task_id = result.first.id if result
result
end
|
#create_multiple ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/podio/models/task.rb', line 60
def create_multiple
compacted_attributes = remove_nil_values(self.attributes)
if(self.ref_type.present? && self.ref_id.present?)
self.class.create_with_ref(self.ref_type, self.ref_id, compacted_attributes)
else
self.class.create(compacted_attributes)
end
end
|
#delete_reference ⇒ Object
80
81
82
|
# File 'lib/podio/models/task.rb', line 80
def delete_reference
self.class.delete_reference(self.id)
end
|
#destroy ⇒ Object
70
71
72
|
# File 'lib/podio/models/task.rb', line 70
def destroy
self.class.delete(self.id)
end
|
#rank(previous_task, next_task) ⇒ Object
100
101
102
|
# File 'lib/podio/models/task.rb', line 100
def rank(previous_task, next_task)
self.class.rank(self.id, previous_task && previous_task.to_i, next_task && next_task.to_i)
end
|
#uncomplete ⇒ Object
95
96
97
|
# File 'lib/podio/models/task.rb', line 95
def uncomplete
self.class.incomplete(self.id)
end
|
#update_labels(label_ids) ⇒ Object
85
86
87
|
# File 'lib/podio/models/task.rb', line 85
def update_labels(label_ids)
self.class.update_labels(self.id, label_ids)
end
|
#update_reference(ref_type, ref_id) ⇒ Object
75
76
77
|
# File 'lib/podio/models/task.rb', line 75
def update_reference(ref_type, ref_id)
self.class.update_reference(self.id, ref_type, ref_id)
end
|