1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace allejo\DaPulse; |
4
|
|
|
|
5
|
|
|
use allejo\DaPulse\Objects\ApiObject; |
6
|
|
|
|
7
|
|
|
class PulseColumn extends ApiObject |
8
|
|
|
{ |
9
|
|
|
const API_PREFIX = "boards"; |
10
|
|
|
|
11
|
|
|
const Date = "date"; |
|
|
|
|
12
|
|
|
const Numeric = "numeric"; |
|
|
|
|
13
|
|
|
const Person = "person"; |
|
|
|
|
14
|
|
|
const Status = "status"; |
|
|
|
|
15
|
|
|
const Text = "text"; |
|
|
|
|
16
|
|
|
const Timeline = "timerange"; |
|
|
|
|
17
|
|
|
|
18
|
|
|
protected $id; |
19
|
|
|
protected $title; |
20
|
|
|
protected $type; |
21
|
|
|
protected $empty_text; |
22
|
|
|
protected $labels; |
23
|
|
|
protected $board_id; |
24
|
|
|
|
25
|
|
|
public function getId () |
26
|
|
|
{ |
27
|
|
|
return $this->id; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getTitle () |
31
|
|
|
{ |
32
|
|
|
return $this->title; |
33
|
|
|
} |
34
|
|
|
|
35
|
11 |
|
public function getType () |
36
|
|
|
{ |
37
|
|
|
// @todo Workaround due to a bug in DaPulse's API see: https://github.com/allejo/PhpPulse/issues/5 |
|
|
|
|
38
|
11 |
|
if ($this->type === "color") |
39
|
|
|
{ |
40
|
1 |
|
$this->type = self::Status; |
41
|
|
|
} |
42
|
|
|
|
43
|
11 |
|
return $this->type; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getEmptyText () |
47
|
|
|
{ |
48
|
|
|
return $this->empty_text; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getLabels () |
52
|
|
|
{ |
53
|
|
|
return $this->labels; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getBoardId () |
57
|
|
|
{ |
58
|
|
|
return $this->board_id; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function editTitle ($title) |
62
|
|
|
{ |
63
|
|
|
$this->editField("title", $title); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function editLabels ($labels) |
67
|
|
|
{ |
68
|
|
|
$this->editField("labels", $labels); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function deleteColumn () |
72
|
|
|
{ |
73
|
|
|
$this->checkInvalid(); |
74
|
|
|
|
75
|
|
|
self::sendDelete($this->getColumnsUrl()); |
76
|
|
|
|
77
|
|
|
$this->deletedObject = true; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
private function editField ($field, $value) |
81
|
|
|
{ |
82
|
|
|
$this->checkInvalid(); |
83
|
|
|
|
84
|
|
|
$postParams = array( |
85
|
|
|
$field => $value |
86
|
|
|
); |
87
|
|
|
|
88
|
|
|
self::sendPut($this->getColumnsUrl(), $postParams); |
89
|
|
|
|
90
|
|
|
$this->$field = $value; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
private function getColumnsUrl () |
94
|
|
|
{ |
95
|
|
|
return sprintf("%s/%d/columns/%s.json", parent::apiEndpoint(), $this->getBoardId(), $this->getId()); |
|
|
|
|
96
|
|
|
} |
97
|
|
|
} |