Voice.php
1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Zendesk\API;
/**
* The Voice class is a wrapper for methods as detailed on http://developer.zendesk.com/documentation/rest_api/voice.html
* @package Zendesk\API
*
* @method VoicePhoneNumbers phoneNumbers()
* @method VoiceGreetings greetings()
* @method VoiceStats stats()
* @method VoiceAgents agents()
* @method VoiceTickets tickets()
*/
class Voice extends ClientAbstract
{
/**
* @var VoicePhoneNumbers
*/
protected $phoneNumbers;
/**
* @var VoiceGreetings
*/
protected $greetings;
/**
* @var VoiceStats
*/
protected $stats;
/**
* @var VoiceAgents
*/
protected $agents;
/**
* @var VoiceTickets
*/
protected $tickets;
/**
* @param Client $client
*/
public function __construct(Client $client)
{
parent::__construct($client);
$this->phoneNumbers = new VoicePhoneNumbers($client);
$this->greetings = new VoiceGreetings($client);
$this->stats = new VoiceStats($client);
$this->agents = new VoiceAgents($client);
$this->tickets = new VoiceTickets($client);
}
/**
* Generic method to object getter. Since all objects are protected, this method
* exposes a getter function with the same name as the protected variable, for example
* $client->tickets can be referenced by $client->tickets()
*
* @param $name
* @param $arguments
*
* @throws CustomException
*/
public function __call($name, $arguments)
{
if (isset($this->$name)) {
return ((isset($arguments[0])) && ($arguments[0] != null) ? $this->$name->setLastId($arguments[0]) : $this->$name);
}
$namePlural = $name . 's'; // try pluralize
if (isset($this->$namePlural)) {
return $this->$namePlural->setLastId($arguments[0]);
} else {
throw new CustomException("No method called $name available in " . __CLASS__);
}
}
}