1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace allejo\DaPulse\Objects; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class PulseColumnColorValue |
7
|
|
|
* |
8
|
|
|
* @package allejo\DaPulse\Objects |
9
|
|
|
*/ |
10
|
|
|
class PulseColumnStatusValue extends PulseColumnValue |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The index of the orange status |
14
|
|
|
*/ |
15
|
|
|
const Orange = 0; |
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The index of the light green status |
19
|
|
|
*/ |
20
|
|
|
const L_Green = 1; |
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The index of the red status |
24
|
|
|
*/ |
25
|
|
|
const Red = 2; |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The index of the blue status |
29
|
|
|
*/ |
30
|
|
|
const Blue = 3; |
|
|
|
|
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The index of the purple status |
34
|
|
|
*/ |
35
|
|
|
const Purple = 4; |
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The index of the grey status |
39
|
|
|
*/ |
40
|
|
|
const Grey = 5; |
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The index of the green status |
44
|
|
|
*/ |
45
|
|
|
const Green = 6; |
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* The index of the light blue status |
49
|
|
|
*/ |
50
|
|
|
const L_Blue = 7; |
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The index of the gold status |
54
|
|
|
*/ |
55
|
|
|
const Gold = 8; |
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* The index of the yellow status |
59
|
|
|
*/ |
60
|
|
|
const Yellow = 9; |
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* The index of the black status |
64
|
|
|
*/ |
65
|
|
|
const Black = 10; |
|
|
|
|
66
|
|
|
|
67
|
|
|
public function getValue () |
68
|
|
|
{ |
69
|
|
|
if (!isset($this->column_value)) |
70
|
|
|
{ |
71
|
|
|
$this->column_value = $this->jsonResponse["value"]["index"]; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return $this->column_value; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function updateValue ($color) |
78
|
|
|
{ |
79
|
|
|
if ($color < 0 && $color > 10) |
80
|
|
|
{ |
81
|
|
|
throw new \InvalidArgumentException("DaPulse only has color indexes from 0-10"); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$url = sprintf("%s/%d/columns/%s/status.json", parent::apiEndpoint(), $this->board_id, $this->column_id); |
|
|
|
|
85
|
|
|
$postParams = array( |
86
|
|
|
"pulse_id" => $this->pulse_id, |
87
|
|
|
"color_index" => $color |
88
|
|
|
); |
89
|
|
|
|
90
|
|
|
self::sendPut($url, $postParams); |
91
|
|
|
|
92
|
|
|
$this->column_value = $color; |
93
|
|
|
} |
94
|
|
|
} |