Class: Podio::Task
Instance Attribute Summary
#attributes, #error_code, #error_message, #error_parameters, #error_propagate
Class Method Summary
collapse
-
.complete(id) ⇒ Object
-
.create(attributes) ⇒ Object
-
.create_with_ref(ref_type, ref_id, attributes) ⇒ Object
-
.delete(id) ⇒ Object
-
.delete_reference(task_id) ⇒ Object
-
.find(id) ⇒ Object
-
.find_all(options = {}) ⇒ Object
-
.find_for_reference(ref_type, ref_id) ⇒ Object
-
.find_personal_summary ⇒ Object
-
.find_summary ⇒ Object
-
.find_summary_for_org(org_id, limit = nil) ⇒ Object
-
.find_summary_for_reference(ref_type, ref_id) ⇒ Object
-
.incomplete(id) ⇒ Object
-
.rank(id, before_task_id, after_task_id) ⇒ 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, handle_api_errors_for, has_many, has_one, #hash, #initialize, #initialize_attributes, list, member, #new_record?, output_attribute_as_json, #persisted?, property, #to_param
Class Method Details
.complete(id) ⇒ Object
150
151
152
|
# File 'lib/podio/models/task.rb', line 150
def complete(id)
Podio.connection.post("/task/#{id}/complete").body
end
|
.create(attributes) ⇒ Object
92
93
94
95
96
97
98
99
|
# File 'lib/podio/models/task.rb', line 92
def create(attributes)
response = Podio.connection.post do |req|
req.url "/task/"
req.body = attributes
end
list [response.body].flatten
end
|
.create_with_ref(ref_type, ref_id, attributes) ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'lib/podio/models/task.rb', line 101
def create_with_ref(ref_type, ref_id, attributes)
response = Podio.connection.post do |req|
req.url "/task/#{ref_type}/#{ref_id}/"
req.body = attributes
end
list [response.body].flatten
end
|
.delete(id) ⇒ Object
146
147
148
|
# File 'lib/podio/models/task.rb', line 146
def delete(id)
Podio.connection.delete("/task/#{id}").status
end
|
.delete_reference(task_id) ⇒ Object
138
139
140
|
# File 'lib/podio/models/task.rb', line 138
def delete_reference(task_id)
Podio.connection.delete("/task/#{task_id}/ref").status
end
|
.find(id) ⇒ Object
162
163
164
|
# File 'lib/podio/models/task.rb', line 162
def find(id)
member Podio.connection.get("/task/#{id}").body
end
|
.find_all(options = {}) ⇒ Object
170
171
172
173
174
|
# File 'lib/podio/models/task.rb', line 170
def find_all(options={})
list Podio.connection.get { |req|
req.url('/task/', options)
}.body
end
|
.find_for_reference(ref_type, ref_id) ⇒ Object
166
167
168
|
# File 'lib/podio/models/task.rb', line 166
def find_for_reference(ref_type, ref_id)
list Podio.connection.get("/task/#{ref_type}/#{ref_id}/").body
end
|
.find_personal_summary ⇒ Object
201
202
203
204
205
206
207
|
# File 'lib/podio/models/task.rb', line 201
def find_personal_summary
response = Podio.connection.get("/task/personal/summary").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 ⇒ Object
176
177
178
179
180
181
182
|
# File 'lib/podio/models/task.rb', line 176
def find_summary
response = Podio.connection.get("/task/summary").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, limit = nil) ⇒ Object
184
185
186
187
188
189
190
191
|
# File 'lib/podio/models/task.rb', line 184
def find_summary_for_org(org_id, limit=nil)
response = Podio.connection.get("/task/org/#{org_id}/summary" +
((limit != nil) ? "?limit=#{limit}" : "")).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) ⇒ Object
193
194
195
196
197
198
199
|
# File 'lib/podio/models/task.rb', line 193
def find_summary_for_reference(ref_type, ref_id)
response = Podio.connection.get("/task/#{ref_type}/#{ref_id}/summary").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
154
155
156
|
# File 'lib/podio/models/task.rb', line 154
def incomplete(id)
Podio.connection.post("/task/#{id}/incomplete").body
end
|
.rank(id, before_task_id, after_task_id) ⇒ Object
158
159
160
|
# File 'lib/podio/models/task.rb', line 158
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_assignee(id, user_id) ⇒ Object
130
131
132
|
# File 'lib/podio/models/task.rb', line 130
def update_assignee(id, user_id)
Podio.connection.post("/task/#{id}/assign", {:responsible => user_id}).status
end
|
.update_description(id, description) ⇒ Object
110
111
112
|
# File 'lib/podio/models/task.rb', line 110
def update_description(id, description)
Podio.connection.put("/task/#{id}/description", {:description => description}).status
end
|
.update_due_date(id, due_date) ⇒ Object
122
123
124
|
# File 'lib/podio/models/task.rb', line 122
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
126
127
128
|
# File 'lib/podio/models/task.rb', line 126
def update_due_on(id, options)
Podio.connection.put("/task/#{id}/due_on", options).status
end
|
.update_labels(id, label_ids) ⇒ Object
142
143
144
|
# File 'lib/podio/models/task.rb', line 142
def update_labels(id, label_ids)
Podio.connection.put("/task/#{id}/label/", label_ids).status
end
|
.update_private(id, private_flag) ⇒ Object
118
119
120
|
# File 'lib/podio/models/task.rb', line 118
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
134
135
136
|
# File 'lib/podio/models/task.rb', line 134
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
114
115
116
|
# File 'lib/podio/models/task.rb', line 114
def update_text(id, text)
Podio.connection.put("/task/#{id}/text", {:text => text}).status
end
|
Instance Method Details
#complete ⇒ Object
77
78
79
|
# File 'lib/podio/models/task.rb', line 77
def complete
self.class.complete(self.id)
end
|
#create ⇒ Object
46
47
48
49
50
|
# File 'lib/podio/models/task.rb', line 46
def create
result = self.create_multiple self.task_id = result.first.id if result
result
end
|
#create_multiple ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/podio/models/task.rb', line 52
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
69
70
71
|
# File 'lib/podio/models/task.rb', line 69
def delete_reference
self.class.delete_reference(self.id)
end
|
#destroy ⇒ Object
61
62
63
|
# File 'lib/podio/models/task.rb', line 61
def destroy
self.class.delete(self.id)
end
|
#rank(previous_task, next_task) ⇒ Object
85
86
87
|
# File 'lib/podio/models/task.rb', line 85
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
81
82
83
|
# File 'lib/podio/models/task.rb', line 81
def uncomplete
self.class.incomplete(self.id)
end
|
#update_labels(label_ids) ⇒ Object
73
74
75
|
# File 'lib/podio/models/task.rb', line 73
def update_labels(label_ids)
self.class.update_labels(self.id, label_ids)
end
|
#update_reference(ref_type, ref_id) ⇒ Object
65
66
67
|
# File 'lib/podio/models/task.rb', line 65
def update_reference(ref_type, ref_id)
self.class.update_reference(self.id, ref_type, ref_id)
end
|