Init commit
This commit is contained in:
commit
5febd4d014
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Twilio;
|
||||
|
||||
class Deserialize {
|
||||
|
||||
/**
|
||||
* Deserialize a string date into a DateTime object
|
||||
*
|
||||
* @param string $s A date or date and time, can be iso8601, rfc2822,
|
||||
* YYYY-MM-DD format.
|
||||
* @return \DateTime DateTime corresponding to the input string, in UTC time.
|
||||
*/
|
||||
public static function dateTime($s) {
|
||||
try {
|
||||
return new \DateTime($s, new \DateTimeZone('UTC'));
|
||||
} catch (\Exception $e) {
|
||||
return $s;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class ConfigurationException extends TwilioException {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class DeserializeException extends TwilioException {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class EnvironmentException extends TwilioException {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class HttpException extends TwilioException {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class RestException extends TwilioException {
|
||||
protected $statusCode;
|
||||
|
||||
/**
|
||||
* Construct the exception. Note: The message is NOT binary safe.
|
||||
* @link http://php.net/manual/en/exception.construct.php
|
||||
* @param string $message [optional] The Exception message to throw.
|
||||
* @param int $code [optional] The Exception code.
|
||||
* @param int $statusCode [optional] The HTTP Status code.
|
||||
* @since 5.1.0
|
||||
*/
|
||||
public function __construct($message, $code, $statusCode) {
|
||||
$this->statusCode = $statusCode;
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTTP Status Code of the RestException
|
||||
* @return int HTTP Status Code
|
||||
*/
|
||||
public function getStatusCode() {
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class TwilioException extends \Exception {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Exceptions;
|
||||
|
||||
|
||||
class TwimlException extends TwilioException {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Http;
|
||||
|
||||
|
||||
interface Client {
|
||||
public function request($method, $url, $params = array(), $data = array(),
|
||||
$headers = array(), $user = null, $password = null,
|
||||
$timeout = null);
|
||||
}
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Http;
|
||||
|
||||
|
||||
use Twilio\Exceptions\EnvironmentException;
|
||||
|
||||
class CurlClient implements Client {
|
||||
const DEFAULT_TIMEOUT = 60;
|
||||
protected $curlOptions = array();
|
||||
protected $debugHttp = false;
|
||||
|
||||
public $lastRequest = null;
|
||||
public $lastResponse = null;
|
||||
|
||||
public function __construct(array $options = array()) {
|
||||
$this->curlOptions = $options;
|
||||
$this->debugHttp = getenv('DEBUG_HTTP_TRAFFIC') === 'true';
|
||||
}
|
||||
|
||||
public function request($method, $url, $params = array(), $data = array(),
|
||||
$headers = array(), $user = null, $password = null,
|
||||
$timeout = null) {
|
||||
$options = $this->options($method, $url, $params, $data, $headers,
|
||||
$user, $password, $timeout);
|
||||
|
||||
$this->lastRequest = $options;
|
||||
$this->lastResponse = null;
|
||||
|
||||
try {
|
||||
if (!$curl = curl_init()) {
|
||||
throw new EnvironmentException('Unable to initialize cURL');
|
||||
}
|
||||
|
||||
if (!curl_setopt_array($curl, $options)) {
|
||||
throw new EnvironmentException(curl_error($curl));
|
||||
}
|
||||
|
||||
if (!$response = curl_exec($curl)) {
|
||||
throw new EnvironmentException(curl_error($curl));
|
||||
}
|
||||
|
||||
$parts = explode("\r\n\r\n", $response, 3);
|
||||
list($head, $body) = ($parts[0] == 'HTTP/1.1 100 Continue')
|
||||
? array($parts[1], $parts[2])
|
||||
: array($parts[0], $parts[1]);
|
||||
|
||||
if ($this->debugHttp) {
|
||||
$u = parse_url($url);
|
||||
$hdrLine = $method . ' ' . $u['path'];
|
||||
if (isset($u['query']) && strlen($u['query']) > 0 ) {
|
||||
$hdrLine = $hdrLine . '?' . $u['query'];
|
||||
}
|
||||
error_log($hdrLine);
|
||||
foreach ($headers as $key => $value) {
|
||||
error_log("$key: $value");
|
||||
}
|
||||
if ($method === 'POST') {
|
||||
error_log("\n" . $options[CURLOPT_POSTFIELDS] . "\n");
|
||||
}
|
||||
}
|
||||
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
$responseHeaders = array();
|
||||
$headerLines = explode("\r\n", $head);
|
||||
array_shift($headerLines);
|
||||
foreach ($headerLines as $line) {
|
||||
list($key, $value) = explode(':', $line, 2);
|
||||
$responseHeaders[$key] = $value;
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
if (isset($buffer) && is_resource($buffer)) {
|
||||
fclose($buffer);
|
||||
}
|
||||
|
||||
if ($this->debugHttp) {
|
||||
error_log("HTTP/1.1 $statusCode");
|
||||
foreach ($responseHeaders as $key => $value) {
|
||||
error_log("$key: $value");
|
||||
}
|
||||
error_log("\n$body");
|
||||
}
|
||||
|
||||
$this->lastResponse = new Response($statusCode, $body, $responseHeaders);
|
||||
|
||||
return $this->lastResponse;
|
||||
} catch (\ErrorException $e) {
|
||||
if (isset($curl) && is_resource($curl)) {
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
if (isset($buffer) && is_resource($buffer)) {
|
||||
fclose($buffer);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function options($method, $url, $params = array(), $data = array(),
|
||||
$headers = array(), $user = null, $password = null,
|
||||
$timeout = null) {
|
||||
|
||||
$timeout = is_null($timeout)
|
||||
? self::DEFAULT_TIMEOUT
|
||||
: $timeout;
|
||||
$options = $this->curlOptions + array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_HEADER => true,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_INFILESIZE => Null,
|
||||
CURLOPT_HTTPHEADER => array(),
|
||||
CURLOPT_TIMEOUT => $timeout,
|
||||
);
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$options[CURLOPT_HTTPHEADER][] = "$key: $value";
|
||||
}
|
||||
|
||||
if ($user && $password) {
|
||||
$options[CURLOPT_HTTPHEADER][] = 'Authorization: Basic ' . base64_encode("$user:$password");
|
||||
}
|
||||
|
||||
$body = $this->buildQuery($params);
|
||||
if ($body) {
|
||||
$options[CURLOPT_URL] .= '?' . $body;
|
||||
}
|
||||
|
||||
switch (strtolower(trim($method))) {
|
||||
case 'get':
|
||||
$options[CURLOPT_HTTPGET] = true;
|
||||
break;
|
||||
case 'post':
|
||||
$options[CURLOPT_POST] = true;
|
||||
$options[CURLOPT_POSTFIELDS] = $this->buildQuery($data);
|
||||
|
||||
break;
|
||||
case 'put':
|
||||
$options[CURLOPT_PUT] = true;
|
||||
if ($data) {
|
||||
if ($buffer = fopen('php://memory', 'w+')) {
|
||||
$dataString = $this->buildQuery($data);
|
||||
fwrite($buffer, $dataString);
|
||||
fseek($buffer, 0);
|
||||
$options[CURLOPT_INFILE] = $buffer;
|
||||
$options[CURLOPT_INFILESIZE] = strlen($dataString);
|
||||
} else {
|
||||
throw new EnvironmentException('Unable to open a temporary file');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'head':
|
||||
$options[CURLOPT_NOBODY] = true;
|
||||
break;
|
||||
default:
|
||||
$options[CURLOPT_CUSTOMREQUEST] = strtoupper($method);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function buildQuery($params) {
|
||||
$parts = array();
|
||||
|
||||
if (is_string($params)) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
$params = $params ?: array();
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $item) {
|
||||
$parts[] = urlencode((string)$key) . '=' . urlencode((string)$item);
|
||||
}
|
||||
} else {
|
||||
$parts[] = urlencode((string)$key) . '=' . urlencode((string)$value);
|
||||
}
|
||||
}
|
||||
|
||||
return implode('&', $parts);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Http;
|
||||
|
||||
|
||||
class Response {
|
||||
protected $headers;
|
||||
protected $content;
|
||||
protected $statusCode;
|
||||
|
||||
public function __construct($statusCode, $content, $headers = array()) {
|
||||
$this->statusCode = $statusCode;
|
||||
$this->content = $content;
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getContent() {
|
||||
return json_decode($this->content, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getStatusCode() {
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
public function getHeaders() {
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function ok() {
|
||||
return $this->getStatusCode() < 400;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return '[Response] HTTP ' . $this->getStatusCode() . ' ' . $this->content;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio;
|
||||
|
||||
|
||||
class InstanceContext {
|
||||
protected $version;
|
||||
protected $solution = array();
|
||||
protected $uri;
|
||||
|
||||
public function __construct(Version $version) {
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return '[InstanceContext]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio;
|
||||
|
||||
|
||||
class InstanceResource {
|
||||
protected $version;
|
||||
protected $context = null;
|
||||
protected $properties = array();
|
||||
protected $solution = array();
|
||||
|
||||
public function __construct(Version $version) {
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return '[InstanceResource]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
namespace Twilio\Jwt;
|
||||
|
||||
|
||||
use Twilio\Jwt\Grants\Grant;
|
||||
|
||||
class AccessToken {
|
||||
private $signingKeySid;
|
||||
private $accountSid;
|
||||
private $secret;
|
||||
private $ttl;
|
||||
private $identity;
|
||||
private $nbf;
|
||||
/** @var Grant[] $grants */
|
||||
private $grants;
|
||||
/** @var string[] $customClaims */
|
||||
private $customClaims;
|
||||
|
||||
public function __construct($accountSid, $signingKeySid, $secret, $ttl = 3600, $identity = null) {
|
||||
$this->signingKeySid = $signingKeySid;
|
||||
$this->accountSid = $accountSid;
|
||||
$this->secret = $secret;
|
||||
$this->ttl = $ttl;
|
||||
|
||||
if (!is_null($identity)) {
|
||||
$this->identity = $identity;
|
||||
}
|
||||
|
||||
$this->grants = array();
|
||||
$this->customClaims = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the identity of this access token
|
||||
*
|
||||
* @param string $identity identity of the grant
|
||||
*
|
||||
* @return $this updated access token
|
||||
*/
|
||||
public function setIdentity($identity) {
|
||||
$this->identity = $identity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identity of the grant
|
||||
*
|
||||
* @return string the identity
|
||||
*/
|
||||
public function getIdentity() {
|
||||
return $this->identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nbf of this access token
|
||||
*
|
||||
* @param integer $nbf nbf in epoch seconds of the grant
|
||||
*
|
||||
* @return $this updated access token
|
||||
*/
|
||||
public function setNbf($nbf) {
|
||||
$this->nbf = $nbf;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nbf of the grant
|
||||
*
|
||||
* @return integer the nbf in epoch seconds
|
||||
*/
|
||||
public function getNbf() {
|
||||
return $this->nbf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a grant to the access token
|
||||
*
|
||||
* @param Grant $grant to be added
|
||||
*
|
||||
* @return $this the updated access token
|
||||
*/
|
||||
public function addGrant(Grant $grant) {
|
||||
$this->grants[] = $grant;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to set custom claims, which then will be encoded into JWT payload.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addClaim($name, $value) {
|
||||
$this->customClaims[$name] = $value;
|
||||
}
|
||||
|
||||
public function toJWT($algorithm = 'HS256') {
|
||||
$header = array(
|
||||
'cty' => 'twilio-fpa;v=1',
|
||||
'typ' => 'JWT'
|
||||
);
|
||||
|
||||
$now = time();
|
||||
|
||||
$grants = array();
|
||||
if ($this->identity) {
|
||||
$grants['identity'] = $this->identity;
|
||||
}
|
||||
|
||||
foreach ($this->grants as $grant) {
|
||||
$payload = $grant->getPayload();
|
||||
if (empty($payload)) {
|
||||
$payload = json_decode('{}');
|
||||
}
|
||||
|
||||
$grants[$grant->getGrantKey()] = $payload;
|
||||
}
|
||||
|
||||
if (empty($grants)) {
|
||||
$grants = json_decode('{}');
|
||||
}
|
||||
|
||||
$payload = array_merge($this->customClaims, array(
|
||||
'jti' => $this->signingKeySid . '-' . $now,
|
||||
'iss' => $this->signingKeySid,
|
||||
'sub' => $this->accountSid,
|
||||
'exp' => $now + $this->ttl,
|
||||
'grants' => $grants
|
||||
));
|
||||
|
||||
if (!is_null($this->nbf)) {
|
||||
$payload['nbf'] = $this->nbf;
|
||||
}
|
||||
|
||||
return JWT::encode($payload, $this->secret, $algorithm, $header);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->toJWT();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Client;
|
||||
|
||||
|
||||
/**
|
||||
* Scope URI implementation
|
||||
*
|
||||
* Simple way to represent configurable privileges in an OAuth
|
||||
* friendly way. For our case, they look like this:
|
||||
*
|
||||
* scope:<service>:<privilege>?<params>
|
||||
*
|
||||
* For example:
|
||||
* scope:client:incoming?name=jonas
|
||||
*/
|
||||
class ScopeURI {
|
||||
public $service;
|
||||
public $privilege;
|
||||
public $params;
|
||||
|
||||
public function __construct($service, $privilege, $params = array()) {
|
||||
$this->service = $service;
|
||||
$this->privilege = $privilege;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function toString() {
|
||||
$uri = "scope:{$this->service}:{$this->privilege}";
|
||||
if (count($this->params)) {
|
||||
$uri .= "?" . http_build_query($this->params, '', '&');
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a scope URI into a ScopeURI object
|
||||
*
|
||||
* @param string $uri The scope URI
|
||||
* @return ScopeURI The parsed scope uri
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public static function parse($uri) {
|
||||
if (strpos($uri, 'scope:') !== 0) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Not a scope URI according to scheme');
|
||||
}
|
||||
|
||||
$parts = explode('?', $uri, 1);
|
||||
$params = null;
|
||||
|
||||
if (count($parts) > 1) {
|
||||
parse_str($parts[1], $params);
|
||||
}
|
||||
|
||||
$parts = explode(':', $parts[0], 2);
|
||||
|
||||
if (count($parts) != 3) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Not enough parts for scope URI');
|
||||
}
|
||||
|
||||
list($scheme, $service, $privilege) = $parts;
|
||||
return new ScopeURI($service, $privilege, $params);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt;
|
||||
|
||||
use Twilio\Jwt\Client\ScopeURI;
|
||||
|
||||
/**
|
||||
* Twilio Capability Token generator
|
||||
*/
|
||||
class ClientToken {
|
||||
public $accountSid;
|
||||
public $authToken;
|
||||
/** @var ScopeURI[] $scopes */
|
||||
public $scopes;
|
||||
/** @var string[] $customClaims */
|
||||
private $customClaims;
|
||||
|
||||
/**
|
||||
* Create a new TwilioCapability with zero permissions. Next steps are to
|
||||
* grant access to resources by configuring this token through the
|
||||
* functions allowXXXX.
|
||||
*
|
||||
* @param string $accountSid the account sid to which this token is granted
|
||||
* access
|
||||
* @param string $authToken the secret key used to sign the token. Note,
|
||||
* this auth token is not visible to the user of the token.
|
||||
*/
|
||||
public function __construct($accountSid, $authToken) {
|
||||
$this->accountSid = $accountSid;
|
||||
$this->authToken = $authToken;
|
||||
$this->scopes = array();
|
||||
$this->clientName = false;
|
||||
$this->customClaims = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* If the user of this token should be allowed to accept incoming
|
||||
* connections then configure the TwilioCapability through this method and
|
||||
* specify the client name.
|
||||
*
|
||||
* @param $clientName
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function allowClientIncoming($clientName) {
|
||||
|
||||
// clientName must be a non-zero length alphanumeric string
|
||||
if (preg_match('/\W/', $clientName)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Only alphanumeric characters allowed in client name.');
|
||||
}
|
||||
|
||||
if (strlen($clientName) == 0) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Client name must not be a zero length string.');
|
||||
}
|
||||
|
||||
$this->clientName = $clientName;
|
||||
$this->allow('client', 'incoming',
|
||||
array('clientName' => $clientName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the user of this token to make outgoing connections.
|
||||
*
|
||||
* @param string $appSid the application to which this token grants access
|
||||
* @param mixed[] $appParams signed parameters that the user of this token
|
||||
* cannot overwrite.
|
||||
*/
|
||||
public function allowClientOutgoing($appSid, array $appParams = array()) {
|
||||
$this->allow('client', 'outgoing', array(
|
||||
'appSid' => $appSid,
|
||||
'appParams' => http_build_query($appParams, '', '&')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the user of this token to access their event stream.
|
||||
*
|
||||
* @param mixed[] $filters key/value filters to apply to the event stream
|
||||
*/
|
||||
public function allowEventStream(array $filters = array()) {
|
||||
$this->allow('stream', 'subscribe', array(
|
||||
'path' => '/2010-04-01/Events',
|
||||
'params' => http_build_query($filters, '', '&'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to set custom claims, which then will be encoded into JWT payload.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
*/
|
||||
public function addClaim($name, $value) {
|
||||
$this->customClaims[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new token based on the credentials and permissions that
|
||||
* previously has been granted to this token.
|
||||
*
|
||||
* @param int $ttl the expiration time of the token (in seconds). Default
|
||||
* value is 3600 (1hr)
|
||||
* @return ClientToken the newly generated token that is valid for $ttl
|
||||
* seconds
|
||||
*/
|
||||
public function generateToken($ttl = 3600) {
|
||||
$payload = array_merge($this->customClaims, array(
|
||||
'scope' => array(),
|
||||
'iss' => $this->accountSid,
|
||||
'exp' => time() + $ttl,
|
||||
));
|
||||
$scopeStrings = array();
|
||||
|
||||
foreach ($this->scopes as $scope) {
|
||||
if ($scope->privilege == "outgoing" && $this->clientName)
|
||||
$scope->params["clientName"] = $this->clientName;
|
||||
$scopeStrings[] = $scope->toString();
|
||||
}
|
||||
|
||||
$payload['scope'] = implode(' ', $scopeStrings);
|
||||
return JWT::encode($payload, $this->authToken, 'HS256');
|
||||
}
|
||||
|
||||
protected function allow($service, $privilege, $params) {
|
||||
$this->scopes[] = new ScopeURI($service, $privilege, $params);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
|
||||
class ChatGrant implements Grant {
|
||||
private $serviceSid;
|
||||
private $endpointId;
|
||||
private $deploymentRoleSid;
|
||||
private $pushCredentialSid;
|
||||
|
||||
/**
|
||||
* Returns the service sid
|
||||
*
|
||||
* @return string the service sid
|
||||
*/
|
||||
public function getServiceSid() {
|
||||
return $this->serviceSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service sid of this grant
|
||||
*
|
||||
* @param string $serviceSid service sid of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setServiceSid($serviceSid) {
|
||||
$this->serviceSid = $serviceSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint id of the grant
|
||||
*
|
||||
* @return string the endpoint id
|
||||
*/
|
||||
public function getEndpointId() {
|
||||
return $this->endpointId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the endpoint id of the grant
|
||||
*
|
||||
* @param string $endpointId endpoint id of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setEndpointId($endpointId) {
|
||||
$this->endpointId = $endpointId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deployment role sid of the grant
|
||||
*
|
||||
* @return string the deployment role sid
|
||||
*/
|
||||
public function getDeploymentRoleSid() {
|
||||
return $this->deploymentRoleSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the role sid of the grant
|
||||
*
|
||||
* @param string $deploymentRoleSid role sid of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setDeploymentRoleSid($deploymentRoleSid) {
|
||||
$this->deploymentRoleSid = $deploymentRoleSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the push credential sid of the grant
|
||||
*
|
||||
* @return string the push credential sid
|
||||
*/
|
||||
public function getPushCredentialSid() {
|
||||
return $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the credential sid of the grant
|
||||
*
|
||||
* @param string $pushCredentialSid push credential sid of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setPushCredentialSid($pushCredentialSid) {
|
||||
$this->pushCredentialSid = $pushCredentialSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey() {
|
||||
return "chat";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload() {
|
||||
$payload = array();
|
||||
if ($this->serviceSid) {
|
||||
$payload['service_sid'] = $this->serviceSid;
|
||||
}
|
||||
if ($this->endpointId) {
|
||||
$payload['endpoint_id'] = $this->endpointId;
|
||||
}
|
||||
if ($this->deploymentRoleSid) {
|
||||
$payload['deployment_role_sid'] = $this->deploymentRoleSid;
|
||||
}
|
||||
if ($this->pushCredentialSid) {
|
||||
$payload['push_credential_sid'] = $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
|
||||
class ConversationsGrant implements Grant {
|
||||
private $configurationProfileSid;
|
||||
|
||||
public function __construct() {
|
||||
trigger_error("ConversationsGrant is deprecated, please use VideoGrant", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration profile sid
|
||||
*
|
||||
* @return string the configuration profile sid
|
||||
*/
|
||||
public function getConfigurationProfileSid() {
|
||||
return $this->configurationProfileSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $configurationProfileSid the configuration profile sid
|
||||
* we want to enable for this grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setConfigurationProfileSid($configurationProfileSid) {
|
||||
$this->configurationProfileSid = $configurationProfileSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey() {
|
||||
return "rtc";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload() {
|
||||
$payload = array();
|
||||
if ($this->configurationProfileSid) {
|
||||
$payload['configuration_profile_sid'] = $this->configurationProfileSid;
|
||||
}
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
|
||||
interface Grant {
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey();
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload();
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
|
||||
class IpMessagingGrant implements Grant {
|
||||
private $serviceSid;
|
||||
private $endpointId;
|
||||
private $deploymentRoleSid;
|
||||
private $pushCredentialSid;
|
||||
|
||||
public function __construct() {
|
||||
trigger_error("IpMessagingGrant is deprecated, please use ChatGrant", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the service sid
|
||||
*
|
||||
* @return string the service sid
|
||||
*/
|
||||
public function getServiceSid() {
|
||||
return $this->serviceSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service sid of this grant
|
||||
*
|
||||
* @param string $serviceSid service sid of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setServiceSid($serviceSid) {
|
||||
$this->serviceSid = $serviceSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint id of the grant
|
||||
*
|
||||
* @return string the endpoint id
|
||||
*/
|
||||
public function getEndpointId() {
|
||||
return $this->endpointId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the endpoint id of the grant
|
||||
*
|
||||
* @param string $endpointId endpoint id of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setEndpointId($endpointId) {
|
||||
$this->endpointId = $endpointId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deployment role sid of the grant
|
||||
*
|
||||
* @return string the deployment role sid
|
||||
*/
|
||||
public function getDeploymentRoleSid() {
|
||||
return $this->deploymentRoleSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the role sid of the grant
|
||||
*
|
||||
* @param string $deploymentRoleSid role sid of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setDeploymentRoleSid($deploymentRoleSid) {
|
||||
$this->deploymentRoleSid = $deploymentRoleSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the push credential sid of the grant
|
||||
*
|
||||
* @return string the push credential sid
|
||||
*/
|
||||
public function getPushCredentialSid() {
|
||||
return $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the credential sid of the grant
|
||||
*
|
||||
* @param string $pushCredentialSid push credential sid of the grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setPushCredentialSid($pushCredentialSid) {
|
||||
$this->pushCredentialSid = $pushCredentialSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey() {
|
||||
return "ip_messaging";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload() {
|
||||
$payload = array();
|
||||
if ($this->serviceSid) {
|
||||
$payload['service_sid'] = $this->serviceSid;
|
||||
}
|
||||
if ($this->endpointId) {
|
||||
$payload['endpoint_id'] = $this->endpointId;
|
||||
}
|
||||
if ($this->deploymentRoleSid) {
|
||||
$payload['deployment_role_sid'] = $this->deploymentRoleSid;
|
||||
}
|
||||
if ($this->pushCredentialSid) {
|
||||
$payload['push_credential_sid'] = $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
class SyncGrant implements Grant
|
||||
{
|
||||
private $serviceSid;
|
||||
private $endpointId;
|
||||
private $deploymentRoleSid;
|
||||
private $pushCredentialSid;
|
||||
|
||||
/**
|
||||
* Returns the service sid
|
||||
*
|
||||
* @return string the service sid
|
||||
*/
|
||||
public function getServiceSid()
|
||||
{
|
||||
return $this->serviceSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service sid of this grant
|
||||
*
|
||||
* @param string $serviceSid service sid of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_SyncGrant updated grant
|
||||
*/
|
||||
public function setServiceSid($serviceSid)
|
||||
{
|
||||
$this->serviceSid = $serviceSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint id of the grant
|
||||
*
|
||||
* @return string the endpoint id
|
||||
*/
|
||||
public function getEndpointId()
|
||||
{
|
||||
return $this->endpointId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the endpoint id of the grant
|
||||
*
|
||||
* @param string $endpointId endpoint id of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_SyncGrant updated grant
|
||||
*/
|
||||
public function setEndpointId($endpointId)
|
||||
{
|
||||
$this->endpointId = $endpointId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deployment role sid of the grant
|
||||
*
|
||||
* @return string the deployment role sid
|
||||
*/
|
||||
public function getDeploymentRoleSid()
|
||||
{
|
||||
return $this->deploymentRoleSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the role sid of the grant
|
||||
*
|
||||
* @param string $deploymentRoleSid role sid of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_SyncGrant updated grant
|
||||
*/
|
||||
public function setDeploymentRoleSid($deploymentRoleSid)
|
||||
{
|
||||
$this->deploymentRoleSid = $deploymentRoleSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the push credential sid of the grant
|
||||
*
|
||||
* @return string the push credential sid
|
||||
*/
|
||||
public function getPushCredentialSid()
|
||||
{
|
||||
return $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the credential sid of the grant
|
||||
*
|
||||
* @param string $pushCredentialSid push credential sid of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_SyncGrant updated grant
|
||||
*/
|
||||
public function setPushCredentialSid($pushCredentialSid)
|
||||
{
|
||||
$this->pushCredentialSid = $pushCredentialSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey()
|
||||
{
|
||||
return "data_sync";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload()
|
||||
{
|
||||
$payload = array();
|
||||
if ($this->serviceSid) {
|
||||
$payload['service_sid'] = $this->serviceSid;
|
||||
}
|
||||
if ($this->endpointId) {
|
||||
$payload['endpoint_id'] = $this->endpointId;
|
||||
}
|
||||
if ($this->deploymentRoleSid) {
|
||||
$payload['deployment_role_sid'] = $this->deploymentRoleSid;
|
||||
}
|
||||
if ($this->pushCredentialSid) {
|
||||
$payload['push_credential_sid'] = $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
class TaskRouterGrant implements Grant {
|
||||
private $workspaceSid;
|
||||
private $workerSid;
|
||||
private $role;
|
||||
|
||||
/**
|
||||
* Returns the workspace sid
|
||||
*
|
||||
* @return string the workspace sid
|
||||
*/
|
||||
public function getWorkspaceSid()
|
||||
{
|
||||
return $this->workspaceSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the workspace sid of this grant
|
||||
*
|
||||
* @param string $workspaceSid workspace sid of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_TaskRouterGrant updated grant
|
||||
*/
|
||||
public function setWorkspaceSid($workspaceSid)
|
||||
{
|
||||
$this->workspaceSid = $workspaceSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the worker sid
|
||||
*
|
||||
* @return string the worker sid
|
||||
*/
|
||||
public function getWorkerSid()
|
||||
{
|
||||
return $this->workerSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the worker sid of this grant
|
||||
*
|
||||
* @param string $worker worker sid of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_TaskRouterGrant updated grant
|
||||
*/
|
||||
public function setWorkerSid($workerSid)
|
||||
{
|
||||
$this->workerSid = $workerSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role
|
||||
*
|
||||
* @return string the role
|
||||
*/
|
||||
public function getRole()
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the role of this grant
|
||||
*
|
||||
* @param string $role role of the grant
|
||||
*
|
||||
* @return Services_Twilio_Auth_TaskRouterGrant updated grant
|
||||
*/
|
||||
public function setRole($role)
|
||||
{
|
||||
$this->role = $role;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey()
|
||||
{
|
||||
return "task_router";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload()
|
||||
{
|
||||
$payload = array();
|
||||
if ($this->workspaceSid) {
|
||||
$payload['workspace_sid'] = $this->workspaceSid;
|
||||
}
|
||||
if ($this->workerSid) {
|
||||
$payload['worker_sid'] = $this->workerSid;
|
||||
}
|
||||
if ($this->role) {
|
||||
$payload['role'] = $this->role;
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
|
||||
class VideoGrant implements Grant {
|
||||
|
||||
private $configurationProfileSid;
|
||||
private $room;
|
||||
|
||||
/**
|
||||
* Returns the configuration profile sid
|
||||
*
|
||||
* @return string the configuration profile sid
|
||||
*/
|
||||
public function getConfigurationProfileSid() {
|
||||
return $this->configurationProfileSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration profile sid of the grant
|
||||
* @deprecated in favor of setRoom/getRoom
|
||||
*
|
||||
* @param string $configurationProfileSid configuration profile sid of grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setConfigurationProfileSid($configurationProfileSid) {
|
||||
trigger_error('Configuration profile sid is deprecated, use room instead.', E_USER_NOTICE);
|
||||
$this->configurationProfileSid = $configurationProfileSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the room
|
||||
*
|
||||
* @return string room name or sid set in this grant
|
||||
*/
|
||||
public function getRoom() {
|
||||
return $this->room;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the room to allow access to in the grant
|
||||
*
|
||||
* @param string $roomSidOrName room sid or name
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setRoom($roomSidOrName) {
|
||||
$this->room = $roomSidOrName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey() {
|
||||
return "video";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload() {
|
||||
$payload = array();
|
||||
if ($this->configurationProfileSid) {
|
||||
$payload['configuration_profile_sid'] = $this->configurationProfileSid;
|
||||
}
|
||||
if ($this->room) {
|
||||
$payload['room'] = $this->room;
|
||||
}
|
||||
return $payload;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\Grants;
|
||||
|
||||
|
||||
class VoiceGrant implements Grant {
|
||||
|
||||
private $incomingAllow;
|
||||
private $outgoingApplicationSid;
|
||||
private $outgoingApplicationParams;
|
||||
private $pushCredentialSid;
|
||||
private $endpointId;
|
||||
|
||||
/**
|
||||
* Returns whether incoming is allowed
|
||||
*
|
||||
* @return boolean whether incoming is allowed
|
||||
*/
|
||||
public function getIncomingAllow()
|
||||
{
|
||||
return $this->incomingAllow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether incoming is allowed
|
||||
*
|
||||
* @param boolean $incomingAllow whether incoming is allowed
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setIncomingAllow($incomingAllow)
|
||||
{
|
||||
$this->incomingAllow = $incomingAllow;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the outgoing application sid
|
||||
*
|
||||
* @return string the outgoing application sid
|
||||
*/
|
||||
public function getOutgoingApplicationSid()
|
||||
{
|
||||
return $this->outgoingApplicationSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the outgoing application sid of the grant
|
||||
*
|
||||
* @param string $outgoingApplicationSid outgoing application sid of grant
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setOutgoingApplicationSid($outgoingApplicationSid)
|
||||
{
|
||||
$this->outgoingApplicationSid = $outgoingApplicationSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the outgoing application params
|
||||
*
|
||||
* @return array the outgoing application params
|
||||
*/
|
||||
public function getOutgoingApplicationParams()
|
||||
{
|
||||
return $this->outgoingApplicationParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the outgoing application of the the grant
|
||||
*
|
||||
* @param string $sid outgoing application sid of the grant
|
||||
* @param string $params params to pass the the application
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setOutgoingApplication($sid, $params) {
|
||||
$this->outgoingApplicationSid = $sid;
|
||||
$this->outgoingApplicationParams = $params;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the push credential sid
|
||||
*
|
||||
* @return string the push credential sid
|
||||
*/
|
||||
public function getPushCredentialSid()
|
||||
{
|
||||
return $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the push credential sid
|
||||
*
|
||||
* @param string $pushCredentialSid
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setPushCredentialSid($pushCredentialSid)
|
||||
{
|
||||
$this->pushCredentialSid = $pushCredentialSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the endpoint id
|
||||
*
|
||||
* @return string the endpoint id
|
||||
*/
|
||||
public function getEndpointId()
|
||||
{
|
||||
return $this->endpointId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the endpoint id
|
||||
*
|
||||
* @param string $endpointId endpoint id
|
||||
*
|
||||
* @return $this updated grant
|
||||
*/
|
||||
public function setEndpointId($endpointId)
|
||||
{
|
||||
$this->endpointId = $endpointId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant type
|
||||
*
|
||||
* @return string type of the grant
|
||||
*/
|
||||
public function getGrantKey()
|
||||
{
|
||||
return "voice";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grant data
|
||||
*
|
||||
* @return array data of the grant
|
||||
*/
|
||||
public function getPayload()
|
||||
{
|
||||
$payload = array();
|
||||
if ($this->incomingAllow == true) {
|
||||
$incoming = array();
|
||||
$incoming['allow'] = true;
|
||||
$payload['incoming'] = $incoming;
|
||||
}
|
||||
|
||||
if ($this->outgoingApplicationSid) {
|
||||
$outgoing = array();
|
||||
$outgoing['application_sid'] = $this->outgoingApplicationSid;
|
||||
|
||||
if ($this->outgoingApplicationParams) {
|
||||
$outgoing['params'] = $this->outgoingApplicationParams;
|
||||
}
|
||||
|
||||
$payload['outgoing'] = $outgoing;
|
||||
}
|
||||
|
||||
if ($this->pushCredentialSid) {
|
||||
$payload['push_credential_sid'] = $this->pushCredentialSid;
|
||||
}
|
||||
|
||||
if ($this->endpointId) {
|
||||
$payload['endpoint_id'] = $this->endpointId;
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
namespace Twilio\Jwt;
|
||||
|
||||
/**
|
||||
* JSON Web Token implementation
|
||||
*
|
||||
* Minimum implementation used by Realtime auth, based on this spec:
|
||||
* http://self-issued.info/docs/draft-jones-json-web-token-01.html.
|
||||
*
|
||||
* @author Neuman Vong <neuman@twilio.com>
|
||||
*/
|
||||
class JWT {
|
||||
/**
|
||||
* @param string $jwt The JWT
|
||||
* @param string|null $key The secret key
|
||||
* @param bool $verify Don't skip verification process
|
||||
* @return object The JWT's payload as a PHP object
|
||||
* @throws \DomainException
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public static function decode($jwt, $key = null, $verify = true) {
|
||||
$tks = explode('.', $jwt);
|
||||
if (count($tks) != 3) {
|
||||
throw new \UnexpectedValueException('Wrong number of segments');
|
||||
}
|
||||
list($headb64, $payloadb64, $cryptob64) = $tks;
|
||||
if (null === ($header = self::jsonDecode(self::urlsafeB64Decode($headb64)))
|
||||
) {
|
||||
throw new \UnexpectedValueException('Invalid segment encoding');
|
||||
}
|
||||
if (null === $payload = self::jsonDecode(self::urlsafeB64Decode($payloadb64))
|
||||
) {
|
||||
throw new \UnexpectedValueException('Invalid segment encoding');
|
||||
}
|
||||
$sig = self::urlsafeB64Decode($cryptob64);
|
||||
if ($verify) {
|
||||
if (empty($header->alg)) {
|
||||
throw new \DomainException('Empty algorithm');
|
||||
}
|
||||
if ($sig != self::sign("$headb64.$payloadb64", $key, $header->alg)) {
|
||||
throw new \UnexpectedValueException('Signature verification failed');
|
||||
}
|
||||
}
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object|array $payload PHP object or array
|
||||
* @param string $key The secret key
|
||||
* @param string $algo The signing algorithm
|
||||
* @param array $additionalHeaders Additional keys/values to add to the header
|
||||
*
|
||||
* @return string A JWT
|
||||
*/
|
||||
public static function encode($payload, $key, $algo = 'HS256', $additionalHeaders = array()) {
|
||||
$header = array('typ' => 'JWT', 'alg' => $algo);
|
||||
$header = $header + $additionalHeaders;
|
||||
|
||||
$segments = array();
|
||||
$segments[] = self::urlsafeB64Encode(self::jsonEncode($header));
|
||||
$segments[] = self::urlsafeB64Encode(self::jsonEncode($payload));
|
||||
$signing_input = implode('.', $segments);
|
||||
|
||||
$signature = self::sign($signing_input, $key, $algo);
|
||||
$segments[] = self::urlsafeB64Encode($signature);
|
||||
|
||||
return implode('.', $segments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg The message to sign
|
||||
* @param string $key The secret key
|
||||
* @param string $method The signing algorithm
|
||||
* @return string An encrypted message
|
||||
* @throws \DomainException
|
||||
*/
|
||||
public static function sign($msg, $key, $method = 'HS256') {
|
||||
$methods = array(
|
||||
'HS256' => 'sha256',
|
||||
'HS384' => 'sha384',
|
||||
'HS512' => 'sha512',
|
||||
);
|
||||
if (empty($methods[$method])) {
|
||||
throw new \DomainException('Algorithm not supported');
|
||||
}
|
||||
return hash_hmac($methods[$method], $msg, $key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input JSON string
|
||||
* @return object Object representation of JSON string
|
||||
* @throws \DomainException
|
||||
*/
|
||||
public static function jsonDecode($input) {
|
||||
$obj = json_decode($input);
|
||||
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
||||
self::handleJsonError($errno);
|
||||
} else if ($obj === null && $input !== 'null') {
|
||||
throw new \DomainException('Null result with non-null input');
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object|array $input A PHP object or array
|
||||
* @return string JSON representation of the PHP object or array
|
||||
* @throws \DomainException
|
||||
*/
|
||||
public static function jsonEncode($input) {
|
||||
$json = json_encode($input);
|
||||
if (function_exists('json_last_error') && $errno = json_last_error()) {
|
||||
self::handleJsonError($errno);
|
||||
} else if ($json === 'null' && $input !== null) {
|
||||
throw new \DomainException('Null result with non-null input');
|
||||
}
|
||||
return $json;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input A base64 encoded string
|
||||
*
|
||||
* @return string A decoded string
|
||||
*/
|
||||
public static function urlsafeB64Decode($input) {
|
||||
$padlen = 4 - strlen($input) % 4;
|
||||
$input .= str_repeat('=', $padlen);
|
||||
return base64_decode(strtr($input, '-_', '+/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input Anything really
|
||||
*
|
||||
* @return string The base64 encode of what you passed in
|
||||
*/
|
||||
public static function urlsafeB64Encode($input) {
|
||||
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $errno An error number from json_last_error()
|
||||
*
|
||||
* @throws \DomainException
|
||||
*/
|
||||
private static function handleJsonError($errno) {
|
||||
$messages = array(
|
||||
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
|
||||
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
|
||||
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
|
||||
);
|
||||
throw new \DomainException(isset($messages[$errno])
|
||||
? $messages[$errno]
|
||||
: 'Unknown JSON error: ' . $errno
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\TaskRouter;
|
||||
use Twilio\Jwt\JWT;
|
||||
|
||||
|
||||
/**
|
||||
* Twilio TaskRouter Capability assigner
|
||||
*
|
||||
* @author Justin Witz <justin.witz@twilio.com>
|
||||
* @license http://creativecommons.org/licenses/MIT/ MIT
|
||||
*/
|
||||
class CapabilityToken {
|
||||
protected $accountSid;
|
||||
protected $authToken;
|
||||
private $friendlyName;
|
||||
/** @var Policy[] $policies */
|
||||
private $policies;
|
||||
|
||||
protected $baseUrl = 'https://taskrouter.twilio.com/v1';
|
||||
protected $baseWsUrl = 'https://event-bridge.twilio.com/v1/wschannels';
|
||||
protected $version = 'v1';
|
||||
|
||||
protected $workspaceSid;
|
||||
protected $channelId;
|
||||
protected $resourceUrl;
|
||||
|
||||
protected $required = array("required" => true);
|
||||
protected $optional = array("required" => false);
|
||||
|
||||
public function __construct($accountSid, $authToken, $workspaceSid, $channelId, $resourceUrl = null, $overrideBaseUrl = null, $overrideBaseWSUrl = null) {
|
||||
$this->accountSid = $accountSid;
|
||||
$this->authToken = $authToken;
|
||||
$this->friendlyName = $channelId;
|
||||
$this->policies = array();
|
||||
|
||||
$this->workspaceSid = $workspaceSid;
|
||||
$this->channelId = $channelId;
|
||||
if (isset($overrideBaseUrl)) {
|
||||
$this->baseUrl = $overrideBaseUrl;
|
||||
}
|
||||
if (isset($overrideBaseWSUrl)) {
|
||||
$this->baseWsUrl = $overrideBaseWSUrl;
|
||||
}
|
||||
$this->baseUrl = $this->baseUrl . '/Workspaces/' . $workspaceSid;
|
||||
|
||||
$this->validateJWT();
|
||||
|
||||
if (!isset($resourceUrl)) {
|
||||
$this->setupResource();
|
||||
}
|
||||
|
||||
//add permissions to GET and POST to the event-bridge channel
|
||||
$this->allow($this->baseWsUrl . "/" . $this->accountSid . "/" . $this->channelId, "GET", null, null);
|
||||
$this->allow($this->baseWsUrl . "/" . $this->accountSid . "/" . $this->channelId, "POST", null, null);
|
||||
|
||||
//add permissions to fetch the instance resource
|
||||
$this->allow($this->resourceUrl, "GET", null, null);
|
||||
}
|
||||
|
||||
protected function setupResource() {
|
||||
|
||||
}
|
||||
|
||||
public function addPolicyDeconstructed($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true) {
|
||||
$policy = new Policy($url, $method, $queryFilter, $postFilter, $allow);
|
||||
array_push($this->policies, $policy);
|
||||
return $policy;
|
||||
}
|
||||
|
||||
public function allow($url, $method, $queryFilter = array(), $postFilter = array()) {
|
||||
$this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, true);
|
||||
}
|
||||
|
||||
public function deny($url, $method, $queryFilter = array(), $postFilter = array()) {
|
||||
$this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, false);
|
||||
}
|
||||
|
||||
private function validateJWT() {
|
||||
if (!isset($this->accountSid) || substr($this->accountSid, 0, 2) != 'AC') {
|
||||
throw new \Exception("Invalid AccountSid provided: " . $this->accountSid);
|
||||
}
|
||||
if (!isset($this->workspaceSid) || substr($this->workspaceSid, 0, 2) != 'WS') {
|
||||
throw new \Exception("Invalid WorkspaceSid provided: " . $this->workspaceSid);
|
||||
}
|
||||
if (!isset($this->channelId)) {
|
||||
throw new \Exception("ChannelId not provided");
|
||||
}
|
||||
$prefix = substr($this->channelId, 0, 2);
|
||||
if ($prefix != 'WS' && $prefix != 'WK' && $prefix != 'WQ') {
|
||||
throw new \Exception("Invalid ChannelId provided: " . $this->channelId);
|
||||
}
|
||||
}
|
||||
|
||||
public function allowFetchSubresources() {
|
||||
$method = 'GET';
|
||||
$queryFilter = array();
|
||||
$postFilter = array();
|
||||
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function allowUpdates() {
|
||||
$method = 'POST';
|
||||
$queryFilter = array();
|
||||
$postFilter = array();
|
||||
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function allowUpdatesSubresources() {
|
||||
$method = 'POST';
|
||||
$queryFilter = array();
|
||||
$postFilter = array();
|
||||
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function allowDelete() {
|
||||
$method = 'DELETE';
|
||||
$queryFilter = array();
|
||||
$postFilter = array();
|
||||
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function allowDeleteSubresources() {
|
||||
$method = 'DELETE';
|
||||
$queryFilter = array();
|
||||
$postFilter = array();
|
||||
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function generateToken($ttl = 3600, $extraAttributes = array()) {
|
||||
$payload = array(
|
||||
'version' => $this->version,
|
||||
'friendly_name' => $this->friendlyName,
|
||||
'iss' => $this->accountSid,
|
||||
'exp' => time() + $ttl,
|
||||
'account_sid' => $this->accountSid,
|
||||
'channel' => $this->channelId,
|
||||
'workspace_sid' => $this->workspaceSid
|
||||
);
|
||||
|
||||
if (substr($this->channelId, 0, 2) == 'WK') {
|
||||
$payload['worker_sid'] = $this->channelId;
|
||||
} else if (substr($this->channelId, 0, 2) == 'WQ') {
|
||||
$payload['taskqueue_sid'] = $this->channelId;
|
||||
}
|
||||
|
||||
foreach ($extraAttributes as $key => $value) {
|
||||
$payload[$key] = $value;
|
||||
}
|
||||
|
||||
$policyStrings = array();
|
||||
foreach ($this->policies as $policy) {
|
||||
$policyStrings[] = $policy->toArray();
|
||||
}
|
||||
|
||||
$payload['policies'] = $policyStrings;
|
||||
return JWT::encode($payload, $this->authToken, 'HS256');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\TaskRouter;
|
||||
|
||||
|
||||
/**
|
||||
* Twilio API Policy constructor
|
||||
*
|
||||
* @author Justin Witz <justin.witz@twilio.com>
|
||||
* @license http://creativecommons.org/licenses/MIT/ MIT
|
||||
*/
|
||||
class Policy {
|
||||
private $url;
|
||||
private $method;
|
||||
private $queryFilter;
|
||||
private $postFilter;
|
||||
private $allow;
|
||||
|
||||
public function __construct($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true) {
|
||||
$this->url = $url;
|
||||
$this->method = $method;
|
||||
$this->queryFilter = $queryFilter;
|
||||
$this->postFilter = $postFilter;
|
||||
$this->allow = $allow;
|
||||
}
|
||||
|
||||
public function addQueryFilter($queryFilter) {
|
||||
array_push($this->queryFilter, $queryFilter);
|
||||
}
|
||||
|
||||
public function addPostFilter($postFilter) {
|
||||
array_push($this->postFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
$policy_array = array('url' => $this->url, 'method' => $this->method, 'allow' => $this->allow);
|
||||
if (!is_null($this->queryFilter)) {
|
||||
if (count($this->queryFilter) > 0) {
|
||||
$policy_array['query_filter'] = $this->queryFilter;
|
||||
} else {
|
||||
$policy_array['query_filter'] = new \stdClass();
|
||||
}
|
||||
}
|
||||
if (!is_null($this->postFilter)) {
|
||||
if (count($this->postFilter) > 0) {
|
||||
$policy_array['post_filter'] = $this->postFilter;
|
||||
} else {
|
||||
$policy_array['post_filter'] = new \stdClass();
|
||||
}
|
||||
}
|
||||
return $policy_array;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\TaskRouter;
|
||||
|
||||
/**
|
||||
* Twilio TaskRouter TaskQueue Capability assigner
|
||||
*
|
||||
* @author Justin Witz <justin.witz@twilio.com>
|
||||
* @license http://creativecommons.org/licenses/MIT/ MIT
|
||||
*/
|
||||
class TaskQueueCapability extends CapabilityToken {
|
||||
public function __construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null) {
|
||||
parent::__construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
|
||||
}
|
||||
|
||||
protected function setupResource() {
|
||||
$this->resourceUrl = $this->baseUrl . '/TaskQueues/' . $this->channelId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\TaskRouter;
|
||||
|
||||
/**
|
||||
* Twilio TaskRouter Worker Capability assigner
|
||||
*
|
||||
* @author Justin Witz <justin.witz@twilio.com>
|
||||
* @license http://creativecommons.org/licenses/MIT/ MIT
|
||||
*/
|
||||
class WorkerCapability extends CapabilityToken {
|
||||
private $tasksUrl;
|
||||
private $workerReservationsUrl;
|
||||
private $activityUrl;
|
||||
|
||||
public function __construct($accountSid, $authToken, $workspaceSid, $workerSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null) {
|
||||
parent::__construct($accountSid, $authToken, $workspaceSid, $workerSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
|
||||
|
||||
$this->tasksUrl = $this->baseUrl . '/Tasks/**';
|
||||
$this->activityUrl = $this->baseUrl . '/Activities';
|
||||
$this->workerReservationsUrl = $this->resourceUrl . '/Reservations/**';
|
||||
|
||||
//add permissions to fetch the list of activities, tasks, and worker reservations
|
||||
$this->allow($this->activityUrl, "GET", null, null);
|
||||
$this->allow($this->tasksUrl, "GET", null, null);
|
||||
$this->allow($this->workerReservationsUrl, "GET", null, null);
|
||||
}
|
||||
|
||||
protected function setupResource() {
|
||||
$this->resourceUrl = $this->baseUrl . '/Workers/' . $this->channelId;
|
||||
}
|
||||
|
||||
public function allowActivityUpdates() {
|
||||
$method = 'POST';
|
||||
$queryFilter = array();
|
||||
$postFilter = array("ActivitySid" => $this->required);
|
||||
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
|
||||
}
|
||||
|
||||
public function allowReservationUpdates() {
|
||||
$method = 'POST';
|
||||
$queryFilter = array();
|
||||
$postFilter = array();
|
||||
$this->allow($this->tasksUrl, $method, $queryFilter, $postFilter);
|
||||
$this->allow($this->workerReservationsUrl, $method, $queryFilter, $postFilter);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio\Jwt\TaskRouter;
|
||||
|
||||
|
||||
class WorkspaceCapability extends CapabilityToken {
|
||||
public function __construct($accountSid, $authToken, $workspaceSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null) {
|
||||
parent::__construct($accountSid, $authToken, $workspaceSid, $workspaceSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
|
||||
}
|
||||
|
||||
protected function setupResource() {
|
||||
$this->resourceUrl = $this->baseUrl;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Twilio;
|
||||
|
||||
|
||||
abstract class Options implements \IteratorAggregate {
|
||||
protected $options = array();
|
||||
|
||||
public function getIterator() {
|
||||
return new \ArrayIterator($this->options);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,449 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Api\V2010;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Api\V2010 v2010
|
||||
* @property \Twilio\Rest\Api\V2010\AccountList accounts
|
||||
* @property \Twilio\Rest\Api\V2010\AccountContext account
|
||||
* @property \Twilio\Rest\Api\V2010\Account\AddressList addresses
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ApplicationList applications
|
||||
* @property \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList authorizedConnectApps
|
||||
* @property \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList availablePhoneNumbers
|
||||
* @property \Twilio\Rest\Api\V2010\Account\CallList calls
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ConferenceList conferences
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ConnectAppList connectApps
|
||||
* @property \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList incomingPhoneNumbers
|
||||
* @property \Twilio\Rest\Api\V2010\Account\KeyList keys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\MessageList messages
|
||||
* @property \Twilio\Rest\Api\V2010\Account\NewKeyList newKeys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\NewSigningKeyList newSigningKeys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\NotificationList notifications
|
||||
* @property \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList outgoingCallerIds
|
||||
* @property \Twilio\Rest\Api\V2010\Account\QueueList queues
|
||||
* @property \Twilio\Rest\Api\V2010\Account\RecordingList recordings
|
||||
* @property \Twilio\Rest\Api\V2010\Account\SigningKeyList signingKeys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\SipList sip
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ShortCodeList shortCodes
|
||||
* @property \Twilio\Rest\Api\V2010\Account\TokenList tokens
|
||||
* @property \Twilio\Rest\Api\V2010\Account\TranscriptionList transcriptions
|
||||
* @property \Twilio\Rest\Api\V2010\Account\UsageList usage
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ValidationRequestList validationRequests
|
||||
* @method \Twilio\Rest\Api\V2010\Account\AddressContext addresses(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ApplicationContext applications(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext authorizedConnectApps(string $connectAppSid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext availablePhoneNumbers(string $countryCode)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\CallContext calls(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ConferenceContext conferences(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ConnectAppContext connectApps(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext incomingPhoneNumbers(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\KeyContext keys(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\MessageContext messages(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\NotificationContext notifications(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext outgoingCallerIds(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\QueueContext queues(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\RecordingContext recordings(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\SigningKeyContext signingKeys(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ShortCodeContext shortCodes(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\TranscriptionContext transcriptions(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\AccountContext accounts(string $sid)
|
||||
*/
|
||||
class Api extends Domain {
|
||||
protected $_v2010 = null;
|
||||
|
||||
/**
|
||||
* Construct the Api Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Api Domain for Api
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://api.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010 Version v2010 of api
|
||||
*/
|
||||
protected function getV2010() {
|
||||
if (!$this->_v2010) {
|
||||
$this->_v2010 = new V2010($this);
|
||||
}
|
||||
return $this->_v2010;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\AccountContext Account provided as the
|
||||
* authenticating account
|
||||
*/
|
||||
protected function getAccount() {
|
||||
return $this->v2010->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\AccountList
|
||||
*/
|
||||
protected function getAccounts() {
|
||||
return $this->v2010->accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique Account Sid
|
||||
* @return \Twilio\Rest\Api\V2010\AccountContext
|
||||
*/
|
||||
protected function contextAccounts($sid) {
|
||||
return $this->v2010->accounts($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AddressList
|
||||
*/
|
||||
protected function getAddresses() {
|
||||
return $this->v2010->account->addresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AddressContext
|
||||
*/
|
||||
protected function contextAddresses($sid) {
|
||||
return $this->v2010->account->addresses($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ApplicationList
|
||||
*/
|
||||
protected function getApplications() {
|
||||
return $this->v2010->account->applications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique Application Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ApplicationContext
|
||||
*/
|
||||
protected function contextApplications($sid) {
|
||||
return $this->v2010->account->applications($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList
|
||||
*/
|
||||
protected function getAuthorizedConnectApps() {
|
||||
return $this->v2010->account->authorizedConnectApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectAppSid The connect_app_sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext
|
||||
*/
|
||||
protected function contextAuthorizedConnectApps($connectAppSid) {
|
||||
return $this->v2010->account->authorizedConnectApps($connectAppSid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList
|
||||
*/
|
||||
protected function getAvailablePhoneNumbers() {
|
||||
return $this->v2010->account->availablePhoneNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $countryCode The country_code
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext
|
||||
*/
|
||||
protected function contextAvailablePhoneNumbers($countryCode) {
|
||||
return $this->v2010->account->availablePhoneNumbers($countryCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\CallList
|
||||
*/
|
||||
protected function getCalls() {
|
||||
return $this->v2010->account->calls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Call Sid that uniquely identifies the Call to fetch
|
||||
* @return \Twilio\Rest\Api\V2010\Account\CallContext
|
||||
*/
|
||||
protected function contextCalls($sid) {
|
||||
return $this->v2010->account->calls($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConferenceList
|
||||
*/
|
||||
protected function getConferences() {
|
||||
return $this->v2010->account->conferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique conference Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConferenceContext
|
||||
*/
|
||||
protected function contextConferences($sid) {
|
||||
return $this->v2010->account->conferences($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConnectAppList
|
||||
*/
|
||||
protected function getConnectApps() {
|
||||
return $this->v2010->account->connectApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique connect-app Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConnectAppContext
|
||||
*/
|
||||
protected function contextConnectApps($sid) {
|
||||
return $this->v2010->account->connectApps($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList
|
||||
*/
|
||||
protected function getIncomingPhoneNumbers() {
|
||||
return $this->v2010->account->incomingPhoneNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique incoming-phone-number Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext
|
||||
*/
|
||||
protected function contextIncomingPhoneNumbers($sid) {
|
||||
return $this->v2010->account->incomingPhoneNumbers($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\KeyList
|
||||
*/
|
||||
protected function getKeys() {
|
||||
return $this->v2010->account->keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\KeyContext
|
||||
*/
|
||||
protected function contextKeys($sid) {
|
||||
return $this->v2010->account->keys($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\MessageList
|
||||
*/
|
||||
protected function getMessages() {
|
||||
return $this->v2010->account->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique message Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\MessageContext
|
||||
*/
|
||||
protected function contextMessages($sid) {
|
||||
return $this->v2010->account->messages($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NewKeyList
|
||||
*/
|
||||
protected function getNewKeys() {
|
||||
return $this->v2010->account->newKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NewSigningKeyList
|
||||
*/
|
||||
protected function getNewSigningKeys() {
|
||||
return $this->v2010->account->newSigningKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NotificationList
|
||||
*/
|
||||
protected function getNotifications() {
|
||||
return $this->v2010->account->notifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique notification Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NotificationContext
|
||||
*/
|
||||
protected function contextNotifications($sid) {
|
||||
return $this->v2010->account->notifications($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList
|
||||
*/
|
||||
protected function getOutgoingCallerIds() {
|
||||
return $this->v2010->account->outgoingCallerIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique outgoing-caller-id Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext
|
||||
*/
|
||||
protected function contextOutgoingCallerIds($sid) {
|
||||
return $this->v2010->account->outgoingCallerIds($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\QueueList
|
||||
*/
|
||||
protected function getQueues() {
|
||||
return $this->v2010->account->queues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique queue Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\QueueContext
|
||||
*/
|
||||
protected function contextQueues($sid) {
|
||||
return $this->v2010->account->queues($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\RecordingList
|
||||
*/
|
||||
protected function getRecordings() {
|
||||
return $this->v2010->account->recordings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique recording SID
|
||||
* @return \Twilio\Rest\Api\V2010\Account\RecordingContext
|
||||
*/
|
||||
protected function contextRecordings($sid) {
|
||||
return $this->v2010->account->recordings($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\SigningKeyList
|
||||
*/
|
||||
protected function getSigningKeys() {
|
||||
return $this->v2010->account->signingKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\SigningKeyContext
|
||||
*/
|
||||
protected function contextSigningKeys($sid) {
|
||||
return $this->v2010->account->signingKeys($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\SipList
|
||||
*/
|
||||
protected function getSip() {
|
||||
return $this->v2010->account->sip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ShortCodeList
|
||||
*/
|
||||
protected function getShortCodes() {
|
||||
return $this->v2010->account->shortCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique short-code Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ShortCodeContext
|
||||
*/
|
||||
protected function contextShortCodes($sid) {
|
||||
return $this->v2010->account->shortCodes($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\TokenList
|
||||
*/
|
||||
protected function getTokens() {
|
||||
return $this->v2010->account->tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\TranscriptionList
|
||||
*/
|
||||
protected function getTranscriptions() {
|
||||
return $this->v2010->account->transcriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique transcription SID
|
||||
* @return \Twilio\Rest\Api\V2010\Account\TranscriptionContext
|
||||
*/
|
||||
protected function contextTranscriptions($sid) {
|
||||
return $this->v2010->account->transcriptions($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\UsageList
|
||||
*/
|
||||
protected function getUsage() {
|
||||
return $this->v2010->account->usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ValidationRequestList
|
||||
*/
|
||||
protected function getValidationRequests() {
|
||||
return $this->v2010->account->validationRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Api]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Chat\V1;
|
||||
use Twilio\Rest\Chat\V2;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Chat\V1 v1
|
||||
* @property \Twilio\Rest\Chat\V2 v2
|
||||
* @property \Twilio\Rest\Chat\V2\CredentialList credentials
|
||||
* @property \Twilio\Rest\Chat\V2\ServiceList services
|
||||
* @method \Twilio\Rest\Chat\V2\CredentialContext credentials(string $sid)
|
||||
* @method \Twilio\Rest\Chat\V2\ServiceContext services(string $sid)
|
||||
*/
|
||||
class Chat extends Domain {
|
||||
protected $_v1 = null;
|
||||
protected $_v2 = null;
|
||||
|
||||
/**
|
||||
* Construct the Chat Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Chat Domain for Chat
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://chat.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Chat\V1 Version v1 of chat
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Chat\V2 Version v2 of chat
|
||||
*/
|
||||
protected function getV2() {
|
||||
if (!$this->_v2) {
|
||||
$this->_v2 = new V2($this);
|
||||
}
|
||||
return $this->_v2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Chat\V2\CredentialList
|
||||
*/
|
||||
protected function getCredentials() {
|
||||
return $this->v2->credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Chat\V2\CredentialContext
|
||||
*/
|
||||
protected function contextCredentials($sid) {
|
||||
return $this->v2->credentials($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Chat\V2\ServiceList
|
||||
*/
|
||||
protected function getServices() {
|
||||
return $this->v2->services;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Chat\V2\ServiceContext
|
||||
*/
|
||||
protected function contextServices($sid) {
|
||||
return $this->v2->services($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Chat]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Chat\V1;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Options;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class CredentialContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the CredentialContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Chat\V1\CredentialContext
|
||||
*/
|
||||
public function __construct(Version $version, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('sid' => $sid, );
|
||||
|
||||
$this->uri = '/Credentials/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a CredentialInstance
|
||||
*
|
||||
* @return CredentialInstance Fetched CredentialInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new CredentialInstance($this->version, $payload, $this->solution['sid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the CredentialInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return CredentialInstance Updated CredentialInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update($options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'FriendlyName' => $options['friendlyName'],
|
||||
'Certificate' => $options['certificate'],
|
||||
'PrivateKey' => $options['privateKey'],
|
||||
'Sandbox' => Serialize::booleanToString($options['sandbox']),
|
||||
'ApiKey' => $options['apiKey'],
|
||||
'Secret' => $options['secret'],
|
||||
));
|
||||
|
||||
$payload = $this->version->update(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new CredentialInstance($this->version, $payload, $this->solution['sid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the CredentialInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Chat.V1.CredentialContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Chat\V1\Service\Channel;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string channelSid
|
||||
* @property string serviceSid
|
||||
* @property string identity
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string roleSid
|
||||
* @property string createdBy
|
||||
* @property string url
|
||||
*/
|
||||
class InviteInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the InviteInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $serviceSid The unique id of the Service this member belongs
|
||||
* to.
|
||||
* @param string $channelSid The unique id of the Channel for this member.
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\InviteInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $serviceSid, $channelSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'channelSid' => Values::array_get($payload, 'channel_sid'),
|
||||
'serviceSid' => Values::array_get($payload, 'service_sid'),
|
||||
'identity' => Values::array_get($payload, 'identity'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'roleSid' => Values::array_get($payload, 'role_sid'),
|
||||
'createdBy' => Values::array_get($payload, 'created_by'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array(
|
||||
'serviceSid' => $serviceSid,
|
||||
'channelSid' => $channelSid,
|
||||
'sid' => $sid ?: $this->properties['sid'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\InviteContext Context for this
|
||||
* InviteInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new InviteContext(
|
||||
$this->version,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['channelSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a InviteInstance
|
||||
*
|
||||
* @return InviteInstance Fetched InviteInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the InviteInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Chat.V1.InviteInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Chat\V1\Service\Channel;
|
||||
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
|
||||
abstract class InviteOptions {
|
||||
/**
|
||||
* @param string $roleSid The Role assigned to this member.
|
||||
* @return CreateInviteOptions Options builder
|
||||
*/
|
||||
public static function create($roleSid = Values::NONE) {
|
||||
return new CreateInviteOptions($roleSid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $identity A unique string identifier for this User in this
|
||||
* Service.
|
||||
* @return ReadInviteOptions Options builder
|
||||
*/
|
||||
public static function read($identity = Values::NONE) {
|
||||
return new ReadInviteOptions($identity);
|
||||
}
|
||||
}
|
||||
|
||||
class CreateInviteOptions extends Options {
|
||||
/**
|
||||
* @param string $roleSid The Role assigned to this member.
|
||||
*/
|
||||
public function __construct($roleSid = Values::NONE) {
|
||||
$this->options['roleSid'] = $roleSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The [Role](https://www.twilio.com/docs/api/chat/rest/v1/role) assigned to this member.
|
||||
*
|
||||
* @param string $roleSid The Role assigned to this member.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setRoleSid($roleSid) {
|
||||
$this->options['roleSid'] = $roleSid;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Chat.V1.CreateInviteOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
class ReadInviteOptions extends Options {
|
||||
/**
|
||||
* @param string $identity A unique string identifier for this User in this
|
||||
* Service.
|
||||
*/
|
||||
public function __construct($identity = Values::NONE) {
|
||||
$this->options['identity'] = $identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique string identifier for this [User](https://www.twilio.com/docs/api/chat/rest/v1/user) in this [Service](https://www.twilio.com/docs/api/chat/rest/v1/service). See the [access tokens](https://www.twilio.com/docs/api/chat/guides/create-tokens)[/docs/api/chat/guides/create-tokens] docs for more details.
|
||||
*
|
||||
* @param string $identity A unique string identifier for this User in this
|
||||
* Service.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setIdentity($identity) {
|
||||
$this->options['identity'] = $identity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Chat.V1.ReadInviteOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Chat\V1\Service\Channel;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class MessageList extends ListResource {
|
||||
/**
|
||||
* Construct the MessageList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $serviceSid The unique id of the Service this message belongs
|
||||
* to.
|
||||
* @param string $channelSid The channel_sid
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\MessageList
|
||||
*/
|
||||
public function __construct(Version $version, $serviceSid, $channelSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('serviceSid' => $serviceSid, 'channelSid' => $channelSid, );
|
||||
|
||||
$this->uri = '/Services/' . rawurlencode($serviceSid) . '/Channels/' . rawurlencode($channelSid) . '/Messages';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MessageInstance
|
||||
*
|
||||
* @param string $body The body
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MessageInstance Newly created MessageInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create($body, $options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'Body' => $body,
|
||||
'From' => $options['from'],
|
||||
'Attributes' => $options['attributes'],
|
||||
));
|
||||
|
||||
$payload = $this->version->create(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new MessageInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['channelSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MessageInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($options = array(), $limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($options, $limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MessageInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return MessageInstance[] Array of results
|
||||
*/
|
||||
public function read($options = array(), $limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MessageInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of MessageInstance
|
||||
*/
|
||||
public function page($options = array(), $pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$options = new Values($options);
|
||||
$params = Values::of(array(
|
||||
'Order' => $options['order'],
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new MessagePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MessageInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of MessageInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new MessagePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a MessageContext
|
||||
*
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\MessageContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new MessageContext(
|
||||
$this->version,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['channelSid'],
|
||||
$sid
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Chat.V1.MessageList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Chat\V1\Service;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Options;
|
||||
use Twilio\Rest\Chat\V1\Service\Channel\InviteList;
|
||||
use Twilio\Rest\Chat\V1\Service\Channel\MemberList;
|
||||
use Twilio\Rest\Chat\V1\Service\Channel\MessageList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Chat\V1\Service\Channel\MemberList members
|
||||
* @property \Twilio\Rest\Chat\V1\Service\Channel\MessageList messages
|
||||
* @property \Twilio\Rest\Chat\V1\Service\Channel\InviteList invites
|
||||
* @method \Twilio\Rest\Chat\V1\Service\Channel\MemberContext members(string $sid)
|
||||
* @method \Twilio\Rest\Chat\V1\Service\Channel\MessageContext messages(string $sid)
|
||||
* @method \Twilio\Rest\Chat\V1\Service\Channel\InviteContext invites(string $sid)
|
||||
*/
|
||||
class ChannelContext extends InstanceContext {
|
||||
protected $_members = null;
|
||||
protected $_messages = null;
|
||||
protected $_invites = null;
|
||||
|
||||
/**
|
||||
* Initialize the ChannelContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $serviceSid The service_sid
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Chat\V1\Service\ChannelContext
|
||||
*/
|
||||
public function __construct(Version $version, $serviceSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('serviceSid' => $serviceSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Services/' . rawurlencode($serviceSid) . '/Channels/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ChannelInstance
|
||||
*
|
||||
* @return ChannelInstance Fetched ChannelInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ChannelInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the ChannelInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ChannelInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ChannelInstance Updated ChannelInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update($options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'FriendlyName' => $options['friendlyName'],
|
||||
'UniqueName' => $options['uniqueName'],
|
||||
'Attributes' => $options['attributes'],
|
||||
));
|
||||
|
||||
$payload = $this->version->update(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new ChannelInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the members
|
||||
*
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\MemberList
|
||||
*/
|
||||
protected function getMembers() {
|
||||
if (!$this->_members) {
|
||||
$this->_members = new MemberList(
|
||||
$this->version,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the messages
|
||||
*
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\MessageList
|
||||
*/
|
||||
protected function getMessages() {
|
||||
if (!$this->_messages) {
|
||||
$this->_messages = new MessageList(
|
||||
$this->version,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the invites
|
||||
*
|
||||
* @return \Twilio\Rest\Chat\V1\Service\Channel\InviteList
|
||||
*/
|
||||
protected function getInvites() {
|
||||
if (!$this->_invites) {
|
||||
$this->_invites = new InviteList(
|
||||
$this->version,
|
||||
$this->solution['serviceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_invites;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Chat.V1.ChannelContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Chat;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Chat\V2\CredentialList;
|
||||
use Twilio\Rest\Chat\V2\ServiceList;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Chat\V2\CredentialList credentials
|
||||
* @property \Twilio\Rest\Chat\V2\ServiceList services
|
||||
* @method \Twilio\Rest\Chat\V2\CredentialContext credentials(string $sid)
|
||||
* @method \Twilio\Rest\Chat\V2\ServiceContext services(string $sid)
|
||||
*/
|
||||
class V2 extends Version {
|
||||
protected $_credentials = null;
|
||||
protected $_services = null;
|
||||
|
||||
/**
|
||||
* Construct the V2 version of Chat
|
||||
*
|
||||
* @param \Twilio\Domain $domain Domain that contains the version
|
||||
* @return \Twilio\Rest\Chat\V2 V2 version of Chat
|
||||
*/
|
||||
public function __construct(Domain $domain) {
|
||||
parent::__construct($domain);
|
||||
$this->version = 'v2';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Chat\V2\CredentialList
|
||||
*/
|
||||
protected function getCredentials() {
|
||||
if (!$this->_credentials) {
|
||||
$this->_credentials = new CredentialList($this);
|
||||
}
|
||||
return $this->_credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Chat\V2\ServiceList
|
||||
*/
|
||||
protected function getServices() {
|
||||
if (!$this->_services) {
|
||||
$this->_services = new ServiceList($this);
|
||||
}
|
||||
return $this->_services;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load root resources
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @return \Twilio\ListResource The requested resource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown resource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('Resource does not have a context');
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Chat.V2]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,855 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Exceptions\ConfigurationException;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Http\Client as HttpClient;
|
||||
use Twilio\Http\CurlClient;
|
||||
use Twilio\VersionInfo;
|
||||
|
||||
/**
|
||||
* A client for accessing the Twilio API.
|
||||
*
|
||||
* @property \Twilio\Rest\Accounts accounts
|
||||
* @property \Twilio\Rest\Api api
|
||||
* @property \Twilio\Rest\Chat chat
|
||||
* @property \Twilio\Rest\Fax fax
|
||||
* @property \Twilio\Rest\IpMessaging ipMessaging
|
||||
* @property \Twilio\Rest\Lookups lookups
|
||||
* @property \Twilio\Rest\Monitor monitor
|
||||
* @property \Twilio\Rest\Notify notify
|
||||
* @property \Twilio\Rest\Preview preview
|
||||
* @property \Twilio\Rest\Pricing pricing
|
||||
* @property \Twilio\Rest\Proxy proxy
|
||||
* @property \Twilio\Rest\Taskrouter taskrouter
|
||||
* @property \Twilio\Rest\Trunking trunking
|
||||
* @property \Twilio\Rest\Video video
|
||||
* @property \Twilio\Rest\Messaging messaging
|
||||
* @property \Twilio\Rest\Wireless wireless
|
||||
* @property \Twilio\Rest\Sync sync
|
||||
* @property \Twilio\Rest\Studio studio
|
||||
* @property \Twilio\Rest\Verify verify
|
||||
* @property \Twilio\Rest\Api\V2010\AccountInstance account
|
||||
* @property \Twilio\Rest\Api\V2010\Account\AddressList addresses
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ApplicationList applications
|
||||
* @property \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList authorizedConnectApps
|
||||
* @property \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList availablePhoneNumbers
|
||||
* @property \Twilio\Rest\Api\V2010\Account\CallList calls
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ConferenceList conferences
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ConnectAppList connectApps
|
||||
* @property \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList incomingPhoneNumbers
|
||||
* @property \Twilio\Rest\Api\V2010\Account\KeyList keys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\MessageList messages
|
||||
* @property \Twilio\Rest\Api\V2010\Account\NewKeyList newKeys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\NewSigningKeyList newSigningKeys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\NotificationList notifications
|
||||
* @property \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList outgoingCallerIds
|
||||
* @property \Twilio\Rest\Api\V2010\Account\QueueList queues
|
||||
* @property \Twilio\Rest\Api\V2010\Account\RecordingList recordings
|
||||
* @property \Twilio\Rest\Api\V2010\Account\SigningKeyList signingKeys
|
||||
* @property \Twilio\Rest\Api\V2010\Account\SipList sip
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ShortCodeList shortCodes
|
||||
* @property \Twilio\Rest\Api\V2010\Account\TokenList tokens
|
||||
* @property \Twilio\Rest\Api\V2010\Account\TranscriptionList transcriptions
|
||||
* @property \Twilio\Rest\Api\V2010\Account\UsageList usage
|
||||
* @property \Twilio\Rest\Api\V2010\Account\ValidationRequestList validationRequests
|
||||
* @method \Twilio\Rest\Api\V2010\AccountContext accounts(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\AddressContext addresses(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ApplicationContext applications(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext authorizedConnectApps(string $connectAppSid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext availablePhoneNumbers(string $countryCode)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\CallContext calls(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ConferenceContext conferences(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ConnectAppContext connectApps(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext incomingPhoneNumbers(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\KeyContext keys(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\MessageContext messages(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\NotificationContext notifications(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext outgoingCallerIds(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\QueueContext queues(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\RecordingContext recordings(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\SigningKeyContext signingKeys(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\ShortCodeContext shortCodes(string $sid)
|
||||
* @method \Twilio\Rest\Api\V2010\Account\TranscriptionContext transcriptions(string $sid)
|
||||
*/
|
||||
class Client {
|
||||
const ENV_ACCOUNT_SID = "TWILIO_ACCOUNT_SID";
|
||||
const ENV_AUTH_TOKEN = "TWILIO_AUTH_TOKEN";
|
||||
|
||||
protected $username;
|
||||
protected $password;
|
||||
protected $accountSid;
|
||||
protected $region;
|
||||
protected $httpClient;
|
||||
protected $_account;
|
||||
protected $_accounts = null;
|
||||
protected $_api = null;
|
||||
protected $_chat = null;
|
||||
protected $_fax = null;
|
||||
protected $_ipMessaging = null;
|
||||
protected $_lookups = null;
|
||||
protected $_monitor = null;
|
||||
protected $_notify = null;
|
||||
protected $_preview = null;
|
||||
protected $_pricing = null;
|
||||
protected $_proxy = null;
|
||||
protected $_taskrouter = null;
|
||||
protected $_trunking = null;
|
||||
protected $_video = null;
|
||||
protected $_messaging = null;
|
||||
protected $_wireless = null;
|
||||
protected $_sync = null;
|
||||
protected $_studio = null;
|
||||
protected $_verify = null;
|
||||
|
||||
/**
|
||||
* Initializes the Twilio Client
|
||||
*
|
||||
* @param string $username Username to authenticate with
|
||||
* @param string $password Password to authenticate with
|
||||
* @param string $accountSid Account Sid to authenticate with, defaults to
|
||||
* $username
|
||||
* @param string $region Region to send requests to, defaults to no region
|
||||
* selection
|
||||
* @param \Twilio\Http\Client $httpClient HttpClient, defaults to CurlClient
|
||||
* @param mixed[] $environment Environment to look for auth details, defaults
|
||||
* to $_ENV
|
||||
* @return \Twilio\Rest\Client Twilio Client
|
||||
* @throws ConfigurationException If valid authentication is not present
|
||||
*/
|
||||
public function __construct($username = null, $password = null, $accountSid = null, $region = null, HttpClient $httpClient = null, $environment = null) {
|
||||
if (is_null($environment)) {
|
||||
$environment = $_ENV;
|
||||
}
|
||||
|
||||
if ($username) {
|
||||
$this->username = $username;
|
||||
} else {
|
||||
if (array_key_exists(self::ENV_ACCOUNT_SID, $environment)) {
|
||||
$this->username = $environment[self::ENV_ACCOUNT_SID];
|
||||
}
|
||||
}
|
||||
|
||||
if ($password) {
|
||||
$this->password = $password;
|
||||
} else {
|
||||
if (array_key_exists(self::ENV_AUTH_TOKEN, $environment)) {
|
||||
$this->password = $environment[self::ENV_AUTH_TOKEN];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->username || !$this->password) {
|
||||
throw new ConfigurationException("Credentials are required to create a Client");
|
||||
}
|
||||
|
||||
$this->accountSid = $accountSid ?: $this->username;
|
||||
$this->region = $region;
|
||||
|
||||
if ($httpClient) {
|
||||
$this->httpClient = $httpClient;
|
||||
} else {
|
||||
$this->httpClient = new CurlClient();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a request to the Twilio API using the configured http client
|
||||
* Authentication information is automatically added if none is provided
|
||||
*
|
||||
* @param string $method HTTP Method
|
||||
* @param string $uri Fully qualified url
|
||||
* @param string[] $params Query string parameters
|
||||
* @param string[] $data POST body data
|
||||
* @param string[] $headers HTTP Headers
|
||||
* @param string $username User for Authentication
|
||||
* @param string $password Password for Authentication
|
||||
* @param int $timeout Timeout in seconds
|
||||
* @return \Twilio\Http\Response Response from the Twilio API
|
||||
*/
|
||||
public function request($method, $uri, $params = array(), $data = array(), $headers = array(), $username = null, $password = null, $timeout = null) {
|
||||
$username = $username ? $username : $this->username;
|
||||
$password = $password ? $password : $this->password;
|
||||
|
||||
$headers['User-Agent'] = 'twilio-php/' . VersionInfo::string() .
|
||||
' (PHP ' . phpversion() . ')';
|
||||
$headers['Accept-Charset'] = 'utf-8';
|
||||
|
||||
if ($method == 'POST' && !array_key_exists('Content-Type', $headers)) {
|
||||
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
|
||||
if (!array_key_exists('Accept', $headers)) {
|
||||
$headers['Accept'] = 'application/json';
|
||||
}
|
||||
|
||||
if ($this->region) {
|
||||
list($head, $tail) = explode('.', $uri, 2);
|
||||
|
||||
if (strpos($tail, $this->region) !== 0) {
|
||||
$uri = implode('.', array($head, $this->region, $tail));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->getHttpClient()->request(
|
||||
$method,
|
||||
$uri,
|
||||
$params,
|
||||
$data,
|
||||
$headers,
|
||||
$username,
|
||||
$password,
|
||||
$timeout
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Username
|
||||
*
|
||||
* @return string Current Username
|
||||
*/
|
||||
public function getUsername() {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Password
|
||||
*
|
||||
* @return string Current Password
|
||||
*/
|
||||
public function getPassword() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the AccountSid
|
||||
*
|
||||
* @return string Current AccountSid
|
||||
*/
|
||||
public function getAccountSid() {
|
||||
return $this->accountSid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Region
|
||||
*
|
||||
* @return string Current Region
|
||||
*/
|
||||
public function getRegion() {
|
||||
return $this->region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the HttpClient
|
||||
*
|
||||
* @return \Twilio\Http\Client Current HttpClient
|
||||
*/
|
||||
public function getHttpClient() {
|
||||
return $this->httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the HttpClient
|
||||
*
|
||||
* @param \Twilio\Http\Client $httpClient HttpClient to use
|
||||
*/
|
||||
public function setHttpClient(HttpClient $httpClient) {
|
||||
$this->httpClient = $httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Accounts Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Accounts Accounts Twilio Domain
|
||||
*/
|
||||
protected function getAccounts() {
|
||||
if (!$this->_accounts) {
|
||||
$this->_accounts = new Accounts($this);
|
||||
}
|
||||
return $this->_accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Api Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Api Api Twilio Domain
|
||||
*/
|
||||
protected function getApi() {
|
||||
if (!$this->_api) {
|
||||
$this->_api = new Api($this);
|
||||
}
|
||||
return $this->_api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\AccountContext Account provided as the
|
||||
* authenticating account
|
||||
*/
|
||||
public function getAccount() {
|
||||
return $this->api->v2010->account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AddressList
|
||||
*/
|
||||
protected function getAddresses() {
|
||||
return $this->api->v2010->account->addresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AddressContext
|
||||
*/
|
||||
protected function contextAddresses($sid) {
|
||||
return $this->api->v2010->account->addresses($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ApplicationList
|
||||
*/
|
||||
protected function getApplications() {
|
||||
return $this->api->v2010->account->applications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique Application Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ApplicationContext
|
||||
*/
|
||||
protected function contextApplications($sid) {
|
||||
return $this->api->v2010->account->applications($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList
|
||||
*/
|
||||
protected function getAuthorizedConnectApps() {
|
||||
return $this->api->v2010->account->authorizedConnectApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectAppSid The connect_app_sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext
|
||||
*/
|
||||
protected function contextAuthorizedConnectApps($connectAppSid) {
|
||||
return $this->api->v2010->account->authorizedConnectApps($connectAppSid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList
|
||||
*/
|
||||
protected function getAvailablePhoneNumbers() {
|
||||
return $this->api->v2010->account->availablePhoneNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $countryCode The country_code
|
||||
* @return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext
|
||||
*/
|
||||
protected function contextAvailablePhoneNumbers($countryCode) {
|
||||
return $this->api->v2010->account->availablePhoneNumbers($countryCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\CallList
|
||||
*/
|
||||
protected function getCalls() {
|
||||
return $this->api->v2010->account->calls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Call Sid that uniquely identifies the Call to fetch
|
||||
* @return \Twilio\Rest\Api\V2010\Account\CallContext
|
||||
*/
|
||||
protected function contextCalls($sid) {
|
||||
return $this->api->v2010->account->calls($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConferenceList
|
||||
*/
|
||||
protected function getConferences() {
|
||||
return $this->api->v2010->account->conferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique conference Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConferenceContext
|
||||
*/
|
||||
protected function contextConferences($sid) {
|
||||
return $this->api->v2010->account->conferences($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConnectAppList
|
||||
*/
|
||||
protected function getConnectApps() {
|
||||
return $this->api->v2010->account->connectApps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique connect-app Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ConnectAppContext
|
||||
*/
|
||||
protected function contextConnectApps($sid) {
|
||||
return $this->api->v2010->account->connectApps($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList
|
||||
*/
|
||||
protected function getIncomingPhoneNumbers() {
|
||||
return $this->api->v2010->account->incomingPhoneNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique incoming-phone-number Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext
|
||||
*/
|
||||
protected function contextIncomingPhoneNumbers($sid) {
|
||||
return $this->api->v2010->account->incomingPhoneNumbers($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\KeyList
|
||||
*/
|
||||
protected function getKeys() {
|
||||
return $this->api->v2010->account->keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\KeyContext
|
||||
*/
|
||||
protected function contextKeys($sid) {
|
||||
return $this->api->v2010->account->keys($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\MessageList
|
||||
*/
|
||||
protected function getMessages() {
|
||||
return $this->api->v2010->account->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique message Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\MessageContext
|
||||
*/
|
||||
protected function contextMessages($sid) {
|
||||
return $this->api->v2010->account->messages($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NewKeyList
|
||||
*/
|
||||
protected function getNewKeys() {
|
||||
return $this->api->v2010->account->newKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NewSigningKeyList
|
||||
*/
|
||||
protected function getNewSigningKeys() {
|
||||
return $this->api->v2010->account->newSigningKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NotificationList
|
||||
*/
|
||||
protected function getNotifications() {
|
||||
return $this->api->v2010->account->notifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique notification Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\NotificationContext
|
||||
*/
|
||||
protected function contextNotifications($sid) {
|
||||
return $this->api->v2010->account->notifications($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList
|
||||
*/
|
||||
protected function getOutgoingCallerIds() {
|
||||
return $this->api->v2010->account->outgoingCallerIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique outgoing-caller-id Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext
|
||||
*/
|
||||
protected function contextOutgoingCallerIds($sid) {
|
||||
return $this->api->v2010->account->outgoingCallerIds($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\QueueList
|
||||
*/
|
||||
protected function getQueues() {
|
||||
return $this->api->v2010->account->queues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique queue Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\QueueContext
|
||||
*/
|
||||
protected function contextQueues($sid) {
|
||||
return $this->api->v2010->account->queues($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\RecordingList
|
||||
*/
|
||||
protected function getRecordings() {
|
||||
return $this->api->v2010->account->recordings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique recording SID
|
||||
* @return \Twilio\Rest\Api\V2010\Account\RecordingContext
|
||||
*/
|
||||
protected function contextRecordings($sid) {
|
||||
return $this->api->v2010->account->recordings($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\SigningKeyList
|
||||
*/
|
||||
protected function getSigningKeys() {
|
||||
return $this->api->v2010->account->signingKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\SigningKeyContext
|
||||
*/
|
||||
protected function contextSigningKeys($sid) {
|
||||
return $this->api->v2010->account->signingKeys($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\SipList
|
||||
*/
|
||||
protected function getSip() {
|
||||
return $this->api->v2010->account->sip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ShortCodeList
|
||||
*/
|
||||
protected function getShortCodes() {
|
||||
return $this->api->v2010->account->shortCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique short-code Sid
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ShortCodeContext
|
||||
*/
|
||||
protected function contextShortCodes($sid) {
|
||||
return $this->api->v2010->account->shortCodes($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\TokenList
|
||||
*/
|
||||
protected function getTokens() {
|
||||
return $this->api->v2010->account->tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\TranscriptionList
|
||||
*/
|
||||
protected function getTranscriptions() {
|
||||
return $this->api->v2010->account->transcriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid Fetch by unique transcription SID
|
||||
* @return \Twilio\Rest\Api\V2010\Account\TranscriptionContext
|
||||
*/
|
||||
protected function contextTranscriptions($sid) {
|
||||
return $this->api->v2010->account->transcriptions($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\UsageList
|
||||
*/
|
||||
protected function getUsage() {
|
||||
return $this->api->v2010->account->usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Api\V2010\Account\ValidationRequestList
|
||||
*/
|
||||
protected function getValidationRequests() {
|
||||
return $this->api->v2010->account->validationRequests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Chat Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Chat Chat Twilio Domain
|
||||
*/
|
||||
protected function getChat() {
|
||||
if (!$this->_chat) {
|
||||
$this->_chat = new Chat($this);
|
||||
}
|
||||
return $this->_chat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Fax Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Fax Fax Twilio Domain
|
||||
*/
|
||||
protected function getFax() {
|
||||
if (!$this->_fax) {
|
||||
$this->_fax = new Fax($this);
|
||||
}
|
||||
return $this->_fax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the IpMessaging Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\IpMessaging IpMessaging Twilio Domain
|
||||
*/
|
||||
protected function getIpMessaging() {
|
||||
if (!$this->_ipMessaging) {
|
||||
$this->_ipMessaging = new IpMessaging($this);
|
||||
}
|
||||
return $this->_ipMessaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Lookups Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Lookups Lookups Twilio Domain
|
||||
*/
|
||||
protected function getLookups() {
|
||||
if (!$this->_lookups) {
|
||||
$this->_lookups = new Lookups($this);
|
||||
}
|
||||
return $this->_lookups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Monitor Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Monitor Monitor Twilio Domain
|
||||
*/
|
||||
protected function getMonitor() {
|
||||
if (!$this->_monitor) {
|
||||
$this->_monitor = new Monitor($this);
|
||||
}
|
||||
return $this->_monitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Notify Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Notify Notify Twilio Domain
|
||||
*/
|
||||
protected function getNotify() {
|
||||
if (!$this->_notify) {
|
||||
$this->_notify = new Notify($this);
|
||||
}
|
||||
return $this->_notify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Preview Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Preview Preview Twilio Domain
|
||||
*/
|
||||
protected function getPreview() {
|
||||
if (!$this->_preview) {
|
||||
$this->_preview = new Preview($this);
|
||||
}
|
||||
return $this->_preview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Pricing Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Pricing Pricing Twilio Domain
|
||||
*/
|
||||
protected function getPricing() {
|
||||
if (!$this->_pricing) {
|
||||
$this->_pricing = new Pricing($this);
|
||||
}
|
||||
return $this->_pricing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Proxy Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Proxy Proxy Twilio Domain
|
||||
*/
|
||||
protected function getProxy() {
|
||||
if (!$this->_proxy) {
|
||||
$this->_proxy = new Proxy($this);
|
||||
}
|
||||
return $this->_proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Taskrouter Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Taskrouter Taskrouter Twilio Domain
|
||||
*/
|
||||
protected function getTaskrouter() {
|
||||
if (!$this->_taskrouter) {
|
||||
$this->_taskrouter = new Taskrouter($this);
|
||||
}
|
||||
return $this->_taskrouter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Trunking Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Trunking Trunking Twilio Domain
|
||||
*/
|
||||
protected function getTrunking() {
|
||||
if (!$this->_trunking) {
|
||||
$this->_trunking = new Trunking($this);
|
||||
}
|
||||
return $this->_trunking;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Video Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Video Video Twilio Domain
|
||||
*/
|
||||
protected function getVideo() {
|
||||
if (!$this->_video) {
|
||||
$this->_video = new Video($this);
|
||||
}
|
||||
return $this->_video;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Messaging Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Messaging Messaging Twilio Domain
|
||||
*/
|
||||
protected function getMessaging() {
|
||||
if (!$this->_messaging) {
|
||||
$this->_messaging = new Messaging($this);
|
||||
}
|
||||
return $this->_messaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Wireless Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Wireless Wireless Twilio Domain
|
||||
*/
|
||||
protected function getWireless() {
|
||||
if (!$this->_wireless) {
|
||||
$this->_wireless = new Wireless($this);
|
||||
}
|
||||
return $this->_wireless;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Sync Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Sync Sync Twilio Domain
|
||||
*/
|
||||
protected function getSync() {
|
||||
if (!$this->_sync) {
|
||||
$this->_sync = new Sync($this);
|
||||
}
|
||||
return $this->_sync;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Studio Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Studio Studio Twilio Domain
|
||||
*/
|
||||
protected function getStudio() {
|
||||
if (!$this->_studio) {
|
||||
$this->_studio = new Studio($this);
|
||||
}
|
||||
return $this->_studio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the Verify Twilio Domain
|
||||
*
|
||||
* @return \Twilio\Rest\Verify Verify Twilio Domain
|
||||
*/
|
||||
protected function getVerify() {
|
||||
if (!$this->_verify) {
|
||||
$this->_verify = new Verify($this);
|
||||
}
|
||||
return $this->_verify;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load domains
|
||||
*
|
||||
* @param string $name Domain to return
|
||||
* @return \Twilio\Domain The requested domain
|
||||
* @throws TwilioException For unknown domains
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown domain ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic call to lazy load contexts
|
||||
*
|
||||
* @param string $name Context to return
|
||||
* @param mixed[] $arguments Context to return
|
||||
* @return \Twilio\InstanceContext The requested context
|
||||
* @throws TwilioException For unknown contexts
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Client ' . $this->getAccountSid() . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates connection to new SSL certificate endpoint
|
||||
*
|
||||
* @param CurlClient $client
|
||||
* @throws TwilioException if request fails
|
||||
*/
|
||||
public function validateSslCertificate($client) {
|
||||
$response = $client->request('GET', 'https://api.twilio.com:8443');
|
||||
|
||||
if ($response->getStatusCode() < 200 || $response->getStatusCode() > 300) {
|
||||
throw new TwilioException("Failed to validate SSL certificate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Fax\V1\FaxList;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Fax\V1\FaxList faxes
|
||||
* @method \Twilio\Rest\Fax\V1\FaxContext faxes(string $sid)
|
||||
*/
|
||||
class V1 extends Version {
|
||||
protected $_faxes = null;
|
||||
|
||||
/**
|
||||
* Construct the V1 version of Fax
|
||||
*
|
||||
* @param \Twilio\Domain $domain Domain that contains the version
|
||||
* @return \Twilio\Rest\Fax\V1 V1 version of Fax
|
||||
*/
|
||||
public function __construct(Domain $domain) {
|
||||
parent::__construct($domain);
|
||||
$this->version = 'v1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Fax\V1\FaxList
|
||||
*/
|
||||
protected function getFaxes() {
|
||||
if (!$this->_faxes) {
|
||||
$this->_faxes = new FaxList($this);
|
||||
}
|
||||
return $this->_faxes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load root resources
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @return \Twilio\ListResource The requested resource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown resource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('Resource does not have a context');
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Fax.V1]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1\Fax;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*/
|
||||
class FaxMediaContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the FaxMediaContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $faxSid Fax SID
|
||||
* @param string $sid A string that uniquely identifies this fax media
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaContext
|
||||
*/
|
||||
public function __construct(Version $version, $faxSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('faxSid' => $faxSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Faxes/' . rawurlencode($faxSid) . '/Media/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a FaxMediaInstance
|
||||
*
|
||||
* @return FaxMediaInstance Fetched FaxMediaInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new FaxMediaInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['faxSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the FaxMediaInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Fax.V1.FaxMediaContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1\Fax;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string faxSid
|
||||
* @property string contentType
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string url
|
||||
*/
|
||||
class FaxMediaInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the FaxMediaInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $faxSid Fax SID
|
||||
* @param string $sid A string that uniquely identifies this fax media
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $faxSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'faxSid' => Values::array_get($payload, 'fax_sid'),
|
||||
'contentType' => Values::array_get($payload, 'content_type'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array('faxSid' => $faxSid, 'sid' => $sid ?: $this->properties['sid'], );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaContext Context for this
|
||||
* FaxMediaInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new FaxMediaContext(
|
||||
$this->version,
|
||||
$this->solution['faxSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a FaxMediaInstance
|
||||
*
|
||||
* @return FaxMediaInstance Fetched FaxMediaInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the FaxMediaInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Fax.V1.FaxMediaInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1\Fax;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*/
|
||||
class FaxMediaList extends ListResource {
|
||||
/**
|
||||
* Construct the FaxMediaList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $faxSid Fax SID
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaList
|
||||
*/
|
||||
public function __construct(Version $version, $faxSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('faxSid' => $faxSid, );
|
||||
|
||||
$this->uri = '/Faxes/' . rawurlencode($faxSid) . '/Media';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams FaxMediaInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads FaxMediaInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return FaxMediaInstance[] Array of results
|
||||
*/
|
||||
public function read($limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of FaxMediaInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of FaxMediaInstance
|
||||
*/
|
||||
public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$params = Values::of(array(
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new FaxMediaPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of FaxMediaInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of FaxMediaInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new FaxMediaPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a FaxMediaContext
|
||||
*
|
||||
* @param string $sid A string that uniquely identifies this fax media
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new FaxMediaContext($this->version, $this->solution['faxSid'], $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Fax.V1.FaxMediaList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1\Fax;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*/
|
||||
class FaxMediaPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new FaxMediaInstance($this->version, $payload, $this->solution['faxSid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Fax.V1.FaxMediaPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Options;
|
||||
use Twilio\Rest\Fax\V1\Fax\FaxMediaList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*
|
||||
* @property \Twilio\Rest\Fax\V1\Fax\FaxMediaList media
|
||||
* @method \Twilio\Rest\Fax\V1\Fax\FaxMediaContext media(string $sid)
|
||||
*/
|
||||
class FaxContext extends InstanceContext {
|
||||
protected $_media = null;
|
||||
|
||||
/**
|
||||
* Initialize the FaxContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $sid A string that uniquely identifies this fax.
|
||||
* @return \Twilio\Rest\Fax\V1\FaxContext
|
||||
*/
|
||||
public function __construct(Version $version, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('sid' => $sid, );
|
||||
|
||||
$this->uri = '/Faxes/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a FaxInstance
|
||||
*
|
||||
* @return FaxInstance Fetched FaxInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new FaxInstance($this->version, $payload, $this->solution['sid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the FaxInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return FaxInstance Updated FaxInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update($options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array('Status' => $options['status'], ));
|
||||
|
||||
$payload = $this->version->update(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new FaxInstance($this->version, $payload, $this->solution['sid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the FaxInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the media
|
||||
*
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaList
|
||||
*/
|
||||
protected function getMedia() {
|
||||
if (!$this->_media) {
|
||||
$this->_media = new FaxMediaList($this->version, $this->solution['sid']);
|
||||
}
|
||||
|
||||
return $this->_media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Fax.V1.FaxContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string from
|
||||
* @property string to
|
||||
* @property string quality
|
||||
* @property string mediaSid
|
||||
* @property string mediaUrl
|
||||
* @property integer numPages
|
||||
* @property integer duration
|
||||
* @property string status
|
||||
* @property string direction
|
||||
* @property string apiVersion
|
||||
* @property string price
|
||||
* @property string priceUnit
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property array links
|
||||
* @property string url
|
||||
*/
|
||||
class FaxInstance extends InstanceResource {
|
||||
protected $_media = null;
|
||||
|
||||
/**
|
||||
* Initialize the FaxInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $sid A string that uniquely identifies this fax.
|
||||
* @return \Twilio\Rest\Fax\V1\FaxInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'from' => Values::array_get($payload, 'from'),
|
||||
'to' => Values::array_get($payload, 'to'),
|
||||
'quality' => Values::array_get($payload, 'quality'),
|
||||
'mediaSid' => Values::array_get($payload, 'media_sid'),
|
||||
'mediaUrl' => Values::array_get($payload, 'media_url'),
|
||||
'numPages' => Values::array_get($payload, 'num_pages'),
|
||||
'duration' => Values::array_get($payload, 'duration'),
|
||||
'status' => Values::array_get($payload, 'status'),
|
||||
'direction' => Values::array_get($payload, 'direction'),
|
||||
'apiVersion' => Values::array_get($payload, 'api_version'),
|
||||
'price' => Values::array_get($payload, 'price'),
|
||||
'priceUnit' => Values::array_get($payload, 'price_unit'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'links' => Values::array_get($payload, 'links'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array('sid' => $sid ?: $this->properties['sid'], );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Fax\V1\FaxContext Context for this FaxInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new FaxContext($this->version, $this->solution['sid']);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a FaxInstance
|
||||
*
|
||||
* @return FaxInstance Fetched FaxInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the FaxInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return FaxInstance Updated FaxInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update($options = array()) {
|
||||
return $this->proxy()->update($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the FaxInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the media
|
||||
*
|
||||
* @return \Twilio\Rest\Fax\V1\Fax\FaxMediaList
|
||||
*/
|
||||
protected function getMedia() {
|
||||
return $this->proxy()->media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Fax.V1.FaxInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*/
|
||||
class FaxList extends ListResource {
|
||||
/**
|
||||
* Construct the FaxList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @return \Twilio\Rest\Fax\V1\FaxList
|
||||
*/
|
||||
public function __construct(Version $version) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array();
|
||||
|
||||
$this->uri = '/Faxes';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams FaxInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($options = array(), $limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($options, $limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads FaxInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return FaxInstance[] Array of results
|
||||
*/
|
||||
public function read($options = array(), $limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of FaxInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of FaxInstance
|
||||
*/
|
||||
public function page($options = array(), $pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$options = new Values($options);
|
||||
$params = Values::of(array(
|
||||
'From' => $options['from'],
|
||||
'To' => $options['to'],
|
||||
'DateCreatedOnOrBefore' => Serialize::iso8601DateTime($options['dateCreatedOnOrBefore']),
|
||||
'DateCreatedAfter' => Serialize::iso8601DateTime($options['dateCreatedAfter']),
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new FaxPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of FaxInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of FaxInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new FaxPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new FaxInstance
|
||||
*
|
||||
* @param string $to The phone number or SIP address to send the fax to
|
||||
* @param string $mediaUrl URL that points to the fax media
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return FaxInstance Newly created FaxInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create($to, $mediaUrl, $options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'To' => $to,
|
||||
'MediaUrl' => $mediaUrl,
|
||||
'Quality' => $options['quality'],
|
||||
'StatusCallback' => $options['statusCallback'],
|
||||
'From' => $options['from'],
|
||||
'SipAuthUsername' => $options['sipAuthUsername'],
|
||||
'SipAuthPassword' => $options['sipAuthPassword'],
|
||||
'StoreMedia' => Serialize::booleanToString($options['storeMedia']),
|
||||
'Ttl' => $options['ttl'],
|
||||
));
|
||||
|
||||
$payload = $this->version->create(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new FaxInstance($this->version, $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a FaxContext
|
||||
*
|
||||
* @param string $sid A string that uniquely identifies this fax.
|
||||
* @return \Twilio\Rest\Fax\V1\FaxContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new FaxContext($this->version, $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Fax.V1.FaxList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,276 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1;
|
||||
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*/
|
||||
abstract class FaxOptions {
|
||||
/**
|
||||
* @param string $from Include only faxes sent from
|
||||
* @param string $to Include only faxes sent to
|
||||
* @param \DateTime $dateCreatedOnOrBefore Include only faxes created on or
|
||||
* before
|
||||
* @param \DateTime $dateCreatedAfter Include only faxes created after
|
||||
* @return ReadFaxOptions Options builder
|
||||
*/
|
||||
public static function read($from = Values::NONE, $to = Values::NONE, $dateCreatedOnOrBefore = Values::NONE, $dateCreatedAfter = Values::NONE) {
|
||||
return new ReadFaxOptions($from, $to, $dateCreatedOnOrBefore, $dateCreatedAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $quality The quality of this fax
|
||||
* @param string $statusCallback URL for fax status callbacks
|
||||
* @param string $from Twilio number from which to originate the fax
|
||||
* @param string $sipAuthUsername Username for SIP authentication
|
||||
* @param string $sipAuthPassword Password for SIP authentication
|
||||
* @param boolean $storeMedia Whether or not to store media
|
||||
* @param integer $ttl How many minutes to attempt a fax
|
||||
* @return CreateFaxOptions Options builder
|
||||
*/
|
||||
public static function create($quality = Values::NONE, $statusCallback = Values::NONE, $from = Values::NONE, $sipAuthUsername = Values::NONE, $sipAuthPassword = Values::NONE, $storeMedia = Values::NONE, $ttl = Values::NONE) {
|
||||
return new CreateFaxOptions($quality, $statusCallback, $from, $sipAuthUsername, $sipAuthPassword, $storeMedia, $ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $status The updated status of this fax
|
||||
* @return UpdateFaxOptions Options builder
|
||||
*/
|
||||
public static function update($status = Values::NONE) {
|
||||
return new UpdateFaxOptions($status);
|
||||
}
|
||||
}
|
||||
|
||||
class ReadFaxOptions extends Options {
|
||||
/**
|
||||
* @param string $from Include only faxes sent from
|
||||
* @param string $to Include only faxes sent to
|
||||
* @param \DateTime $dateCreatedOnOrBefore Include only faxes created on or
|
||||
* before
|
||||
* @param \DateTime $dateCreatedAfter Include only faxes created after
|
||||
*/
|
||||
public function __construct($from = Values::NONE, $to = Values::NONE, $dateCreatedOnOrBefore = Values::NONE, $dateCreatedAfter = Values::NONE) {
|
||||
$this->options['from'] = $from;
|
||||
$this->options['to'] = $to;
|
||||
$this->options['dateCreatedOnOrBefore'] = $dateCreatedOnOrBefore;
|
||||
$this->options['dateCreatedAfter'] = $dateCreatedAfter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the returned list to only include faxes sent from the supplied number, given in E.164 format.
|
||||
*
|
||||
* @param string $from Include only faxes sent from
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setFrom($from) {
|
||||
$this->options['from'] = $from;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the returned list to only include faxes sent to the supplied number, given in E.164 format.
|
||||
*
|
||||
* @param string $to Include only faxes sent to
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setTo($to) {
|
||||
$this->options['to'] = $to;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the returned list to only include faxes created on or before the supplied date, given in ISO 8601 format.
|
||||
*
|
||||
* @param \DateTime $dateCreatedOnOrBefore Include only faxes created on or
|
||||
* before
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setDateCreatedOnOrBefore($dateCreatedOnOrBefore) {
|
||||
$this->options['dateCreatedOnOrBefore'] = $dateCreatedOnOrBefore;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the returned list to only include faxes created after the supplied date, given in ISO 8601 format.
|
||||
*
|
||||
* @param \DateTime $dateCreatedAfter Include only faxes created after
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setDateCreatedAfter($dateCreatedAfter) {
|
||||
$this->options['dateCreatedAfter'] = $dateCreatedAfter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Fax.V1.ReadFaxOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
class CreateFaxOptions extends Options {
|
||||
/**
|
||||
* @param string $quality The quality of this fax
|
||||
* @param string $statusCallback URL for fax status callbacks
|
||||
* @param string $from Twilio number from which to originate the fax
|
||||
* @param string $sipAuthUsername Username for SIP authentication
|
||||
* @param string $sipAuthPassword Password for SIP authentication
|
||||
* @param boolean $storeMedia Whether or not to store media
|
||||
* @param integer $ttl How many minutes to attempt a fax
|
||||
*/
|
||||
public function __construct($quality = Values::NONE, $statusCallback = Values::NONE, $from = Values::NONE, $sipAuthUsername = Values::NONE, $sipAuthPassword = Values::NONE, $storeMedia = Values::NONE, $ttl = Values::NONE) {
|
||||
$this->options['quality'] = $quality;
|
||||
$this->options['statusCallback'] = $statusCallback;
|
||||
$this->options['from'] = $from;
|
||||
$this->options['sipAuthUsername'] = $sipAuthUsername;
|
||||
$this->options['sipAuthPassword'] = $sipAuthPassword;
|
||||
$this->options['storeMedia'] = $storeMedia;
|
||||
$this->options['ttl'] = $ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* A [quality value](https://www.twilio.com/docs/api/fax/rest/faxes#fax-quality-values), which defaults to `fine`
|
||||
*
|
||||
* @param string $quality The quality of this fax
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setQuality($quality) {
|
||||
$this->options['quality'] = $quality;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A [status callback](https://www.twilio.com/docs/api/fax/rest/faxes#fax-status-callback) URL that will receive a POST when the status of the fax changes
|
||||
*
|
||||
* @param string $statusCallback URL for fax status callbacks
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setStatusCallback($statusCallback) {
|
||||
$this->options['statusCallback'] = $statusCallback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The phone number to use as the caller id, E.164-formatted. If using a phone number, it must be a Twilio number or a verified outgoing caller id for your account. If sending to a SIP address, this can be any alphanumeric string (plus the characters `+`, `_`, `.`, and `-`) to use in the From header of the SIP request.
|
||||
*
|
||||
* @param string $from Twilio number from which to originate the fax
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setFrom($from) {
|
||||
$this->options['from'] = $from;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The username to use for authentication when sending to a SIP address.
|
||||
*
|
||||
* @param string $sipAuthUsername Username for SIP authentication
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setSipAuthUsername($sipAuthUsername) {
|
||||
$this->options['sipAuthUsername'] = $sipAuthUsername;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The password to use for authentication when sending to a SIP address.
|
||||
*
|
||||
* @param string $sipAuthPassword Password for SIP authentication
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setSipAuthPassword($sipAuthPassword) {
|
||||
$this->options['sipAuthPassword'] = $sipAuthPassword;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not to store a copy of the sent media on Twilio's servers for later retrieval (defaults to `true`)
|
||||
*
|
||||
* @param boolean $storeMedia Whether or not to store media
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setStoreMedia($storeMedia) {
|
||||
$this->options['storeMedia'] = $storeMedia;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* How many minutes from when a fax was initiated should Twilio attempt to send a fax.
|
||||
*
|
||||
* @param integer $ttl How many minutes to attempt a fax
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setTtl($ttl) {
|
||||
$this->options['ttl'] = $ttl;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Fax.V1.CreateFaxOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
class UpdateFaxOptions extends Options {
|
||||
/**
|
||||
* @param string $status The updated status of this fax
|
||||
*/
|
||||
public function __construct($status = Values::NONE) {
|
||||
$this->options['status'] = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* The updated status of this fax. The only valid option is `canceled`. This may fail if the status has already started transmission.
|
||||
*
|
||||
* @param string $status The updated status of this fax
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setStatus($status) {
|
||||
$this->options['status'] = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Fax.V1.UpdateFaxOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Fax\V1;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
/**
|
||||
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
||||
*/
|
||||
class FaxPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new FaxInstance($this->version, $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Fax.V1.FaxPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Lookups\V1;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Lookups\V1 v1
|
||||
* @property \Twilio\Rest\Lookups\V1\PhoneNumberList phoneNumbers
|
||||
* @method \Twilio\Rest\Lookups\V1\PhoneNumberContext phoneNumbers(string $phoneNumber)
|
||||
*/
|
||||
class Lookups extends Domain {
|
||||
protected $_v1 = null;
|
||||
|
||||
/**
|
||||
* Construct the Lookups Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Lookups Domain for Lookups
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://lookups.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Lookups\V1 Version v1 of lookups
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Lookups\V1\PhoneNumberList
|
||||
*/
|
||||
protected function getPhoneNumbers() {
|
||||
return $this->v1->phoneNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $phoneNumber The phone_number
|
||||
* @return \Twilio\Rest\Lookups\V1\PhoneNumberContext
|
||||
*/
|
||||
protected function contextPhoneNumbers($phoneNumber) {
|
||||
return $this->v1->phoneNumbers($phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Lookups]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Notify\V1;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Notify\V1 v1
|
||||
* @property \Twilio\Rest\Notify\V1\CredentialList credentials
|
||||
* @property \Twilio\Rest\Notify\V1\ServiceList services
|
||||
* @method \Twilio\Rest\Notify\V1\CredentialContext credentials(string $sid)
|
||||
* @method \Twilio\Rest\Notify\V1\ServiceContext services(string $sid)
|
||||
*/
|
||||
class Notify extends Domain {
|
||||
protected $_v1 = null;
|
||||
|
||||
/**
|
||||
* Construct the Notify Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Notify Domain for Notify
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://notify.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Notify\V1 Version v1 of notify
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Notify\V1\CredentialList
|
||||
*/
|
||||
protected function getCredentials() {
|
||||
return $this->v1->credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Notify\V1\CredentialContext
|
||||
*/
|
||||
protected function contextCredentials($sid) {
|
||||
return $this->v1->credentials($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Notify\V1\ServiceList
|
||||
*/
|
||||
protected function getServices() {
|
||||
return $this->v1->services;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Notify\V1\ServiceContext
|
||||
*/
|
||||
protected function contextServices($sid) {
|
||||
return $this->v1->services($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Notify]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Pricing\V1;
|
||||
use Twilio\Rest\Pricing\V2;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Pricing\V1 v1
|
||||
* @property \Twilio\Rest\Pricing\V2 v2
|
||||
* @property \Twilio\Rest\Pricing\V1\MessagingList messaging
|
||||
* @property \Twilio\Rest\Pricing\V1\PhoneNumberList phoneNumbers
|
||||
* @property \Twilio\Rest\Pricing\V2\VoiceList voice
|
||||
*/
|
||||
class Pricing extends Domain {
|
||||
protected $_v1 = null;
|
||||
protected $_v2 = null;
|
||||
|
||||
/**
|
||||
* Construct the Pricing Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Pricing Domain for Pricing
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://pricing.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Pricing\V1 Version v1 of pricing
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Pricing\V2 Version v2 of pricing
|
||||
*/
|
||||
protected function getV2() {
|
||||
if (!$this->_v2) {
|
||||
$this->_v2 = new V2($this);
|
||||
}
|
||||
return $this->_v2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Pricing\V1\MessagingList
|
||||
*/
|
||||
protected function getMessaging() {
|
||||
return $this->v1->messaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Pricing\V1\PhoneNumberList
|
||||
*/
|
||||
protected function getPhoneNumbers() {
|
||||
return $this->v1->phoneNumbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Pricing\V2\VoiceList
|
||||
*/
|
||||
protected function getVoice() {
|
||||
return $this->v2->voice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Pricing]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Proxy\V1;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Proxy\V1 v1
|
||||
* @property \Twilio\Rest\Proxy\V1\ServiceList services
|
||||
* @method \Twilio\Rest\Proxy\V1\ServiceContext services(string $sid)
|
||||
*/
|
||||
class Proxy extends Domain {
|
||||
protected $_v1 = null;
|
||||
|
||||
/**
|
||||
* Construct the Proxy Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Proxy Domain for Proxy
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://proxy.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Proxy\V1 Version v1 of proxy
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Proxy\V1\ServiceList
|
||||
*/
|
||||
protected function getServices() {
|
||||
return $this->v1->services;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid A string that uniquely identifies this Service.
|
||||
* @return \Twilio\Rest\Proxy\V1\ServiceContext
|
||||
*/
|
||||
protected function contextServices($sid) {
|
||||
return $this->v1->services($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Proxy]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Studio\V1;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1 v1
|
||||
* @property \Twilio\Rest\Studio\V1\FlowList flows
|
||||
* @method \Twilio\Rest\Studio\V1\FlowContext flows(string $sid)
|
||||
*/
|
||||
class Studio extends Domain {
|
||||
protected $_v1 = null;
|
||||
|
||||
/**
|
||||
* Construct the Studio Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Studio Domain for Studio
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://studio.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Studio\V1 Version v1 of studio
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Studio\V1\FlowList
|
||||
*/
|
||||
protected function getFlows() {
|
||||
return $this->v1->flows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid A string that uniquely identifies this Flow.
|
||||
* @return \Twilio\Rest\Studio\V1\FlowContext
|
||||
*/
|
||||
protected function contextFlows($sid) {
|
||||
return $this->v1->flows($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Studio\V1\FlowList;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1\FlowList flows
|
||||
* @method \Twilio\Rest\Studio\V1\FlowContext flows(string $sid)
|
||||
*/
|
||||
class V1 extends Version {
|
||||
protected $_flows = null;
|
||||
|
||||
/**
|
||||
* Construct the V1 version of Studio
|
||||
*
|
||||
* @param \Twilio\Domain $domain Domain that contains the version
|
||||
* @return \Twilio\Rest\Studio\V1 V1 version of Studio
|
||||
*/
|
||||
public function __construct(Domain $domain) {
|
||||
parent::__construct($domain);
|
||||
$this->version = 'v1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Studio\V1\FlowList
|
||||
*/
|
||||
protected function getFlows() {
|
||||
if (!$this->_flows) {
|
||||
$this->_flows = new FlowList($this);
|
||||
}
|
||||
return $this->_flows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load root resources
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @return \Twilio\ListResource The requested resource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown resource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('Resource does not have a context');
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class EngagementContextContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the EngagementContextContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $engagementSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'engagementSid' => $engagementSid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Engagements/' . rawurlencode($engagementSid) . '/Context';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a EngagementContextInstance
|
||||
*
|
||||
* @return EngagementContextInstance Fetched EngagementContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new EngagementContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.EngagementContextContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string accountSid
|
||||
* @property array context
|
||||
* @property string engagementSid
|
||||
* @property string flowSid
|
||||
* @property string url
|
||||
*/
|
||||
class EngagementContextInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the EngagementContextInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $engagementSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'engagementSid' => Values::array_get($payload, 'engagement_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array('flowSid' => $flowSid, 'engagementSid' => $engagementSid, );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextContext Context for this EngagementContextInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new EngagementContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a EngagementContextInstance
|
||||
*
|
||||
* @return EngagementContextInstance Fetched EngagementContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.EngagementContextInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Version;
|
||||
|
||||
class EngagementContextList extends ListResource {
|
||||
/**
|
||||
* Construct the EngagementContextList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $engagementSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'engagementSid' => $engagementSid, );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a EngagementContextContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextContext
|
||||
*/
|
||||
public function getContext() {
|
||||
return new EngagementContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.EngagementContextList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class EngagementContextPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new EngagementContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.EngagementContextPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement\Step;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class StepContextContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the StepContextContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @param string $stepSid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $engagementSid, $stepSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'engagementSid' => $engagementSid,
|
||||
'stepSid' => $stepSid,
|
||||
);
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Engagements/' . rawurlencode($engagementSid) . '/Steps/' . rawurlencode($stepSid) . '/Context';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a StepContextInstance
|
||||
*
|
||||
* @return StepContextInstance Fetched StepContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new StepContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.StepContextContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement\Step;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string accountSid
|
||||
* @property array context
|
||||
* @property string engagementSid
|
||||
* @property string flowSid
|
||||
* @property string stepSid
|
||||
* @property string url
|
||||
*/
|
||||
class StepContextInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the StepContextInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @param string $stepSid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $engagementSid, $stepSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'engagementSid' => Values::array_get($payload, 'engagement_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'stepSid' => Values::array_get($payload, 'step_sid'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'engagementSid' => $engagementSid,
|
||||
'stepSid' => $stepSid,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextContext Context for this StepContextInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new StepContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a StepContextInstance
|
||||
*
|
||||
* @return StepContextInstance Fetched StepContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.StepContextInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement\Step;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Version;
|
||||
|
||||
class StepContextList extends ListResource {
|
||||
/**
|
||||
* Construct the StepContextList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @param string $stepSid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $engagementSid, $stepSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'engagementSid' => $engagementSid,
|
||||
'stepSid' => $stepSid,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a StepContextContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextContext
|
||||
*/
|
||||
public function getContext() {
|
||||
return new StepContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.StepContextList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement\Step;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class StepContextPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new StepContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.StepContextPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextList stepContext
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextContext stepContext()
|
||||
*/
|
||||
class StepContext extends InstanceContext {
|
||||
protected $_stepContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the StepContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @param string $sid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $engagementSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'engagementSid' => $engagementSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Engagements/' . rawurlencode($engagementSid) . '/Steps/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a StepInstance
|
||||
*
|
||||
* @return StepInstance Fetched StepInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new StepInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the stepContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextList
|
||||
*/
|
||||
protected function getStepContext() {
|
||||
if (!$this->_stepContext) {
|
||||
$this->_stepContext = new StepContextList(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_stepContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Studio.V1.StepContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string flowSid
|
||||
* @property string engagementSid
|
||||
* @property string name
|
||||
* @property array context
|
||||
* @property string transitionedFrom
|
||||
* @property string transitionedTo
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string url
|
||||
* @property array links
|
||||
*/
|
||||
class StepInstance extends InstanceResource {
|
||||
protected $_stepContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the StepInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @param string $sid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $engagementSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'engagementSid' => Values::array_get($payload, 'engagement_sid'),
|
||||
'name' => Values::array_get($payload, 'name'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'transitionedFrom' => Values::array_get($payload, 'transitioned_from'),
|
||||
'transitionedTo' => Values::array_get($payload, 'transitioned_to'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
'links' => Values::array_get($payload, 'links'),
|
||||
);
|
||||
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'engagementSid' => $engagementSid,
|
||||
'sid' => $sid ?: $this->properties['sid'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepContext Context for this
|
||||
* StepInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new StepContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a StepInstance
|
||||
*
|
||||
* @return StepInstance Fetched StepInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the stepContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\Step\StepContextList
|
||||
*/
|
||||
protected function getStepContext() {
|
||||
return $this->proxy()->stepContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.StepInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class StepList extends ListResource {
|
||||
/**
|
||||
* Construct the StepList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $engagementSid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $engagementSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'engagementSid' => $engagementSid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Engagements/' . rawurlencode($engagementSid) . '/Steps';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams StepInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads StepInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return StepInstance[] Array of results
|
||||
*/
|
||||
public function read($limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of StepInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of StepInstance
|
||||
*/
|
||||
public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$params = Values::of(array(
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new StepPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of StepInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of StepInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new StepPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a StepContext
|
||||
*
|
||||
* @param string $sid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new StepContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid'],
|
||||
$sid
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.StepList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Engagement;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class StepPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new StepInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['engagementSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.StepPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextList;
|
||||
use Twilio\Rest\Studio\V1\Flow\Engagement\StepList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\Engagement\StepList steps
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextList engagementContext
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\Engagement\StepContext steps(string $sid)
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextContext engagementContext()
|
||||
*/
|
||||
class EngagementContext extends InstanceContext {
|
||||
protected $_steps = null;
|
||||
protected $_engagementContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the EngagementContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $sid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Engagements/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a EngagementInstance
|
||||
*
|
||||
* @return EngagementInstance Fetched EngagementInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new EngagementInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the EngagementInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the steps
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepList
|
||||
*/
|
||||
protected function getSteps() {
|
||||
if (!$this->_steps) {
|
||||
$this->_steps = new StepList($this->version, $this->solution['flowSid'], $this->solution['sid']);
|
||||
}
|
||||
|
||||
return $this->_steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the engagementContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextList
|
||||
*/
|
||||
protected function getEngagementContext() {
|
||||
if (!$this->_engagementContext) {
|
||||
$this->_engagementContext = new EngagementContextList(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_engagementContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Studio.V1.EngagementContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string flowSid
|
||||
* @property string contactSid
|
||||
* @property string contactChannelAddress
|
||||
* @property array context
|
||||
* @property string status
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string url
|
||||
* @property array links
|
||||
*/
|
||||
class EngagementInstance extends InstanceResource {
|
||||
protected $_steps = null;
|
||||
protected $_engagementContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the EngagementInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $sid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'contactSid' => Values::array_get($payload, 'contact_sid'),
|
||||
'contactChannelAddress' => Values::array_get($payload, 'contact_channel_address'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'status' => Values::array_get($payload, 'status'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
'links' => Values::array_get($payload, 'links'),
|
||||
);
|
||||
|
||||
$this->solution = array('flowSid' => $flowSid, 'sid' => $sid ?: $this->properties['sid'], );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementContext Context for this
|
||||
* EngagementInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new EngagementContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a EngagementInstance
|
||||
*
|
||||
* @return EngagementInstance Fetched EngagementInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the EngagementInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the steps
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\StepList
|
||||
*/
|
||||
protected function getSteps() {
|
||||
return $this->proxy()->steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the engagementContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Engagement\EngagementContextList
|
||||
*/
|
||||
protected function getEngagementContext() {
|
||||
return $this->proxy()->engagementContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.EngagementInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class EngagementList extends ListResource {
|
||||
/**
|
||||
* Construct the EngagementList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Engagements';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams EngagementInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads EngagementInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return EngagementInstance[] Array of results
|
||||
*/
|
||||
public function read($limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of EngagementInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of EngagementInstance
|
||||
*/
|
||||
public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$params = Values::of(array(
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new EngagementPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of EngagementInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of EngagementInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new EngagementPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new EngagementInstance
|
||||
*
|
||||
* @param string $to The Contact phone number to start a Studio Flow Engagement.
|
||||
* @param string $from The Twilio phone number to send messages or initiate
|
||||
* calls from during the Flow Engagement.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return EngagementInstance Newly created EngagementInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create($to, $from, $options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'To' => $to,
|
||||
'From' => $from,
|
||||
'Parameters' => Serialize::jsonObject($options['parameters']),
|
||||
));
|
||||
|
||||
$payload = $this->version->create(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new EngagementInstance($this->version, $payload, $this->solution['flowSid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a EngagementContext
|
||||
*
|
||||
* @param string $sid Engagement Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new EngagementContext($this->version, $this->solution['flowSid'], $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.EngagementList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
|
||||
abstract class EngagementOptions {
|
||||
/**
|
||||
* @param array $parameters JSON data that will be added to your flow's context
|
||||
* and can accessed as variables inside your flow.
|
||||
* @return CreateEngagementOptions Options builder
|
||||
*/
|
||||
public static function create($parameters = Values::NONE) {
|
||||
return new CreateEngagementOptions($parameters);
|
||||
}
|
||||
}
|
||||
|
||||
class CreateEngagementOptions extends Options {
|
||||
/**
|
||||
* @param array $parameters JSON data that will be added to your flow's context
|
||||
* and can accessed as variables inside your flow.
|
||||
*/
|
||||
public function __construct($parameters = Values::NONE) {
|
||||
$this->options['parameters'] = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON data that will be added to your flow's context and can accessed as variables inside your flow. For example, if you pass in Parameters={'name':'Zeke'} then inside a widget you can reference the variable {{flow.data.name}} which will return the string 'Zeke'. Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode your JSON string.
|
||||
*
|
||||
* @param array $parameters JSON data that will be added to your flow's context
|
||||
* and can accessed as variables inside your flow.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setParameters($parameters) {
|
||||
$this->options['parameters'] = $parameters;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Studio.V1.CreateEngagementOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class EngagementPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new EngagementInstance($this->version, $payload, $this->solution['flowSid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.EngagementPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class ExecutionContextContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the ExecutionContextContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $executionSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'executionSid' => $executionSid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Executions/' . rawurlencode($executionSid) . '/Context';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionContextInstance
|
||||
*
|
||||
* @return ExecutionContextInstance Fetched ExecutionContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ExecutionContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.ExecutionContextContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string accountSid
|
||||
* @property array context
|
||||
* @property string flowSid
|
||||
* @property string executionSid
|
||||
* @property string url
|
||||
*/
|
||||
class ExecutionContextInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the ExecutionContextInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $executionSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'executionSid' => Values::array_get($payload, 'execution_sid'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array('flowSid' => $flowSid, 'executionSid' => $executionSid, );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextContext Context for this ExecutionContextInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new ExecutionContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionContextInstance
|
||||
*
|
||||
* @return ExecutionContextInstance Fetched ExecutionContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.ExecutionContextInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Version;
|
||||
|
||||
class ExecutionContextList extends ListResource {
|
||||
/**
|
||||
* Construct the ExecutionContextList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $executionSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'executionSid' => $executionSid, );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ExecutionContextContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextContext
|
||||
*/
|
||||
public function getContext() {
|
||||
return new ExecutionContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionContextList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class ExecutionContextPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new ExecutionContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionContextPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class ExecutionStepContextContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the ExecutionStepContextContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @param string $stepSid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $executionSid, $stepSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'executionSid' => $executionSid,
|
||||
'stepSid' => $stepSid,
|
||||
);
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Executions/' . rawurlencode($executionSid) . '/Steps/' . rawurlencode($stepSid) . '/Context';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionStepContextInstance
|
||||
*
|
||||
* @return ExecutionStepContextInstance Fetched ExecutionStepContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ExecutionStepContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.ExecutionStepContextContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string accountSid
|
||||
* @property array context
|
||||
* @property string executionSid
|
||||
* @property string flowSid
|
||||
* @property string stepSid
|
||||
* @property string url
|
||||
*/
|
||||
class ExecutionStepContextInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the ExecutionStepContextInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @param string $stepSid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $executionSid, $stepSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'executionSid' => Values::array_get($payload, 'execution_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'stepSid' => Values::array_get($payload, 'step_sid'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'executionSid' => $executionSid,
|
||||
'stepSid' => $stepSid,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextContext Context for this
|
||||
* ExecutionStepContextInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new ExecutionStepContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionStepContextInstance
|
||||
*
|
||||
* @return ExecutionStepContextInstance Fetched ExecutionStepContextInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.ExecutionStepContextInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Version;
|
||||
|
||||
class ExecutionStepContextList extends ListResource {
|
||||
/**
|
||||
* Construct the ExecutionStepContextList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @param string $stepSid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $executionSid, $stepSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'executionSid' => $executionSid,
|
||||
'stepSid' => $stepSid,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ExecutionStepContextContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextContext
|
||||
*/
|
||||
public function getContext() {
|
||||
return new ExecutionStepContextContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionStepContextList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class ExecutionStepContextPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new ExecutionStepContextInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['stepSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionStepContextPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextList stepContext
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextContext stepContext()
|
||||
*/
|
||||
class ExecutionStepContext extends InstanceContext {
|
||||
protected $_stepContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the ExecutionStepContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @param string $sid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $executionSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'executionSid' => $executionSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Executions/' . rawurlencode($executionSid) . '/Steps/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionStepInstance
|
||||
*
|
||||
* @return ExecutionStepInstance Fetched ExecutionStepInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ExecutionStepInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the stepContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextList
|
||||
*/
|
||||
protected function getStepContext() {
|
||||
if (!$this->_stepContext) {
|
||||
$this->_stepContext = new ExecutionStepContextList(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_stepContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Studio.V1.ExecutionStepContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string flowSid
|
||||
* @property string executionSid
|
||||
* @property string name
|
||||
* @property array context
|
||||
* @property string transitionedFrom
|
||||
* @property string transitionedTo
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string url
|
||||
* @property array links
|
||||
*/
|
||||
class ExecutionStepInstance extends InstanceResource {
|
||||
protected $_stepContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the ExecutionStepInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @param string $sid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $executionSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'executionSid' => Values::array_get($payload, 'execution_sid'),
|
||||
'name' => Values::array_get($payload, 'name'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'transitionedFrom' => Values::array_get($payload, 'transitioned_from'),
|
||||
'transitionedTo' => Values::array_get($payload, 'transitioned_to'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
'links' => Values::array_get($payload, 'links'),
|
||||
);
|
||||
|
||||
$this->solution = array(
|
||||
'flowSid' => $flowSid,
|
||||
'executionSid' => $executionSid,
|
||||
'sid' => $sid ?: $this->properties['sid'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepContext Context
|
||||
* for this
|
||||
* ExecutionStepInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new ExecutionStepContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionStepInstance
|
||||
*
|
||||
* @return ExecutionStepInstance Fetched ExecutionStepInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the stepContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStep\ExecutionStepContextList
|
||||
*/
|
||||
protected function getStepContext() {
|
||||
return $this->proxy()->stepContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.ExecutionStepInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class ExecutionStepList extends ListResource {
|
||||
/**
|
||||
* Construct the ExecutionStepList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $executionSid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $executionSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'executionSid' => $executionSid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Executions/' . rawurlencode($executionSid) . '/Steps';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ExecutionStepInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ExecutionStepInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return ExecutionStepInstance[] Array of results
|
||||
*/
|
||||
public function read($limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ExecutionStepInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of ExecutionStepInstance
|
||||
*/
|
||||
public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$params = Values::of(array(
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ExecutionStepPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ExecutionStepInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of ExecutionStepInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new ExecutionStepPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ExecutionStepContext
|
||||
*
|
||||
* @param string $sid Step Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new ExecutionStepContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid'],
|
||||
$sid
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionStepList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow\Execution;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class ExecutionStepPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new ExecutionStepInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['executionSid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionStepPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextList;
|
||||
use Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepList steps
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextList executionContext
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepContext steps(string $sid)
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextContext executionContext()
|
||||
*/
|
||||
class ExecutionContext extends InstanceContext {
|
||||
protected $_steps = null;
|
||||
protected $_executionContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the ExecutionContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $sid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionContext
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Executions/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionInstance
|
||||
*
|
||||
* @return ExecutionInstance Fetched ExecutionInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ExecutionInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the ExecutionInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the steps
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepList
|
||||
*/
|
||||
protected function getSteps() {
|
||||
if (!$this->_steps) {
|
||||
$this->_steps = new ExecutionStepList(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the executionContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextList
|
||||
*/
|
||||
protected function getExecutionContext() {
|
||||
if (!$this->_executionContext) {
|
||||
$this->_executionContext = new ExecutionContextList(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_executionContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Studio.V1.ExecutionContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string flowSid
|
||||
* @property string contactSid
|
||||
* @property string contactChannelAddress
|
||||
* @property array context
|
||||
* @property string status
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string url
|
||||
* @property array links
|
||||
*/
|
||||
class ExecutionInstance extends InstanceResource {
|
||||
protected $_steps = null;
|
||||
protected $_executionContext = null;
|
||||
|
||||
/**
|
||||
* Initialize the ExecutionInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @param string $sid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $flowSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'flowSid' => Values::array_get($payload, 'flow_sid'),
|
||||
'contactSid' => Values::array_get($payload, 'contact_sid'),
|
||||
'contactChannelAddress' => Values::array_get($payload, 'contact_channel_address'),
|
||||
'context' => Values::array_get($payload, 'context'),
|
||||
'status' => Values::array_get($payload, 'status'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
'links' => Values::array_get($payload, 'links'),
|
||||
);
|
||||
|
||||
$this->solution = array('flowSid' => $flowSid, 'sid' => $sid ?: $this->properties['sid'], );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionContext Context for this
|
||||
* ExecutionInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new ExecutionContext(
|
||||
$this->version,
|
||||
$this->solution['flowSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ExecutionInstance
|
||||
*
|
||||
* @return ExecutionInstance Fetched ExecutionInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the ExecutionInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the steps
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionStepList
|
||||
*/
|
||||
protected function getSteps() {
|
||||
return $this->proxy()->steps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the executionContext
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\Execution\ExecutionContextList
|
||||
*/
|
||||
protected function getExecutionContext() {
|
||||
return $this->proxy()->executionContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.ExecutionInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class ExecutionList extends ListResource {
|
||||
/**
|
||||
* Construct the ExecutionList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $flowSid Flow Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionList
|
||||
*/
|
||||
public function __construct(Version $version, $flowSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('flowSid' => $flowSid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($flowSid) . '/Executions';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ExecutionInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ExecutionInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return ExecutionInstance[] Array of results
|
||||
*/
|
||||
public function read($limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ExecutionInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of ExecutionInstance
|
||||
*/
|
||||
public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$params = Values::of(array(
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ExecutionPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ExecutionInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of ExecutionInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new ExecutionPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ExecutionInstance
|
||||
*
|
||||
* @param string $to The Contact phone number to start a Studio Flow Execution.
|
||||
* @param string $from The Twilio phone number to send messages or initiate
|
||||
* calls from during the Flow Execution.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ExecutionInstance Newly created ExecutionInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create($to, $from, $options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'To' => $to,
|
||||
'From' => $from,
|
||||
'Parameters' => Serialize::jsonObject($options['parameters']),
|
||||
));
|
||||
|
||||
$payload = $this->version->create(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new ExecutionInstance($this->version, $payload, $this->solution['flowSid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ExecutionContext
|
||||
*
|
||||
* @param string $sid Execution Sid.
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new ExecutionContext($this->version, $this->solution['flowSid'], $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
|
||||
abstract class ExecutionOptions {
|
||||
/**
|
||||
* @param array $parameters JSON data that will be added to your flow's context
|
||||
* and can accessed as variables inside your flow.
|
||||
* @return CreateExecutionOptions Options builder
|
||||
*/
|
||||
public static function create($parameters = Values::NONE) {
|
||||
return new CreateExecutionOptions($parameters);
|
||||
}
|
||||
}
|
||||
|
||||
class CreateExecutionOptions extends Options {
|
||||
/**
|
||||
* @param array $parameters JSON data that will be added to your flow's context
|
||||
* and can accessed as variables inside your flow.
|
||||
*/
|
||||
public function __construct($parameters = Values::NONE) {
|
||||
$this->options['parameters'] = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON data that will be added to your flow's context and can accessed as variables inside your flow. For example, if you pass in Parameters={'name':'Zeke'} then inside a widget you can reference the variable {{flow.data.name}} which will return the string 'Zeke'. Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode your JSON string.
|
||||
*
|
||||
* @param array $parameters JSON data that will be added to your flow's context
|
||||
* and can accessed as variables inside your flow.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setParameters($parameters) {
|
||||
$this->options['parameters'] = $parameters;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$options = array();
|
||||
foreach ($this->options as $key => $value) {
|
||||
if ($value != Values::NONE) {
|
||||
$options[] = "$key=$value";
|
||||
}
|
||||
}
|
||||
return '[Twilio.Studio.V1.CreateExecutionOptions ' . implode(' ', $options) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1\Flow;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class ExecutionPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new ExecutionInstance($this->version, $payload, $this->solution['flowSid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.ExecutionPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1;
|
||||
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Rest\Studio\V1\Flow\EngagementList;
|
||||
use Twilio\Rest\Studio\V1\Flow\ExecutionList;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\EngagementList engagements
|
||||
* @property \Twilio\Rest\Studio\V1\Flow\ExecutionList executions
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\EngagementContext engagements(string $sid)
|
||||
* @method \Twilio\Rest\Studio\V1\Flow\ExecutionContext executions(string $sid)
|
||||
*/
|
||||
class FlowContext extends InstanceContext {
|
||||
protected $_engagements = null;
|
||||
protected $_executions = null;
|
||||
|
||||
/**
|
||||
* Initialize the FlowContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $sid A string that uniquely identifies this Flow.
|
||||
* @return \Twilio\Rest\Studio\V1\FlowContext
|
||||
*/
|
||||
public function __construct(Version $version, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('sid' => $sid, );
|
||||
|
||||
$this->uri = '/Flows/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a FlowInstance
|
||||
*
|
||||
* @return FlowInstance Fetched FlowInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new FlowInstance($this->version, $payload, $this->solution['sid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the FlowInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the engagements
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementList
|
||||
*/
|
||||
protected function getEngagements() {
|
||||
if (!$this->_engagements) {
|
||||
$this->_engagements = new EngagementList($this->version, $this->solution['sid']);
|
||||
}
|
||||
|
||||
return $this->_engagements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the executions
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionList
|
||||
*/
|
||||
protected function getExecutions() {
|
||||
if (!$this->_executions) {
|
||||
$this->_executions = new ExecutionList($this->version, $this->solution['sid']);
|
||||
}
|
||||
|
||||
return $this->_executions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load subresources
|
||||
*
|
||||
* @param string $name Subresource to return
|
||||
* @return \Twilio\ListResource The requested subresource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown subresources
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown subresource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('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 '[Twilio.Studio.V1.FlowContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string sid
|
||||
* @property string accountSid
|
||||
* @property string friendlyName
|
||||
* @property string status
|
||||
* @property integer version
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string url
|
||||
* @property array links
|
||||
*/
|
||||
class FlowInstance extends InstanceResource {
|
||||
protected $_engagements = null;
|
||||
protected $_executions = null;
|
||||
|
||||
/**
|
||||
* Initialize the FlowInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $sid A string that uniquely identifies this Flow.
|
||||
* @return \Twilio\Rest\Studio\V1\FlowInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'friendlyName' => Values::array_get($payload, 'friendly_name'),
|
||||
'status' => Values::array_get($payload, 'status'),
|
||||
'version' => Values::array_get($payload, 'version'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
'links' => Values::array_get($payload, 'links'),
|
||||
);
|
||||
|
||||
$this->solution = array('sid' => $sid ?: $this->properties['sid'], );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\FlowContext Context for this FlowInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new FlowContext($this->version, $this->solution['sid']);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a FlowInstance
|
||||
*
|
||||
* @return FlowInstance Fetched FlowInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the FlowInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the engagements
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\EngagementList
|
||||
*/
|
||||
protected function getEngagements() {
|
||||
return $this->proxy()->engagements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access the executions
|
||||
*
|
||||
* @return \Twilio\Rest\Studio\V1\Flow\ExecutionList
|
||||
*/
|
||||
protected function getExecutions() {
|
||||
return $this->proxy()->executions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Studio.V1.FlowInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class FlowList extends ListResource {
|
||||
/**
|
||||
* Construct the FlowList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @return \Twilio\Rest\Studio\V1\FlowList
|
||||
*/
|
||||
public function __construct(Version $version) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array();
|
||||
|
||||
$this->uri = '/Flows';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams FlowInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads FlowInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return FlowInstance[] Array of results
|
||||
*/
|
||||
public function read($limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of FlowInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of FlowInstance
|
||||
*/
|
||||
public function page($pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$params = Values::of(array(
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new FlowPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of FlowInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of FlowInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new FlowPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a FlowContext
|
||||
*
|
||||
* @param string $sid A string that uniquely identifies this Flow.
|
||||
* @return \Twilio\Rest\Studio\V1\FlowContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new FlowContext($this->version, $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.FlowList]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Studio\V1;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
class FlowPage extends Page {
|
||||
public function __construct($version, $response, $solution) {
|
||||
parent::__construct($version, $response);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = $solution;
|
||||
}
|
||||
|
||||
public function buildInstance(array $payload) {
|
||||
return new FlowInstance($this->version, $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Studio.V1.FlowPage]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Taskrouter\V1;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Taskrouter\V1 v1
|
||||
* @property \Twilio\Rest\Taskrouter\V1\WorkspaceList workspaces
|
||||
* @method \Twilio\Rest\Taskrouter\V1\WorkspaceContext workspaces(string $sid)
|
||||
*/
|
||||
class Taskrouter extends Domain {
|
||||
protected $_v1 = null;
|
||||
|
||||
/**
|
||||
* Construct the Taskrouter Domain
|
||||
*
|
||||
* @param \Twilio\Rest\Client $client Twilio\Rest\Client to communicate with
|
||||
* Twilio
|
||||
* @return \Twilio\Rest\Taskrouter Domain for Taskrouter
|
||||
*/
|
||||
public function __construct(Client $client) {
|
||||
parent::__construct($client);
|
||||
|
||||
$this->baseUrl = 'https://taskrouter.twilio.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Taskrouter\V1 Version v1 of taskrouter
|
||||
*/
|
||||
protected function getV1() {
|
||||
if (!$this->_v1) {
|
||||
$this->_v1 = new V1($this);
|
||||
}
|
||||
return $this->_v1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load version
|
||||
*
|
||||
* @param string $name Version to return
|
||||
* @return \Twilio\Version The requested version
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown versions
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown version ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __call($name, $arguments) {
|
||||
$method = 'context' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return call_user_func_array(array($this, $method), $arguments);
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown context ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Taskrouter\V1\WorkspaceList
|
||||
*/
|
||||
protected function getWorkspaces() {
|
||||
return $this->v1->workspaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Taskrouter\V1\WorkspaceContext
|
||||
*/
|
||||
protected function contextWorkspaces($sid) {
|
||||
return $this->v1->workspaces($sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Taskrouter]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Taskrouter;
|
||||
|
||||
use Twilio\Domain;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\Rest\Taskrouter\V1\WorkspaceList;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property \Twilio\Rest\Taskrouter\V1\WorkspaceList workspaces
|
||||
* @method \Twilio\Rest\Taskrouter\V1\WorkspaceContext workspaces(string $sid)
|
||||
*/
|
||||
class V1 extends Version {
|
||||
protected $_workspaces = null;
|
||||
|
||||
/**
|
||||
* Construct the V1 version of Taskrouter
|
||||
*
|
||||
* @param \Twilio\Domain $domain Domain that contains the version
|
||||
* @return \Twilio\Rest\Taskrouter\V1 V1 version of Taskrouter
|
||||
*/
|
||||
public function __construct(Domain $domain) {
|
||||
parent::__construct($domain);
|
||||
$this->version = 'v1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Twilio\Rest\Taskrouter\V1\WorkspaceList
|
||||
*/
|
||||
protected function getWorkspaces() {
|
||||
if (!$this->_workspaces) {
|
||||
$this->_workspaces = new WorkspaceList($this);
|
||||
}
|
||||
return $this->_workspaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to lazy load root resources
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @return \Twilio\ListResource The requested resource
|
||||
* @throws \Twilio\Exceptions\TwilioException For unknown resource
|
||||
*/
|
||||
public function __get($name) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
if (method_exists($this, $method)) {
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown resource ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic caller to get resource contexts
|
||||
*
|
||||
* @param string $name Resource to return
|
||||
* @param array $arguments Context parameters
|
||||
* @return \Twilio\InstanceContext The requested resource context
|
||||
* @throws \Twilio\Exceptions\TwilioException 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 TwilioException('Resource does not have a context');
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Taskrouter.V1]';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Taskrouter\V1\Workspace;
|
||||
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class ActivityContext extends InstanceContext {
|
||||
/**
|
||||
* Initialize the ActivityContext
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param string $workspaceSid The workspace_sid
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Taskrouter\V1\Workspace\ActivityContext
|
||||
*/
|
||||
public function __construct(Version $version, $workspaceSid, $sid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('workspaceSid' => $workspaceSid, 'sid' => $sid, );
|
||||
|
||||
$this->uri = '/Workspaces/' . rawurlencode($workspaceSid) . '/Activities/' . rawurlencode($sid) . '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ActivityInstance
|
||||
*
|
||||
* @return ActivityInstance Fetched ActivityInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
$params = Values::of(array());
|
||||
|
||||
$payload = $this->version->fetch(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ActivityInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['workspaceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ActivityInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ActivityInstance Updated ActivityInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update($options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array('FriendlyName' => $options['friendlyName'], ));
|
||||
|
||||
$payload = $this->version->update(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new ActivityInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$this->solution['workspaceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the ActivityInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->version->delete('delete', $this->uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Taskrouter.V1.ActivityContext ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Taskrouter\V1\Workspace;
|
||||
|
||||
use Twilio\Deserialize;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
use Twilio\InstanceResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
/**
|
||||
* @property string accountSid
|
||||
* @property boolean available
|
||||
* @property \DateTime dateCreated
|
||||
* @property \DateTime dateUpdated
|
||||
* @property string friendlyName
|
||||
* @property string sid
|
||||
* @property string workspaceSid
|
||||
* @property string url
|
||||
*/
|
||||
class ActivityInstance extends InstanceResource {
|
||||
/**
|
||||
* Initialize the ActivityInstance
|
||||
*
|
||||
* @param \Twilio\Version $version Version that contains the resource
|
||||
* @param mixed[] $payload The response payload
|
||||
* @param string $workspaceSid The unique ID of the Workspace that this
|
||||
* Activity belongs to.
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Taskrouter\V1\Workspace\ActivityInstance
|
||||
*/
|
||||
public function __construct(Version $version, array $payload, $workspaceSid, $sid = null) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Marshaled Properties
|
||||
$this->properties = array(
|
||||
'accountSid' => Values::array_get($payload, 'account_sid'),
|
||||
'available' => Values::array_get($payload, 'available'),
|
||||
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
|
||||
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
|
||||
'friendlyName' => Values::array_get($payload, 'friendly_name'),
|
||||
'sid' => Values::array_get($payload, 'sid'),
|
||||
'workspaceSid' => Values::array_get($payload, 'workspace_sid'),
|
||||
'url' => Values::array_get($payload, 'url'),
|
||||
);
|
||||
|
||||
$this->solution = array('workspaceSid' => $workspaceSid, 'sid' => $sid ?: $this->properties['sid'], );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an instance context for the instance, the context is capable of
|
||||
* performing various actions. All instance actions are proxied to the context
|
||||
*
|
||||
* @return \Twilio\Rest\Taskrouter\V1\Workspace\ActivityContext Context for
|
||||
* this
|
||||
* ActivityInstance
|
||||
*/
|
||||
protected function proxy() {
|
||||
if (!$this->context) {
|
||||
$this->context = new ActivityContext(
|
||||
$this->version,
|
||||
$this->solution['workspaceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a ActivityInstance
|
||||
*
|
||||
* @return ActivityInstance Fetched ActivityInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch() {
|
||||
return $this->proxy()->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ActivityInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ActivityInstance Updated ActivityInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update($options = array()) {
|
||||
return $this->proxy()->update($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the ActivityInstance
|
||||
*
|
||||
* @return boolean True if delete succeeds, false otherwise
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function delete() {
|
||||
return $this->proxy()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic getter to access properties
|
||||
*
|
||||
* @param string $name Property to access
|
||||
* @return mixed The requested property
|
||||
* @throws TwilioException For unknown properties
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (array_key_exists($name, $this->properties)) {
|
||||
return $this->properties[$name];
|
||||
}
|
||||
|
||||
if (property_exists($this, '_' . $name)) {
|
||||
$method = 'get' . ucfirst($name);
|
||||
return $this->$method();
|
||||
}
|
||||
|
||||
throw new TwilioException('Unknown property: ' . $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
$context = array();
|
||||
foreach ($this->solution as $key => $value) {
|
||||
$context[] = "$key=$value";
|
||||
}
|
||||
return '[Twilio.Taskrouter.V1.ActivityInstance ' . implode(' ', $context) . ']';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* This code was generated by
|
||||
* \ / _ _ _| _ _
|
||||
* | (_)\/(_)(_|\/| |(/_ v1.0.0
|
||||
* / /
|
||||
*/
|
||||
|
||||
namespace Twilio\Rest\Taskrouter\V1\Workspace;
|
||||
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Options;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
|
||||
class ActivityList extends ListResource {
|
||||
/**
|
||||
* Construct the ActivityList
|
||||
*
|
||||
* @param Version $version Version that contains the resource
|
||||
* @param string $workspaceSid The unique ID of the Workspace that this
|
||||
* Activity belongs to.
|
||||
* @return \Twilio\Rest\Taskrouter\V1\Workspace\ActivityList
|
||||
*/
|
||||
public function __construct(Version $version, $workspaceSid) {
|
||||
parent::__construct($version);
|
||||
|
||||
// Path Solution
|
||||
$this->solution = array('workspaceSid' => $workspaceSid, );
|
||||
|
||||
$this->uri = '/Workspaces/' . rawurlencode($workspaceSid) . '/Activities';
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ActivityInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
* limit
|
||||
* is reached.
|
||||
* The results are returned as a generator, so this operation is memory
|
||||
* efficient.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. stream()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, stream()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return \Twilio\Stream stream of results
|
||||
*/
|
||||
public function stream($options = array(), $limit = null, $pageSize = null) {
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$page = $this->page($options, $limits['pageSize']);
|
||||
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ActivityInstance records from the API as a list.
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return ActivityInstance[] Array of results
|
||||
*/
|
||||
public function read($options = array(), $limit = null, $pageSize = null) {
|
||||
return iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ActivityInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param mixed $pageSize Number of records to return, defaults to 50
|
||||
* @param string $pageToken PageToken provided by the API
|
||||
* @param mixed $pageNumber Page Number, this value is simply for client state
|
||||
* @return \Twilio\Page Page of ActivityInstance
|
||||
*/
|
||||
public function page($options = array(), $pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
|
||||
$options = new Values($options);
|
||||
$params = Values::of(array(
|
||||
'FriendlyName' => $options['friendlyName'],
|
||||
'Available' => $options['available'],
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
));
|
||||
|
||||
$response = $this->version->page(
|
||||
'GET',
|
||||
$this->uri,
|
||||
$params
|
||||
);
|
||||
|
||||
return new ActivityPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ActivityInstance records from the API.
|
||||
* Request is executed immediately
|
||||
*
|
||||
* @param string $targetUrl API-generated URL for the requested results page
|
||||
* @return \Twilio\Page Page of ActivityInstance
|
||||
*/
|
||||
public function getPage($targetUrl) {
|
||||
$response = $this->version->getDomain()->getClient()->request(
|
||||
'GET',
|
||||
$targetUrl
|
||||
);
|
||||
|
||||
return new ActivityPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ActivityInstance
|
||||
*
|
||||
* @param string $friendlyName A human-readable name for the Activity, such as
|
||||
* 'On Call', 'Break', 'Email', etc.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ActivityInstance Newly created ActivityInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create($friendlyName, $options = array()) {
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of(array(
|
||||
'FriendlyName' => $friendlyName,
|
||||
'Available' => Serialize::booleanToString($options['available']),
|
||||
));
|
||||
|
||||
$payload = $this->version->create(
|
||||
'POST',
|
||||
$this->uri,
|
||||
array(),
|
||||
$data
|
||||
);
|
||||
|
||||
return new ActivityInstance($this->version, $payload, $this->solution['workspaceSid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ActivityContext
|
||||
*
|
||||
* @param string $sid The sid
|
||||
* @return \Twilio\Rest\Taskrouter\V1\Workspace\ActivityContext
|
||||
*/
|
||||
public function getContext($sid) {
|
||||
return new ActivityContext($this->version, $this->solution['workspaceSid'], $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
* @return string Machine friendly representation
|
||||
*/
|
||||
public function __toString() {
|
||||
return '[Twilio.Taskrouter.V1.ActivityList]';
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue