|
1
|
|
|
<?php |
|
2
|
|
|
namespace Datatrics\API\Modules; |
|
3
|
|
|
|
|
4
|
|
|
use Datatrics\API\Client; |
|
5
|
|
|
|
|
6
|
|
|
class Scorecard extends Base |
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* Private constructor so only the client can create this |
|
10
|
|
|
* @param Client $client |
|
11
|
|
|
*/ |
|
12
|
16 |
|
public function __construct(Client $client) |
|
13
|
|
|
{ |
|
14
|
16 |
|
parent::__construct($client); |
|
15
|
16 |
|
$this->SetUrl("/project/" . $this->GetClient()->GetProjectId() . "/scorecard"); |
|
16
|
16 |
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get one or multiple scorecards |
|
20
|
|
|
* @param string scorecard id, leave null for list of boxes |
|
21
|
|
|
* @param object Containing query arguments |
|
22
|
|
|
* @return object Result of the request |
|
23
|
|
|
*/ |
|
24
|
|
|
public function Get($scorecardId = null, $args = array("limit" => 50)) |
|
25
|
|
|
{ |
|
26
|
|
|
if (is_null($scorecardId)) { |
|
27
|
|
|
return $this->GetClient()->Get($this->GetUrl(), $args); |
|
28
|
|
|
} |
|
29
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$scorecardId, $args); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Create new scorecard |
|
34
|
|
|
* @param object Containing all the information of a scorecard |
|
35
|
|
|
* @return object Result of the request |
|
36
|
|
|
*/ |
|
37
|
|
|
public function Create($scorecard) |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->GetClient()->Post($this->GetUrl(), $scorecard); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Delete a scorecard object by scorecard id |
|
44
|
|
|
* @param string Id of the scorecard |
|
45
|
|
|
* @return object Result of the request |
|
46
|
|
|
*/ |
|
47
|
|
|
public function Delete($scorecardId) |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->GetClient()->Delete($this->GetUrl()."/".$scorecardId); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Updates a maximum of 50 scorecard items at a time. |
|
54
|
|
|
* @param array Containing scorecards with a maximum of 50 |
|
55
|
|
|
* @throws \Exception When more that 50 content items are provided |
|
56
|
|
|
* @return object Result of the request |
|
57
|
|
|
*/ |
|
58
|
|
|
public function Bulk($scorecards) |
|
59
|
|
|
{ |
|
60
|
|
|
if (count($scorecards) > 50) { |
|
61
|
|
|
throw new \Exception("Maximum of 50 scorecards allowed at a time"); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $this->GetClient()->Post($this->GetUrl()."/bulk", ['items' => $scorecards]); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|