1
|
|
|
<?php |
2
|
|
|
namespace Datatrics\API\Modules; |
3
|
|
|
|
4
|
|
|
use Datatrics\API\Client; |
5
|
|
|
|
6
|
|
|
class Profile extends Base |
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* Private constructor so only the client can create this |
10
|
|
|
* @param string $apikey |
|
|
|
|
11
|
|
|
* @param string $projectid |
|
|
|
|
12
|
|
|
*/ |
13
|
11 |
|
public function __construct(Client $client) |
14
|
|
|
{ |
15
|
11 |
|
parent::__construct($client); |
16
|
11 |
|
$this->SetUrl("/project/" . $this->GetClient()->GetProjectId() . "/profile"); |
17
|
11 |
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get one or multiple profiles |
21
|
|
|
* @param string profile id, leave null for list of profiles |
22
|
|
|
* @param object Containing query arguments |
23
|
|
|
* @return object Result of the request |
24
|
|
|
*/ |
25
|
|
|
public function Get($profileId = null, $args = array("limit" => 50)) |
26
|
|
|
{ |
27
|
|
|
if (is_null($profileId)) { |
28
|
|
|
return $this->GetClient()->Get($this->GetUrl(), $args); |
29
|
|
|
} |
30
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$profileId, $args); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Create new profile |
35
|
|
|
* @param object Containing all the information of a profile |
36
|
|
|
* @return object Result of the request |
37
|
|
|
*/ |
38
|
|
|
public function Create($profile) |
39
|
|
|
{ |
40
|
|
|
return $this->GetClient()->Post($this->GetUrl(), $profile); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Delete a profile by profileid |
45
|
|
|
* @param string Id of the profile to be deleted |
46
|
|
|
* @return object Result of the request |
47
|
|
|
*/ |
48
|
|
|
public function Delete($profileid) |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
return $this->GetClient()->Delete($this->GetUrl()."/".profileid); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Update a profile |
55
|
|
|
* @param object Profile containing the profileid and fields that need to be updated |
56
|
|
|
* @throws \Exception When profileid is not present |
57
|
|
|
* @return object Result of the request |
58
|
|
|
*/ |
59
|
|
|
public function Update($profile) |
60
|
|
|
{ |
61
|
|
|
if (!isset($profile['profileid'])) { |
62
|
|
|
throw new \Exception("profile must contain a profileid"); |
63
|
|
|
} |
64
|
|
|
return $this->GetClient()->Post($this->GetUrl()."/".$profile['profileid'], $profile); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Updates a maximum of 50 profiles at a time. |
69
|
|
|
* @param array Containing profiles with a maximum of 50 |
70
|
|
|
* @throws \Exception When more that 50 profiles are provided |
71
|
|
|
* @return object Result of the request |
72
|
|
|
*/ |
73
|
|
|
public function Bulk($profiles) |
74
|
|
|
{ |
75
|
|
|
if (count($profiles) > 50) { |
76
|
|
|
throw new \Exception("Maximum of 50 profiles allowed at a time"); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $this->GetClient()->Post($this->GetUrl()."/bulk", ['items' => $profiles]); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.