1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace allejo\DaPulse\Objects; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class PulseColumnColorValue |
7
|
|
|
* |
8
|
|
|
* @package allejo\DaPulse\Objects |
9
|
|
|
* @since 0.1.0 |
10
|
|
|
*/ |
11
|
|
|
class PulseColumnStatusValue extends PulseColumnValue |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* The index of the orange status |
15
|
|
|
*/ |
16
|
|
|
const Orange = 0; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The index of the light green status |
20
|
|
|
*/ |
21
|
|
|
const L_Green = 1; |
|
|
|
|
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The index of the red status |
25
|
|
|
*/ |
26
|
|
|
const Red = 2; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The index of the blue status |
30
|
|
|
*/ |
31
|
|
|
const Blue = 3; |
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The index of the purple status |
35
|
|
|
*/ |
36
|
|
|
const Purple = 4; |
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The index of the grey status |
40
|
|
|
*/ |
41
|
|
|
const Grey = 5; |
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The index of the green status |
45
|
|
|
*/ |
46
|
|
|
const Green = 6; |
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The index of the light blue status |
50
|
|
|
*/ |
51
|
|
|
const L_Blue = 7; |
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* The index of the gold status |
55
|
|
|
*/ |
56
|
|
|
const Gold = 8; |
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The index of the yellow status |
60
|
|
|
*/ |
61
|
|
|
const Yellow = 9; |
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* The index of the black status |
65
|
|
|
*/ |
66
|
|
|
const Black = 10; |
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the numerical representation of the color that a status column is set to. |
70
|
|
|
* |
71
|
|
|
* @api |
72
|
|
|
* |
73
|
|
|
* @since 0.1.0 |
74
|
|
|
* |
75
|
|
|
* @return int The color value of a column |
76
|
|
|
*/ |
77
|
|
|
public function getValue () |
78
|
|
|
{ |
79
|
|
|
if (!isset($this->column_value)) |
80
|
|
|
{ |
81
|
|
|
$this->column_value = $this->jsonResponse["value"]["index"]; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $this->column_value; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Update the status of a status column |
89
|
|
|
* |
90
|
|
|
* It is highly recommended that you use the constants available in the **PulseColumnColorValue** class to match the |
91
|
|
|
* colors; keep in mind this value cannot be higher than 11. |
92
|
|
|
* |
93
|
|
|
* @api |
94
|
|
|
* |
95
|
|
|
* @param int $color The numerical value of the new color value |
96
|
|
|
* |
97
|
|
|
* @see PulseColumnStatusValue::Orange PulseColumnStatusValue::Orange |
98
|
|
|
* @see PulseColumnStatusValue::L_Green PulseColumnStatusValue::L_Green |
99
|
|
|
* @see PulseColumnStatusValue::Red PulseColumnStatusValue::Red |
100
|
|
|
* @see PulseColumnStatusValue::Blue PulseColumnStatusValue::Blue |
101
|
|
|
* @see PulseColumnStatusValue::Purple PulseColumnStatusValue::Purple |
102
|
|
|
* @see PulseColumnStatusValue::Grey PulseColumnStatusValue::Grey |
103
|
|
|
* @see PulseColumnStatusValue::Green PulseColumnStatusValue::Green |
104
|
|
|
* @see PulseColumnStatusValue::L_Blue PulseColumnStatusValue::L_Blue |
105
|
|
|
* @see PulseColumnStatusValue::Gold PulseColumnStatusValue::Gold |
106
|
|
|
* @see PulseColumnStatusValue::Yellow PulseColumnStatusValue::Yellow |
107
|
|
|
* @see PulseColumnStatusValue::Black PulseColumnStatusValue::Black |
108
|
|
|
* |
109
|
|
|
* @since 0.1.0 |
110
|
|
|
*/ |
111
|
|
|
public function updateValue ($color) |
112
|
|
|
{ |
113
|
|
|
if ($color < 0 && $color > 10) |
114
|
|
|
{ |
115
|
|
|
throw new \InvalidArgumentException("DaPulse only has color indexes from 0-10"); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
$url = sprintf("%s/%d/columns/%s/status.json", self::apiEndpoint(), $this->board_id, $this->column_id); |
119
|
|
|
$postParams = array( |
120
|
|
|
"pulse_id" => $this->pulse_id, |
121
|
|
|
"color_index" => $color |
122
|
|
|
); |
123
|
|
|
|
124
|
|
|
self::sendPut($url, $postParams); |
125
|
|
|
|
126
|
|
|
$this->column_value = $color; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get the hex value of the color used on DaPulse to represent the different statuses. |
131
|
|
|
* |
132
|
|
|
* @api |
133
|
|
|
* |
134
|
|
|
* @param int $numericalValue The numerical value of the column |
135
|
|
|
* |
136
|
|
|
* @since 0.1.0 |
137
|
|
|
* |
138
|
|
|
* @return string A hex value **without** the leading # |
139
|
|
|
*/ |
140
|
|
|
public static function getHexColor ($numericalValue) |
141
|
|
|
{ |
142
|
|
|
$colorArray = array( |
143
|
|
|
self::Orange => "fdab3d", |
144
|
|
|
self::L_Green => "00c875", |
145
|
|
|
self::Red => "e2445c", |
146
|
|
|
self::Blue => "0086c0", |
147
|
|
|
self::L_Blue => "579bfc", |
148
|
|
|
self::Purple => "a25ddc", |
149
|
|
|
self::Green => "037f4c", |
150
|
|
|
self::Gold => "CAB641", |
151
|
|
|
self::Yellow => "FFCB00", |
152
|
|
|
self::Black => "333333", |
153
|
|
|
self::Grey => "c4c4c4" |
154
|
|
|
); |
155
|
|
|
|
156
|
|
|
return $colorArray[$numericalValue]; |
157
|
|
|
} |
158
|
|
|
} |