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: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106:
<?php
namespace Angelfon\SDK\Rest\Api\V099;
use Angelfon\SDK\InstanceContext;
use Angelfon\SDK\Version;
use Angelfon\SDK\Values;
use Angelfon\SDK\Exceptions\AngelfonException;
use Angelfon\SDK\Rest\Api\V099\UserInstance;
use Angelfon\SDK\Rest\Api\V099\User\CallList;
use Angelfon\SDK\Rest\Api\V099\User\SmsList;
class UserContext extends InstanceContext
{
protected $_calls = null;
protected $_sms = null;
public function __construct(Version $version)
{
parent::__construct($version);
$this->uri = '/user';
}
public function fetch()
{
$params = Values::of(array());
$payload = $this->version->fetch(
'GET',
$this->uri,
$params
);
return new UserInstance($this->version, $payload);
}
protected function getCalls() {
if (!$this->_calls) $this->_calls = new CallList($this->version);
return $this->_calls;
}
protected function getSms() {
if (!$this->_sms) $this->_sms = new SmsList($this->version);
return $this->_sms;
}
public function __get($name) {
if (property_exists($this, '_' . $name)) {
$method = 'get' . ucfirst($name);
return $this->$method();
}
throw new AngelfonException('Unknown subresource ' . $name);
}
public function __call($name, $arguments) {
$property = $this->$name;
if (method_exists($property, 'getContext')) {
return call_user_func_array(array($property, 'getContext'), $arguments);
}
throw new AngelfonException('Resource does not have a context');
}
public function __toString() {
$context = array();
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Angelfon.SDK.Api.V099.UserContext ' . implode(' ', $context) . ']';
}
}