1
|
|
|
<?php |
2
|
|
|
namespace Datatrics\API\Modules; |
3
|
|
|
|
4
|
|
|
use Datatrics\API\Client; |
5
|
|
|
|
6
|
|
|
class Campaign 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() . "/campaign"); |
17
|
11 |
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get one or multiple campaigns |
21
|
|
|
* @param string campaign id, leave null for list of campaigns |
22
|
|
|
* @param object Containing query arguments |
23
|
|
|
* @return object Result of the request |
24
|
|
|
*/ |
25
|
|
|
public function Get($campaignId = null, $args = array("limit" => 50)) |
26
|
|
|
{ |
27
|
|
|
if (is_null($campaignId)) { |
28
|
|
|
return $this->GetClient()->Get($this->GetUrl(), $args); |
29
|
|
|
} |
30
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$campaignId, $args); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get one or multiple lanes |
35
|
|
|
* @param string campaign id |
36
|
|
|
* @param string lane id, leave null for list of lanes |
37
|
|
|
* @param object Containing query arguments |
38
|
|
|
* @return object Result of the request |
39
|
|
|
*/ |
40
|
|
|
public function GetLane($campaignId, $laneId = null, $args = array("limit" => 50)) |
41
|
|
|
{ |
42
|
|
|
if (is_null($laneId)) { |
43
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/lane", $args); |
44
|
|
|
} |
45
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/lane/".$laneId, $args); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Create new campaign |
50
|
|
|
* @param object Containing all the information of a lane |
51
|
|
|
* @return object Result of the request |
52
|
|
|
*/ |
53
|
|
|
public function Create($campaign) |
54
|
|
|
{ |
55
|
|
|
return $this->GetClient()->Post($this->GetUrl(), $campaign); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Create new lane |
60
|
|
|
* @param string campaign id |
61
|
|
|
* @param object Containing all the information of a lane |
62
|
|
|
* @return object Result of the request |
63
|
|
|
*/ |
64
|
|
|
public function CreateLane($campaignId, $lane) |
65
|
|
|
{ |
66
|
|
|
return $this->GetClient()->Post($this->GetUrl()."/".$campaignId."/lane", $lane); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Update a campaign |
71
|
|
|
* @param object campaign containing the campaign id and fields that need to be updated |
72
|
|
|
* @throws \Exception When boxid is not present |
73
|
|
|
* @return object Result of the request |
74
|
|
|
*/ |
75
|
|
|
public function Update($campaign) |
76
|
|
|
{ |
77
|
|
|
if (!isset($campaign['campaignid'])) { |
78
|
|
|
throw new \Exception("campaign must contain a campaignid"); |
79
|
|
|
} |
80
|
|
|
return $this->GetClient()->Put($this->GetUrl()."/".$campaign['campaignid'], $campaign); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Update a lane |
85
|
|
|
* @param string Id of the campaign |
86
|
|
|
* @param object lane containing the laneid and fields that need to be updated |
87
|
|
|
* @throws \Exception When boxid is not present |
88
|
|
|
* @return object Result of the request |
89
|
|
|
*/ |
90
|
|
|
public function UpdateLane($campaignId, $lane) |
91
|
|
|
{ |
92
|
|
|
if (!isset($lane['laneid'])) { |
93
|
|
|
throw new \Exception("lane must contain a laneid"); |
94
|
|
|
} |
95
|
|
|
return $this->GetClient()->Put($this->GetUrl()."/".$campaignId."/lane/".$lane['laneid'], $lane); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Delete a campaign object by campaign id |
100
|
|
|
* @param string Id of the campaign |
101
|
|
|
* @return object Result of the request |
102
|
|
|
*/ |
103
|
|
|
public function Delete($campaignId) |
104
|
|
|
{ |
105
|
|
|
return $this->GetClient()->Delete($this->GetUrl()."/".$campaignId); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Delete a campaign object by campaign id |
110
|
|
|
* @param string Id of the campaign |
111
|
|
|
* @return object Result of the request |
112
|
|
|
*/ |
113
|
|
|
public function DeleteLane($campaignId, $laneId) |
114
|
|
|
{ |
115
|
|
|
return $this->GetClient()->Delete($this->GetUrl()."/".$campaignId."/lane/".$laneId); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Retrieve stats of a lane by campaign |
120
|
|
|
* @param string Id of the campaign |
121
|
|
|
* @return object Result of the request |
122
|
|
|
*/ |
123
|
|
|
public function Stats($campaignId) |
124
|
|
|
{ |
125
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/stats"); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* Retrieve stats of a lane by campaign and lane id |
130
|
|
|
* @param string Id of the campaign |
131
|
|
|
* @param string Id of the lane to be deleted |
132
|
|
|
* @return object Result of the request |
133
|
|
|
*/ |
134
|
|
|
public function StatsLane($campaignId, $laneId) |
135
|
|
|
{ |
136
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$campaignId."/lane/".$laneId."/stats"); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|
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.