1
|
|
|
<?php |
2
|
|
|
namespace Datatrics\API\Modules; |
3
|
|
|
|
4
|
|
|
class Campaign extends Base |
5
|
|
|
{ |
6
|
|
|
/** |
7
|
|
|
* Private constructor so only the client can create this |
8
|
|
|
* @param string $apikey |
9
|
|
|
* @param string $projectid |
10
|
|
|
*/ |
11
|
|
|
public function __construct($apikey, $projectid) |
12
|
|
|
{ |
13
|
|
|
parent::__construct($apikey, "/project/" . $projectid . "/campaign"); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Get one or multiple campaigns |
18
|
|
|
* @param string campaign id, leave null for list of campaigns |
19
|
|
|
* @param object Containing query arguments |
20
|
|
|
* @return object Result of the request |
21
|
|
|
*/ |
22
|
|
|
public function Get($campaignId = null, $args = array("limit" => 50)) |
23
|
|
|
{ |
24
|
|
|
return $campaignId == null ? $this->request(self::HTTP_GET, "?".http_build_query($args)) : $this->request(self::HTTP_GET, "/".$campaignId."?".http_build_query($args)); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Create new campaign |
29
|
|
|
* @param object Containing all the information of a bucket |
30
|
|
|
* @return object Result of the request |
31
|
|
|
*/ |
32
|
|
|
public function Create($campaign) |
33
|
|
|
{ |
34
|
|
|
return $this->request(self::HTTP_POST, "", $campaign); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Update a box |
39
|
|
|
* @param object Box containing the boxid and fields that need to be updated |
40
|
|
|
* @throws \Exception When boxid is not present |
41
|
|
|
* @return object Result of the request |
42
|
|
|
*/ |
43
|
|
|
public function Update($campaign) |
44
|
|
|
{ |
45
|
|
|
if (!isset($campaign['campaignid'])) { |
46
|
|
|
throw new \Exception("campaign must contain a campaignid"); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return $this->request(self::HTTP_PUT, "/".$campaign['campaignid'], $campaign); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Delete a campaign object by campaign id |
54
|
|
|
* @param string Id of the bucket |
55
|
|
|
* @param string Id of the object to be deleted |
56
|
|
|
* @return object Result of the request |
57
|
|
|
*/ |
58
|
|
|
public function Delete($campaignId) |
59
|
|
|
{ |
60
|
|
|
return $this->request(self::HTTP_DELETE, "/".$campaignId); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Update a box |
65
|
|
|
* @param object Box containing the boxid and fields that need to be updated |
66
|
|
|
* @throws \Exception When boxid is not present |
67
|
|
|
* @return object Result of the request |
68
|
|
|
*/ |
69
|
|
|
public function Fields($campaignId) |
70
|
|
|
{ |
71
|
|
|
return $this->request(self::HTTP_PUT, "/".$campaignId."/fields", $campaign); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.