Overview

Namespaces

  • Angelfon
    • SDK
      • Exceptions
      • Http
      • Rest
        • Api
          • V099
            • User

Classes

  • Angelfon\SDK\Domain
  • Angelfon\SDK\Http\GuzzleClient
  • Angelfon\SDK\Http\Response
  • Angelfon\SDK\InstanceContext
  • Angelfon\SDK\InstanceResource
  • Angelfon\SDK\ListResource
  • Angelfon\SDK\Options
  • Angelfon\SDK\Page
  • Angelfon\SDK\Rest\Api
  • Angelfon\SDK\Rest\Api\V099
  • Angelfon\SDK\Rest\Api\V099\User\CallContext
  • Angelfon\SDK\Rest\Api\V099\User\CallInstance
  • Angelfon\SDK\Rest\Api\V099\User\CallList
  • Angelfon\SDK\Rest\Api\V099\User\CallOptions
  • Angelfon\SDK\Rest\Api\V099\User\CallPage
  • Angelfon\SDK\Rest\Api\V099\User\CreateCallOptions
  • Angelfon\SDK\Rest\Api\V099\User\CreateSmsOptions
  • Angelfon\SDK\Rest\Api\V099\User\ReadCallOptions
  • Angelfon\SDK\Rest\Api\V099\User\ReadSmsOptions
  • Angelfon\SDK\Rest\Api\V099\User\SmsContext
  • Angelfon\SDK\Rest\Api\V099\User\SmsInstance
  • Angelfon\SDK\Rest\Api\V099\User\SmsList
  • Angelfon\SDK\Rest\Api\V099\User\SmsOptions
  • Angelfon\SDK\Rest\Api\V099\User\SmsPage
  • Angelfon\SDK\Rest\Api\V099\UserContext
  • Angelfon\SDK\Rest\Api\V099\UserInstance
  • Angelfon\SDK\Rest\Client
  • Angelfon\SDK\Serialize
  • Angelfon\SDK\Values
  • Angelfon\SDK\Version
  • Angelfon\SDK\VersionInfo

Interfaces

  • Angelfon\SDK\Http\Client

Exceptions

  • Angelfon\SDK\Exceptions\AngelfonException
  • Angelfon\SDK\Exceptions\ConfigurationException
  • Angelfon\SDK\Exceptions\RestException
  • Overview
  • Namespace
  • Class
  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';
    }

    /**
     * Fetch an User instance
     * @return \Angelfon\SDK\Rest\Api\V099\UserInstance The User instance
     */
    public function fetch()
    {
        $params = Values::of(array());

    $payload = $this->version->fetch(
      'GET',
      $this->uri,
      $params
    );

    return new UserInstance($this->version, $payload);
    }

    /**
   * Access the calls
   * 
   * @return \Angelfon\SDK\Rest\Api\V099\User\CallList 
   */
  protected function getCalls() {
    if (!$this->_calls) $this->_calls = new CallList($this->version);
    return $this->_calls;
  }

    /**
   * Access the sms
   * 
   * @return \Angelfon\SDK\Rest\Api\V099\User\SmsList 
   */
  protected function getSms() {
    if (!$this->_sms) $this->_sms = new SmsList($this->version);
    return $this->_sms;
  }

  /**
   * Magic getter to lazy load subresources
   * 
   * @param string $name Subresource to return
   * @return \Angelfon\SDK\ListResource The requested subresource
   * @throws \Angelfon\SDK\Exceptions\AngelfonException For unknown subresources
   */
  public function __get($name) {
    if (property_exists($this, '_' . $name)) {
      $method = 'get' . ucfirst($name);
      return $this->$method();
    }

    throw new AngelfonException('Unknown subresource ' . $name);
  }

  /**
   * Magic caller to get resource contexts
   * 
   * @param string $name Resource to return
   * @param array $arguments Context parameters
   * @return \Angelfon\SDK\InstanceContext The requested resource context
   * @throws \Angelfon\SDK\Exceptions\AngelfonException For unknown resource
   */
  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');
  }

  /**
   * Provide a friendly representation
   * 
   * @return string Machine friendly representation
   */
  public function __toString() {
    $context = array();
    foreach ($this->solution as $key => $value) {
      $context[] = "$key=$value";
    }
    return '[Angelfon.SDK.Api.V099.UserContext ' . implode(' ', $context) . ']';
  }
}
API documentation generated by ApiGen