|
1
|
|
|
<?php |
|
2
|
|
|
namespace Datatrics\API\Modules; |
|
3
|
|
|
|
|
4
|
|
|
use Datatrics\API\Client; |
|
5
|
|
|
|
|
6
|
|
|
class Journey 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() . "/journey"); |
|
16
|
16 |
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get one or multiple journeys |
|
20
|
|
|
* @param string journey 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($journeyId = null, $args = array("limit" => 50)) |
|
25
|
|
|
{ |
|
26
|
|
|
if (is_null($journeyId)) { |
|
27
|
|
|
return $this->GetClient()->Get($this->GetUrl(), $args); |
|
28
|
|
|
} |
|
29
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$journeyId, $args); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Create new journey |
|
34
|
|
|
* @param object Containing all the information of a journey |
|
35
|
|
|
* @return object Result of the request |
|
36
|
|
|
*/ |
|
37
|
|
|
public function Create($journey) |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->GetClient()->Post($this->GetUrl(), $journey); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Update a journey |
|
44
|
|
|
* @param object Containing all the information of a journey |
|
45
|
|
|
* @return object Result of the request |
|
46
|
|
|
*/ |
|
47
|
|
|
public function Update($journey) |
|
48
|
|
|
{ |
|
49
|
|
|
if (!isset($journey['journeyid'])) { |
|
50
|
|
|
throw new \Exception('journey must contain journeyid'); |
|
51
|
|
|
} |
|
52
|
|
|
return $this->GetClient()->Put($this->GetUrl()."/".$journey['journeyid'], $journey); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Delete a journey object by journey id |
|
57
|
|
|
* @param string Id of the journey |
|
58
|
|
|
* @return object Result of the request |
|
59
|
|
|
*/ |
|
60
|
|
|
public function Delete($journeyId) |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->GetClient()->Delete($this->GetUrl()."/".$journeyId); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Retrieve stats of a journey by journey id |
|
67
|
|
|
* @param string Id of the journey |
|
68
|
|
|
* @return object Result of the request |
|
69
|
|
|
*/ |
|
70
|
|
|
public function Stats($journeyId) |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->GetClient()->Get($this->GetUrl()."/".$journeyId."/stats"); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|