• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

podio-community / podio-php / 5242912328

pending completion
5242912328

push

github

web-flow
Merge pull request #228 from podio-community/90-non-static-podio-class

feat: isolated client class to allow for parallel usage + extension mocking

648 of 648 new or added lines in 66 files covered. (100.0%)

917 of 2108 relevant lines covered (43.5%)

24.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/models/PodioTask.php
1
<?php
2
/**
3
 * @see https://developers.podio.com/doc/tasks
4
 */
5
class PodioTask extends PodioObject
6
{
7
    public function __construct(PodioClient $podio_client, $attributes = array())
8
    {
9
        parent::__construct($podio_client);
×
10
        $this->property('task_id', 'integer', array('id' => true));
×
11
        $this->property('status', 'string');
×
12
        $this->property('group', 'string');
×
13
        $this->property('text', 'string');
×
14
        $this->property('description', 'string');
×
15
        $this->property('private', 'boolean');
×
16
        $this->property('due_on', 'datetime');
×
17
        $this->property('due_date', 'string');
×
18
        $this->property('due_time', 'string');
×
19
        $this->property('space_id', 'integer');
×
20
        $this->property('link', 'string');
×
21
        $this->property('created_on', 'datetime');
×
22
        $this->property('completed_on', 'datetime');
×
23
        $this->property('external_id', 'string');
×
24

25
        $this->has_one('ref', 'Reference');
×
26
        $this->has_one('created_by', 'ByLine');
×
27
        $this->has_one('completed_by', 'ByLine');
×
28
        $this->has_one('created_via', 'Via');
×
29
        $this->has_one('deleted_via', 'Via');
×
30
        $this->has_one('completed_via', 'Via');
×
31
        $this->has_one('responsible', 'User', array('json_value' => 'user_id'));
×
32
        $this->has_one('reminder', 'Reminder');
×
33
        $this->has_one('recurrence', 'Recurrence');
×
34
        $this->has_many('labels', 'TaskLabel', array('json_value' => 'label_id', 'json_target' => 'label_ids'));
×
35
        $this->has_many('files', 'File', array('json_value' => 'file_id', 'json_target' => 'file_ids'));
×
36
        $this->has_many('comments', 'Comment');
×
37

38
        $this->init($attributes);
×
39
    }
40

41
    /**
42
     * Creates or updates a task
43
     */
44
    public function save()
45
    {
46
        if ($this->id) {
×
47
            return self::update($this->id, $this, [], $this->podio_client);
×
48
        } else {
49
            $new = self::create($this, [], $this->podio_client);
×
50
            $this->task_id = $new->task_id;
×
51
            return $this;
×
52
        }
53
    }
54

55
    /**
56
     * Complete a task
57
     */
58
    public function completed()
59
    {
60
        return self::complete($this->id, $this->podio_client);
×
61
    }
62

63
    /**
64
     * Incomplete a task
65
     */
66
    public function incompleted()
67
    {
68
        return self::incomplete($this->id, $this->podio_client);
×
69
    }
70

71
    /**
72
     * Delete a task
73
     */
74
    public function destroy()
75
    {
76
        return self::delete($this->id, $this->podio_client);
×
77
    }
78

79
    /**
80
     * @see https://developers.podio.com/doc/tasks/create-task-22419
81
     */
82
    public static function create($attributes = array(), $options = array(), PodioClient $podio_client)
83
    {
84
        $url = $podio_client->url_with_options("/task/", $options);
×
85
        return self::member($podio_client->post($url, $attributes), $podio_client);
×
86
    }
87

88
    /**
89
     * @see https://developers.podio.com/doc/tasks/create-task-with-reference-22420
90
     */
91
    public static function create_for($ref_type, $ref_id, $attributes = array(), $options = array(), PodioClient $podio_client)
92
    {
93
        $url = $podio_client->url_with_options("/task/{$ref_type}/{$ref_id}/", $options);
×
94
        return self::member($podio_client->post($url, $attributes), $podio_client);
×
95
    }
96

97
    /**
98
     * @see https://developers.podio.com/doc/tasks/get-task-22413
99
     */
100
    public static function get($task_id, PodioClient $podio_client)
101
    {
102
        return self::member($podio_client->get("/task/{$task_id}"), $podio_client);
×
103
    }
104

105
    /**
106
     * @see https://developers.podio.com/doc/tasks/get-tasks-77949
107
     */
108
    public static function get_all($attributes = array(), PodioClient $podio_client)
109
    {
110
        return self::listing($podio_client->get("/task/", $attributes), $podio_client);
×
111
    }
112

113
    /**
114
     * @see https://developers.podio.com/doc/tasks/delete-task-77179
115
     */
116
    public static function delete($task_id, PodioClient $podio_client)
117
    {
118
        return $podio_client->delete("/task/{$task_id}");
×
119
    }
120

121
    /**
122
     * @see https://developers.podio.com/doc/tasks/remove-task-reference-6146114
123
     */
124
    public static function delete_ref($task_id, PodioClient $podio_client)
125
    {
126
        return $podio_client->delete("/task/{$task_id}/ref");
×
127
    }
128

129
    /**
130
     * @see https://developers.podio.com/doc/tasks/update-task-10583674
131
     */
132
    public static function update($task_id, $attributes = array(), $options = array(), PodioClient $podio_client)
133
    {
134
        $url = $podio_client->url_with_options("/task/{$task_id}", $options);
×
135
        return self::member($podio_client->put($url, $attributes), $podio_client);
×
136
    }
137

138
    /**
139
     * @see https://developers.podio.com/doc/tasks/assign-task-22412
140
     */
141
    public static function assign($task_id, $attributes = array(), PodioClient $podio_client)
142
    {
143
        return $podio_client->post("/task/{$task_id}/assign", $attributes);
×
144
    }
145

146
    /**
147
     * @see https://developers.podio.com/doc/tasks/complete-task-22432
148
     */
149
    public static function complete($task_id, PodioClient $podio_client)
150
    {
151
        return $podio_client->post("/task/{$task_id}/complete");
×
152
    }
153

154
    /**
155
     * @see https://developers.podio.com/doc/tasks/incomplete-task-22433
156
     */
157
    public static function incomplete($task_id, PodioClient $podio_client)
158
    {
159
        return $podio_client->post("/task/{$task_id}/incomplete");
×
160
    }
161

162
    /**
163
     * @see https://developers.podio.com/doc/tasks/rank-task-81015
164
     */
165
    public static function rank($task_id, $attributes = array(), PodioClient $podio_client)
166
    {
167
        return $podio_client->post("/task/{$task_id}/rank", $attributes);
×
168
    }
169

170
    /**
171
     * @see https://developers.podio.com/doc/calendar/get-task-calendar-as-ical-10195650
172
     */
173
    public static function ical($task_id, PodioClient $podio_client)
174
    {
175
        return $podio_client->get("/calendar/task/{$task_id}/ics/")->body;
×
176
    }
177

178
    /**
179
     * @see https://developers.podio.com/doc/tasks/get-task-summary-1612017
180
     */
181
    public static function get_summary($attributes = array(), PodioClient $podio_client)
182
    {
183
        $result = $podio_client->get("/task/summary", $attributes)->json_body();
×
184
        $result['overdue']['tasks'] = self::listing($result['overdue']['tasks'], $podio_client);
×
185
        $result['today']['tasks'] = self::listing($result['today']['tasks'], $podio_client);
×
186
        $result['other']['tasks'] = self::listing($result['other']['tasks'], $podio_client);
×
187
        return $result;
×
188
    }
189

190
    /**
191
     * @see https://developers.podio.com/doc/tasks/get-task-summary-for-personal-1657217
192
     */
193
    public static function get_summary_personal($attributes = array(), PodioClient $podio_client)
194
    {
195
        $result = $podio_client->get("/task/personal/summary", $attributes)->json_body();
×
196
        $result['overdue']['tasks'] = self::listing($result['overdue']['tasks'], $podio_client);
×
197
        $result['today']['tasks'] = self::listing($result['today']['tasks'], $podio_client);
×
198
        $result['other']['tasks'] = self::listing($result['other']['tasks'], $podio_client);
×
199
        return $result;
×
200
    }
201

202
    /**
203
     * @see https://developers.podio.com/doc/tasks/get-task-summary-for-organization-1612063
204
     */
205
    public static function get_summary_for_org($org_id, $attributes = array(), PodioClient $podio_client)
206
    {
207
        $result = $podio_client->get("/task/org/{$org_id}/summary", $attributes)->json_body();
×
208
        $result['overdue']['tasks'] = self::listing($result['overdue']['tasks'], $podio_client);
×
209
        $result['today']['tasks'] = self::listing($result['today']['tasks'], $podio_client);
×
210
        $result['other']['tasks'] = self::listing($result['other']['tasks'], $podio_client);
×
211
        return $result;
×
212
    }
213

214
    /**
215
     * @see https://developers.podio.com/doc/tasks/get-task-summary-for-space-1612130
216
     */
217
    public static function get_summary_for_space($space_id, $attributes = array(), PodioClient $podio_client)
218
    {
219
        $result = $podio_client->get("/task/space/{$space_id}/summary", $attributes)->json_body();
×
220
        $result['overdue']['tasks'] = self::listing($result['overdue']['tasks'], $podio_client);
×
221
        $result['today']['tasks'] = self::listing($result['today']['tasks'], $podio_client);
×
222
        $result['other']['tasks'] = self::listing($result['other']['tasks'], $podio_client);
×
223
        return $result;
×
224
    }
225

226
    /**
227
     * @see https://developers.podio.com/doc/tasks/get-task-summary-for-reference-1657980
228
     */
229
    public static function get_summary_for($ref_type, $ref_id, $attributes = array(), PodioClient $podio_client)
230
    {
231
        $result = $podio_client->get("/task/{$ref_type}/{$ref_id}/summary", $attributes)->json_body();
×
232
        $result['overdue']['tasks'] = self::listing($result['overdue']['tasks'], $podio_client);
×
233
        $result['today']['tasks'] = self::listing($result['today']['tasks'], $podio_client);
×
234
        $result['other']['tasks'] = self::listing($result['other']['tasks'], $podio_client);
×
235
        return $result;
×
236
    }
237

238
    /**
239
     * @see https://developers.podio.com/doc/tasks/update-task-reference-170733
240
     */
241
    public static function update_reference($task_id, $attributes = array(), PodioClient $podio_client)
242
    {
243
        return $podio_client->put("/task/{$task_id}/ref", $attributes)->body;
×
244
    }
245

246
    /**
247
     * @see https://developers.podio.com/doc/tasks/get-task-count-38316458
248
     */
249
    public static function count($ref_type, $ref_id, PodioClient $podio_client)
250
    {
251
        return $podio_client->get("/task/{$ref_type}/{$ref_id}/count")->json_body();
×
252
    }
253

254
    /**
255
     * @see https://developers.podio.com/doc/tasks/update-task-private-22434
256
     */
257
    public function update_private($private_flag, $options = array())
258
    {
259
        $url = $this->podio_client->url_with_options("/task/{$this->id}/private", $options);
×
260
        return $this->podio_client->put($url, array('private' => $private_flag))->body;
×
261
    }
262
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc