|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright 2017 Vladimir Jimenez |
|
5
|
|
|
* @license https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace allejo\DaPulse; |
|
9
|
|
|
|
|
10
|
|
|
use allejo\DaPulse\Objects\ApiObject; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class PulseColumn |
|
14
|
|
|
* |
|
15
|
|
|
* @api |
|
16
|
|
|
* @package allejo\DaPulse |
|
17
|
|
|
* @since 0.1.0 |
|
18
|
|
|
*/ |
|
19
|
|
|
class PulseColumn extends ApiObject |
|
20
|
|
|
{ |
|
21
|
|
|
const API_PREFIX = "boards"; |
|
22
|
|
|
|
|
23
|
|
|
const Date = "date"; |
|
|
|
|
|
|
24
|
|
|
const Numeric = "numeric"; |
|
|
|
|
|
|
25
|
|
|
const Person = "person"; |
|
|
|
|
|
|
26
|
|
|
const Status = "status"; |
|
|
|
|
|
|
27
|
|
|
const Text = "text"; |
|
|
|
|
|
|
28
|
|
|
const Timeline = "timerange"; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
protected $title; |
|
31
|
|
|
protected $type; |
|
32
|
|
|
protected $empty_text; |
|
33
|
|
|
protected $labels; |
|
34
|
|
|
protected $board_id; |
|
35
|
|
|
|
|
36
|
38 |
|
public function __construct ($idOrArray) |
|
37
|
|
|
{ |
|
38
|
38 |
|
$this->arrayConstructionOnly = true; |
|
39
|
|
|
|
|
40
|
38 |
|
parent::__construct($idOrArray); |
|
41
|
38 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getId () |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->id; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getTitle () |
|
49
|
|
|
{ |
|
50
|
|
|
$this->lazyLoad(); |
|
51
|
|
|
|
|
52
|
|
|
return $this->title; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
11 |
|
public function getType () |
|
56
|
|
|
{ |
|
57
|
11 |
|
$this->lazyLoad(); |
|
58
|
|
|
|
|
59
|
|
|
// @todo Workaround due to a bug in DaPulse's API see: https://github.com/allejo/PhpPulse/issues/5 |
|
|
|
|
|
|
60
|
11 |
|
if ($this->type === "color") |
|
61
|
|
|
{ |
|
62
|
1 |
|
$this->type = self::Status; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
11 |
|
return $this->type; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getEmptyText () |
|
69
|
|
|
{ |
|
70
|
|
|
$this->lazyLoad(); |
|
71
|
|
|
|
|
72
|
|
|
return $this->empty_text; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function getLabels () |
|
76
|
|
|
{ |
|
77
|
|
|
$this->lazyLoad(); |
|
78
|
|
|
|
|
79
|
|
|
return $this->labels; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function getBoardId () |
|
83
|
|
|
{ |
|
84
|
|
|
$this->lazyLoad(); |
|
85
|
|
|
|
|
86
|
|
|
return $this->board_id; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function editTitle ($title) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->editField("title", $title); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function editLabels ($labels) |
|
95
|
|
|
{ |
|
96
|
|
|
$this->editField("labels", $labels); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function deleteColumn () |
|
100
|
|
|
{ |
|
101
|
|
|
$this->checkInvalid(); |
|
102
|
|
|
|
|
103
|
|
|
self::sendDelete($this->getColumnsUrl()); |
|
104
|
|
|
|
|
105
|
|
|
$this->deletedObject = true; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
private function editField ($field, $value) |
|
109
|
|
|
{ |
|
110
|
|
|
$this->checkInvalid(); |
|
111
|
|
|
|
|
112
|
|
|
$postParams = [ |
|
113
|
|
|
$field => $value |
|
114
|
|
|
]; |
|
115
|
|
|
|
|
116
|
|
|
self::sendPut($this->getColumnsUrl(), $postParams); |
|
117
|
|
|
|
|
118
|
|
|
$this->$field = $value; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
private function getColumnsUrl () |
|
122
|
|
|
{ |
|
123
|
|
|
return sprintf("%s/%d/columns/%s.json", parent::apiEndpoint(), $this->getBoardId(), $this->getId()); |
|
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
} |