allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s

This commit is contained in:
2026-03-30 14:54:57 +07:00
parent 66aed7c4e8
commit b5e3a778ce
21316 changed files with 2777892 additions and 13 deletions

View File

@@ -0,0 +1,50 @@
<?php
namespace Twilio;
use Twilio\Exceptions\RestException;
use Twilio\Exceptions\RestExceptionV1;
use Twilio\Exceptions\TwilioException;
use Twilio\Http\Response;
class ApiV1Version extends Version {
protected $apiVersion;
/**
* @param Domain $domain
* @param ?string $version
*/
public function __construct(Domain $domain, ?string $version) {
parent::__construct($domain);
$this->version = $version;
$this->apiVersion = "V1";
}
/**
* Create the best possible exception for the response as per Twilio API Standard V1.
*
* Attempts to parse the response for Twilio Standard error as defined in Twilio API Standards V1
* and use those to populate the exception, falls back to generic error message and
* HTTP status code.
*
* @param Response $response Error response
* @param string $header Header for exception message
* @return TwilioException
*/
protected function exception(Response $response, string $header): TwilioException {
$message = '[HTTP ' . $response->getStatusCode() . '] ' . $header;
$content = $response->getContent();
if (\is_array($content)) {
$message .= isset($content['message']) ? ': ' . $content['message'] : '';
$code = $content['code'] ?? $response->getStatusCode();
$httpStatusCode = $content['httpStatusCode'] ?? $response->getStatusCode();
$params = $content['params'] ?? [];
$userError = $content['userError'] ?? false;
return new RestExceptionV1($code, $message, $httpStatusCode, $params, $userError);
}
return new RestExceptionV1($response->getStatusCode(), $message, $response->getStatusCode());
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Twilio\AuthStrategy;
/**
* Class AuthStrategy
* Abstract parent class for all authentication strategies - Basic, Bearer Token, NoAuth etc.
* @property string $authType The type of authentication strategy
*/
abstract class AuthStrategy {
private $authType;
public function __construct(string $authType) {
$this->authType = $authType;
}
public function getAuthType(): string {
return $this->authType;
}
/**
* Returns the value to be set in the authentication header
*
* @return string the authentication string
*/
abstract public function getAuthString(): string;
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Twilio\AuthStrategy;
/**
* Class BasicAuthStrategy
* Implementation of the AuthStrategy for Basic authentication
* @property string $username
* @property string $password
*/
class BasicAuthStrategy extends AuthStrategy {
private $username;
private $password;
public function __construct(string $username, string $password) {
parent::__construct("basic");
$this->username = $username;
$this->password = $password;
}
/**
* Returns the base64 encoded string concatenating the username and password
*
* @return string the base64 encoded string
*/
public function getAuthString(): string {
return base64_encode($this->username . ':' . $this->password);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Twilio\AuthStrategy;
/**
* Class NoAuthStrategy
* Implementation of the AuthStrategy for No Authentication
*/
class NoAuthStrategy extends AuthStrategy {
public function __construct() {
parent::__construct("noauth");
}
/**
* Returns an empty string since no authentication is required
*
* @return string an empty string
*/
public function getAuthString(): string {
return "";
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace Twilio\AuthStrategy;
use Twilio\Rest\Client;
use Twilio\Http\BearerToken\TokenManager;
/**
* Class TokenAuthStrategy
* Implementation of the AuthStrategy for Bearer Token Authentication
* @property string $token The bearer token
* @property TokenManager $tokenManager The manager for the bearer token
*/
class TokenAuthStrategy extends AuthStrategy {
private $token;
private $tokenManager;
public function __construct(TokenManager $tokenManager) {
parent::__construct("token");
$this->tokenManager = $tokenManager;
}
/**
* Checks if the token is expired or not
*
* @param string $token the token to be checked
*
* @return bool whether the token is expired or not
*/
public function isTokenExpired(string $token): bool {
// Decode the JWT token
$decodedToken = json_decode(base64_decode(str_replace('_', '/', str_replace('-','+',explode('.', $token)[1]))), true);
$expireField = $decodedToken['exp'];
// If the token doesn't have an expiration, consider it expired
if ($decodedToken === null || $expireField === null) {
return false;
}
// Calculate the expiration time with a buffer of 30 seconds
$expiresAt = $expireField * 1000;
$bufferMilliseconds = 30 * 1000;
$bufferExpiresAt = $expiresAt - $bufferMilliseconds;
// Return true if the current time is after the expiration time with buffer
return round(microtime(true)*1000) > $bufferExpiresAt;
}
/**
* Fetches the bearer token
*
* @return string the bearer token
*/
public function fetchToken(?Client $client = null): string {
if (empty($this->token) || $this->isTokenExpired($this->token)) {
$this->token = $this->tokenManager->fetchToken($client);
}
return $this->token;
}
/**
* Returns the bearer token authentication string
*
* @return string the bearer token authentication string
*/
public function getAuthString(?Client $client = null): string {
return "Bearer " . $this->fetchToken($client);
}
}

View File

@@ -0,0 +1,460 @@
<?php
namespace Twilio\Base;
use Twilio\AuthStrategy\AuthStrategy;
use Twilio\CredentialProvider\CredentialProvider;
use Twilio\Exceptions\ConfigurationException;
use Twilio\Exceptions\TwilioException;
use Twilio\Http\Client as HttpClient;
use Twilio\Http\CurlClient;
use Twilio\Rest\Api;
use Twilio\Security\RequestValidator;
use Twilio\VersionInfo;
/**
* @property \Twilio\Rest\Api\V2010\AccountInstance $account
* @property Api $api
*/
class BaseClient
{
const ENV_ACCOUNT_SID = 'TWILIO_ACCOUNT_SID';
const ENV_AUTH_TOKEN = 'TWILIO_AUTH_TOKEN';
const ENV_REGION = 'TWILIO_REGION';
const ENV_EDGE = 'TWILIO_EDGE';
const DEFAULT_REGION = 'us1';
const ENV_LOG = 'TWILIO_LOG_LEVEL';
protected $username;
protected $password;
protected $credentialProvider;
protected $accountSid;
protected $region;
protected $edge;
protected $httpClient;
protected $environment;
protected $userAgentExtensions;
protected $logLevel;
protected $_account;
/**
* 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 'us1' if Edge
* provided
* @param ?HttpClient $httpClient HttpClient, defaults to CurlClient
* @param mixed[] $environment Environment to look for auth details, defaults
* to $_ENV
* @param string[] $userAgentExtensions Additions to the user agent string
*/
public function __construct(
?string $username = null,
?string $password = null,
?string $accountSid = null,
?string $region = null,
?HttpClient $httpClient = null,
?array $environment = null,
?array $userAgentExtensions = null
) {
$this->environment = $environment ?: \getenv();
$this->setUsername($this->getArg($username, self::ENV_ACCOUNT_SID));
$this->setPassword($this->getArg($password, self::ENV_AUTH_TOKEN));
$this->region = $this->getArg($region, self::ENV_REGION);
$this->edge = $this->getArg(null, self::ENV_EDGE);
$this->logLevel = $this->getArg(null, self::ENV_LOG);
$this->userAgentExtensions = $userAgentExtensions ?: [];
$this->invalidateOAuth();
$this->setAccountSid($accountSid ?: $this->username);
if ($httpClient) {
$this->httpClient = $httpClient;
} else {
$this->httpClient = new CurlClient();
}
}
public function setUsername(?string $username): void {
$this->username = $username;
}
public function setPassword(?string $password): void {
$this->password = $password;
}
public function setAccountSid(?string $accountSid): void {
$this->accountSid = $accountSid;
}
private function _setCredentialProvider($credentialProvider): void {
$this->credentialProvider = $credentialProvider;
}
public function setCredentialProvider(CredentialProvider $credentialProvider): void {
$this->_setCredentialProvider($credentialProvider);
$this->invalidateBasicAuth();
}
public function invalidateBasicAuth(): void {
$this->setUsername("");
$this->setPassword("");
}
public function invalidateOAuth(): void {
$this->_setCredentialProvider(null);
}
/**
* Determines argument value accounting for environment variables.
*
* @param ?string $arg The constructor argument
* @param string $envVar The environment variable name
* @return ?string Argument value
*/
public function getArg(?string $arg, string $envVar): ?string
{
if ($arg) {
return $arg;
}
if (\array_key_exists($envVar, $this->environment)) {
return $this->environment[$envVar];
}
return null;
}
/**
* 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
* @param ?AuthStrategy $authStrategy AuthStrategy for Authentication
* @return \Twilio\Http\Response Response from the Twilio API
* @throws TwilioException
*/
public function request(
string $method,
string $uri,
array $params = [],
array $data = [],
array $headers = [],
?string $username = null,
?string $password = null,
?int $timeout = null,
?AuthStrategy $authStrategy = null
): \Twilio\Http\Response{
$username = $username ?: $this->username;
$password = $password ?: $this->password;
$authStrategy = $authStrategy ?: null;
if ($this->credentialProvider) {
$authStrategy = $this->credentialProvider->toAuthStrategy();
}
if( ($this->edge === null && $this->region !== null) || ($this->edge !== null && $this->region === null) )
{
trigger_error(' For regional processing, DNS is of format product.city.region.twilio.com; otherwise use product.twilio.com.', E_USER_DEPRECATED);
}
if ($this->edge === null && $this->region !== null) {
$regionMap = [
'au1' => 'sydney',
'br1' => 'sao-paulo',
'de1' => 'frankfurt',
'ie1' => 'dublin',
'jp1' => 'tokyo',
'jp2' => 'osaka',
'sg1' => 'singapore',
'us1' => 'ashburn',
'us2' => 'umatilla'
];
if (array_key_exists($this->region, $regionMap)) {
trigger_error(' Setting default `Edge` for the provided `region`.', E_USER_DEPRECATED);
$this->edge = $regionMap[$this->region];
}
if( $this->edge === null )
$this->edge = '';
}
if (!$authStrategy) {
if (!$username) {
throw new ConfigurationException('username is required');
}
if (!$password) {
throw new ConfigurationException("password is required");
}
}
$logLevel = (getenv('DEBUG_HTTP_TRAFFIC') === 'true' ? 'debug' : $this->getLogLevel());
$headers['User-Agent'] = 'twilio-php/' . VersionInfo::string() .
' (' . php_uname("s") . ' ' . php_uname("m") . ')' .
' PHP/' . PHP_VERSION;
$headers['Accept-Charset'] = 'utf-8';
if ($this->userAgentExtensions) {
$headers['User-Agent'] .= ' ' . implode(' ', $this->userAgentExtensions);
}
// skip adding Accept header in case of delete operation
if ($method !== "DELETE" && !\array_key_exists('Accept', $headers)) {
$headers['Accept'] = 'application/json';
}
$uri = $this->buildUri($uri);
if ($logLevel === 'debug') {
error_log('-- BEGIN Twilio API Request --');
error_log('Request Method: ' . $method);
$u = parse_url($uri);
if (isset($u['path'])) {
error_log('Request URL: ' . $u['path']);
}
if (isset($u['query']) && strlen($u['query']) > 0) {
error_log('Query Params: ' . $u['query']);
}
error_log('Request Headers: ');
foreach ($headers as $key => $value) {
if (strpos(strtolower($key), 'authorization') === false) {
error_log("$key: $value");
}
}
error_log('-- END Twilio API Request --');
}
$response = $this->getHttpClient()->request(
$method,
$uri,
$params,
$data,
$headers,
$username,
$password,
$timeout,
$authStrategy
);
if ($logLevel === 'debug') {
error_log('Status Code: ' . $response->getStatusCode());
error_log('Response Headers:');
$responseHeaders = $response->getHeaders();
foreach ($responseHeaders as $key => $value) {
error_log("$key: $value");
}
}
return $response;
}
/**
* Build the final request uri
*
* @param string $uri The original request uri
* @return string Request uri
*/
public function buildUri(string $uri): string
{
if ($this->region == null && $this->edge == null) {
return $uri;
}
$parsedUrl = \parse_url($uri);
$pieces = \explode('.', $parsedUrl['host']);
$product = $pieces[0];
$domain = \implode('.', \array_slice($pieces, -2));
$newEdge = $this->edge;
$newRegion = $this->region;
if (count($pieces) == 4) { // product.region.twilio.com
$newRegion = $newRegion ?: $pieces[1];
} elseif (count($pieces) == 5) { // product.edge.region.twilio.com
$newEdge = $newEdge ?: $pieces[1];
$newRegion = $newRegion ?: $pieces[2];
}
if ($newEdge != null && $newRegion == null) {
$newRegion = self::DEFAULT_REGION;
}
$parsedUrl['host'] = \implode('.', \array_filter([$product, $newEdge, $newRegion, $domain]));
return RequestValidator::unparse_url($parsedUrl);
}
/**
* 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(string $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(string $name, array $arguments)
{
$method = 'context' . \ucfirst($name);
if (\method_exists($this, $method)) {
return \call_user_func_array([$this, $method], $arguments);
}
throw new TwilioException('Unknown context ' . $name);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Client ' . $this->getAccountSid() . ']';
}
/**
* Validates connection to new SSL certificate endpoint
*
* @param CurlClient $client
* @throws TwilioException if request fails
*/
public function validateSslCertificate(CurlClient $client): void
{
$response = $client->request('GET', 'https://tls-test.twilio.com:443');
if ($response->getStatusCode() < 200 || $response->getStatusCode() > 300) {
throw new TwilioException('Failed to validate SSL certificate');
}
}
/**
* @return \Twilio\Rest\Api\V2010\AccountContext Account provided as the
* authenticating account
*/
public function getAccount(): \Twilio\Rest\Api\V2010\AccountContext
{
return $this->api->v2010->account;
}
/**
* Retrieve the Username
*
* @return string Current Username
*/
public function getUsername(): string
{
return $this->username;
}
/**
* Retrieve the Password
*
* @return string Current Password
*/
public function getPassword(): string
{
return $this->password;
}
/**
* Retrieve the AccountSid
*
* @return string Current AccountSid
*/
public function getAccountSid(): string
{
return $this->accountSid;
}
/**
* Retrieve the Region
*
* @return string Current Region
*/
public function getRegion(): string
{
return $this->region;
}
/**
* Retrieve the Edge
*
* @return string Current Edge
*/
public function getEdge(): string
{
return $this->edge;
}
/**
* Set Edge
*
* @param ?string $edge Edge to use, unsets the Edge when called with no arguments
*/
public function setEdge(?string $edge = null): void
{
$this->edge = $this->getArg($edge, self::ENV_EDGE);
}
/**
* Retrieve the HttpClient
*
* @return HttpClient Current HttpClient
*/
public function getHttpClient(): HttpClient
{
return $this->httpClient;
}
/**
* Set the HttpClient
*
* @param HttpClient $httpClient HttpClient to use
*/
public function setHttpClient(HttpClient $httpClient): void
{
$this->httpClient = $httpClient;
}
/**
* Retrieve the log level
*
* @return ?string Current log level
*/
public function getLogLevel(): ?string
{
return $this->logLevel;
}
/**
* Set log level to debug
*
* @param ?string $logLevel log level to use
*/
public function setLogLevel(?string $logLevel = null): void
{
$this->logLevel = $this->getArg($logLevel, self::ENV_LOG);
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace Twilio\Base;
use Twilio\Exceptions\TwilioException;
use Twilio\Values;
/**
* @property bool $mms
* @property bool $sms
* @property bool $voice
* @property bool $fax
*/
class PhoneNumberCapabilities
{
protected $mms;
protected $sms;
protected $voice;
protected $fax;
public function __construct(array $capabilities)
{
$this->mms = Values::array_get($capabilities, 'mms', "false");
$this->sms = Values::array_get($capabilities, 'sms', "false");
$this->voice = Values::array_get($capabilities, 'voice', "false");
$this->fax = Values::array_get($capabilities, 'fax', "false");
}
/**
* Access the mms
*/
public function getMms(): bool
{
return $this->mms;
}
/**
* Access the sms
*/
public function getSms(): bool
{
return $this->sms;
}
/**
* Access the voice
*/
public function getVoice(): bool
{
return $this->voice;
}
/**
* Access the fax
*/
public function getFax(): bool
{
return $this->fax;
}
public function __get(string $name)
{
if (\property_exists($this, $name)) {
$method = 'get' . \ucfirst($name);
return $this->$method();
}
throw new TwilioException('Unknown subresource ' . $name);
}
public function __toString(): string
{
return "[Twilio.Base.PhoneNumberCapabilities " .
"(
mms: " . json_encode($this->mms) . ",
sms: " . json_encode($this->sms) . ",
voice: " . json_encode($this->voice) . ",
fax: " . json_encode($this->fax) . "
)]";
}
}

View File

@@ -0,0 +1,93 @@
<?php
namespace Twilio\CredentialProvider;
use Twilio\AuthStrategy\AuthStrategy;
use Twilio\AuthStrategy\TokenAuthStrategy;
use Twilio\Exceptions\TwilioException;
use Twilio\Http\BearerToken\ApiTokenManager;
use Twilio\Http\BearerToken\TokenManager;
/**
* Class ClientCredentialProvider
* Credential provider for OAuth in public apis
*/
class ClientCredentialProvider extends CredentialProvider {
/**
* @var array $options - array of params required for token api
*/
private $options;
/**
* @var TokenManager $tokenManager - handles fetching and refreshing of token
*/
private $tokenManager;
public function __construct() {
parent::__construct("client-credentials");
$this->options = [
"grantType" => "client_credentials",
"clientId" => null,
"clientSecret" => null,
"code" => null,
"redirectUri" =>null,
"audience" => null,
"refreshToken" => null,
"scope" => null
];
}
/**
* @return TokenManager
*/
public function getTokenManager(): TokenManager {
return $this->tokenManager;
}
/**
* @param TokenManager $tokenManager
*/
public function setTokenManager(TokenManager $tokenManager): void {
$this->tokenManager = $tokenManager;
}
/**
* Magic method to get properties - returns the property if it exists in the options array
* @param string $name
* @return mixed value of the property
* @throws TwilioException
*/
public function __get(string $name)
{
if (array_key_exists($name, $this->options)) {
return $this->options[$name];
}
throw new TwilioException('Unknown property ' . $name);
}
/**
* Magic method to set properties - sets the value of the property if it exists in the options array
* @param string $name
* @param $value
* @return void
* @throws TwilioException
*/
public function __set(string $name, $value)
{
if (array_key_exists($name, $this->options)) {
$this->options[$name] = $value;
} else {
throw new TwilioException('Unknown property ' . $name);
}
}
/**
* Returns TokenAuthStrategy using ApiTokenManager
* @return AuthStrategy
*/
public function toAuthStrategy(): AuthStrategy {
if ($this->tokenManager === null) {
$this->tokenManager = new ApiTokenManager($this->options);
}
return new TokenAuthStrategy($this->tokenManager);
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Twilio\CredentialProvider;
use Twilio\Http\BearerToken\TokenManager;
/**
* Class ClientCredentialProviderBuilder
* Builder class for ClientCredentialProvider
*/
class ClientCredentialProviderBuilder {
private $instance;
public function __construct() {
$this->instance = new ClientCredentialProvider();
}
public function setGrantType(string $grantType): ClientCredentialProviderBuilder {
$this->instance->grantType = $grantType;
return $this;
}
public function setClientId(string $clientId): ClientCredentialProviderBuilder {
$this->instance->clientId = $clientId;
return $this;
}
public function setClientSecret(string $clientSecret): ClientCredentialProviderBuilder {
$this->instance->clientSecret = $clientSecret;
return $this;
}
public function setTokenManager(TokenManager $tokenManager): ClientCredentialProviderBuilder {
$this->instance->setTokenManager($tokenManager);
return $this;
}
public function build(): ClientCredentialProvider
{
return $this->instance;
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Twilio\CredentialProvider;
use Twilio\AuthStrategy\AuthStrategy;
/**
* Class CredentialProvider
* Abstract parent class for all credential providers
* @property string $authType The type of authentication
*/
abstract class CredentialProvider {
private $authType;
public function __construct(string $authType) {
$this->authType = $authType;
}
public function getAuthType(): string {
return $this->authType;
}
/**
* Returns the authentication strategy for the credential provider
*
* @return AuthStrategy the authentication strategy for the credential provider
*/
abstract public function toAuthStrategy(): AuthStrategy;
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Twilio\CredentialProvider;
use Twilio\AuthStrategy\AuthStrategy;
use Twilio\AuthStrategy\NoAuthStrategy;
/**
* Class NoAuthCredentialProvider
* Credential provider for no authentication
*/
class NoAuthCredentialProvider extends CredentialProvider {
public function __construct() {
parent::__construct("noauth");
}
/**
* Returns the authentication strategy for the credential provider
*
* @return AuthStrategy the authentication strategy for the credential provider
*/
public function toAuthStrategy(): AuthStrategy {
return new NoAuthStrategy();
}
}

View File

@@ -0,0 +1,93 @@
<?php
namespace Twilio\CredentialProvider;
use Twilio\AuthStrategy\AuthStrategy;
use Twilio\AuthStrategy\TokenAuthStrategy;
use Twilio\Exceptions\TwilioException;
use Twilio\Http\BearerToken\OrgsTokenManager;
use Twilio\Http\BearerToken\TokenManager;
/**
* Class OrgsCredentialProvider
* Credential provider for OAuth in public apis
*/
class OrgsCredentialProvider extends CredentialProvider {
/**
* @var array $options - array of params required for token api
*/
private $options;
/**
* @var TokenManager $tokenManager - handles fetching and refreshing of token
*/
private $tokenManager;
public function __construct() {
parent::__construct("client-credentials");
$this->options = [
"grantType" => "client_credentials",
"clientId" => null,
"clientSecret" => null,
"code" => null,
"redirectUri" =>null,
"audience" => null,
"refreshToken" => null,
"scope" => null
];
}
/**
* @return TokenManager
*/
public function getTokenManager(): TokenManager {
return $this->tokenManager;
}
/**
* @param TokenManager $tokenManager
*/
public function setTokenManager(TokenManager $tokenManager): void {
$this->tokenManager = $tokenManager;
}
/**
* Magic method to get properties - returns the property if it exists in the options array
* @param string $name
* @return mixed value of the property
* @throws TwilioException
*/
public function __get(string $name)
{
if (array_key_exists($name, $this->options)) {
return $this->options[$name];
}
throw new TwilioException('Unknown property ' . $name);
}
/**
* Magic method to set properties - sets the value of the property if it exists in the options array
* @param string $name
* @param $value
* @return void
* @throws TwilioException
*/
public function __set(string $name, $value)
{
if (array_key_exists($name, $this->options)) {
$this->options[$name] = $value;
} else {
throw new TwilioException('Unknown property ' . $name);
}
}
/**
* Returns TokenAuthStrategy using OrgsTokenManager
* @return AuthStrategy
*/
public function toAuthStrategy(): AuthStrategy {
if ($this->tokenManager === null) {
$this->tokenManager = new OrgsTokenManager($this->options);
}
return new TokenAuthStrategy($this->tokenManager);
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Twilio\CredentialProvider;
use Twilio\Http\BearerToken\TokenManager;
/**
* Class OrgsCredentialProviderBuilder
* Builder class for OrgsCredentialProvider
*/
class OrgsCredentialProviderBuilder {
private $instance;
public function __construct() {
$this->instance = new OrgsCredentialProvider();
}
public function setGrantType(string $grantType): OrgsCredentialProviderBuilder {
$this->instance->grantType = $grantType;
return $this;
}
public function setClientId(string $clientId): OrgsCredentialProviderBuilder {
$this->instance->clientId = $clientId;
return $this;
}
public function setClientSecret(string $clientSecret): OrgsCredentialProviderBuilder {
$this->instance->clientSecret = $clientSecret;
return $this;
}
public function setTokenManager(TokenManager $tokenManager): OrgsCredentialProviderBuilder {
$this->instance->setTokenManager($tokenManager);
return $this;
}
public function build(): OrgsCredentialProvider
{
return $this->instance;
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Twilio;
use Twilio\Base\PhoneNumberCapabilities;
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|string DateTime corresponding to the input string, in UTC time.
*/
public static function dateTime(?string $s)
{
try {
if ($s) {
return new \DateTime($s, new \DateTimeZone('UTC'));
}
} catch (\Exception $e) {
// no-op
}
return $s;
}
/**
* Deserialize an array into a PhoneNumberCapabilities object
*
* @param array|null $arr An array
* @return PhoneNumberCapabilities|array PhoneNumberCapabilities object corresponding to the input array.
*/
public static function phoneNumberCapabilities(?array $arr)
{
try {
if ($arr) {
$required = ["mms", "sms", "voice", "fax"];
if (count(array_intersect($required, array_keys($arr))) > 0) {
return new PhoneNumberCapabilities($arr);
}
}
} catch (\Exception $e) {
// no-op
}
return $arr;
}
}

82
vendor/twilio/sdk/src/Twilio/Domain.php vendored Normal file
View File

@@ -0,0 +1,82 @@
<?php
namespace Twilio;
use Twilio\Http\Response;
use Twilio\Rest\Client;
/**
* Class Domain
* Abstracts a Twilio sub domain
* @package Twilio
*/
abstract class Domain {
/**
* @var Client Twilio Client
*/
protected $client;
/**
* @var string Base URL for this domain
*/
protected $baseUrl;
/**
* Construct a new Domain
* @param Client $client used to communicate with Twilio
*/
public function __construct(Client $client) {
$this->client = $client;
$this->baseUrl = '';
}
/**
* Translate version relative URIs into absolute URLs
*
* @param string $uri Version relative URI
* @return string Absolute URL for this domain
*/
public function absoluteUrl(string $uri): string {
return \implode('/', [\trim($this->baseUrl, '/'), \trim($uri, '/')]);
}
/**
* Make an HTTP request to the domain
*
* @param string $method HTTP Method to make the request with
* @param string $uri Relative uri to make a request to
* @param array $params Query string arguments
* @param array $data Post form data
* @param array $headers HTTP headers to send with the request
* @param ?string $user User to authenticate as
* @param ?string $password Password
* @param ?int $timeout Request timeout
* @return Response the response for the request
*/
public function request(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
?string $user = null, ?string $password = null,
?int $timeout = null): Response {
$url = $this->absoluteUrl($uri);
return $this->client->request(
$method,
$url,
$params,
$data,
$headers,
$user,
$password,
$timeout
);
}
public function getClient(): Client {
return $this->client;
}
public function __toString(): string {
return '[Domain]';
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class ConfigurationException extends TwilioException {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class DeserializeException extends TwilioException {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class EnvironmentException extends TwilioException {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class HttpException extends TwilioException {
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Twilio\Exceptions;
/**
* Exception thrown when a required key is missing from a response or metadata.
*
* This exception is typically thrown when the expected 'key' field is not present
* in the response data or metadata, which may indicate a malformed or incomplete response.
*
* Example scenarios:
* - When parsing API responses and the 'key' field is missing.
* - When validating metadata and a required key is not found.
*/
class KeyErrorException extends TwilioException {
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Twilio\Exceptions;
class RestException extends TwilioException {
protected $statusCode;
protected $details;
protected $moreInfo;
/**
* 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.
* @param string $moreInfo [optional] More information about the error.
* @param array $details [optional] Additional details about the error.
* @since 5.1.0
*/
public function __construct(string $message, int $code, int $statusCode, string $moreInfo = '', array $details = []) {
$this->statusCode = $statusCode;
$this->moreInfo = $moreInfo;
$this->details = $details;
parent::__construct($message, $code);
}
/**
* Get the HTTP Status Code of the RestException
* @return int HTTP Status Code
*/
public function getStatusCode(): int {
return $this->statusCode;
}
/**
* Get more information of the RestException
* @return string More error information
*/
public function getMoreInfo(): string {
return $this->moreInfo;
}
/**
* Get the details of the RestException
* @return array details
*/
public function getDetails(): array {
return $this->details;
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Twilio\Exceptions;
class RestExceptionV1 extends TwilioException {
protected $code;
protected $message;
protected $httpStatusCode;
protected $params;
protected $userError;
/**
* Construct the exception.
* @param int $code A unique error code.
* @param string $message A human-readable error message.
* @param int $httpStatusCode The HTTP status code.
* @param array $params [optional] More information about the error.
* @param bool $userError [optional] true if it is an error that depends on the end users actions
*/
public function __construct(int $code, string $message, int $httpStatusCode, array $params = [], bool $userError = false) {
$this->code = $code;
$this->message = $message;
$this->httpStatusCode = $httpStatusCode;
$this->params = $params;
$this->userError = $userError;
parent::__construct($message, $code);
}
/**
* Get the HTTP Status Code of the RestException
* @return int HTTP Status Code
*/
public function getHttpStatusCode(): int {
return $this->httpStatusCode;
}
/**
* Get more information to additional information about the error
* @return array additional information about the error
*/
public function getParams(): array {
return $this->params;
}
/**
* Get the user error flag of the RestException
* @return bool user error flag
*/
public function getUserError(): bool {
return $this->userError;
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class TwilioException extends \Exception {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class TwimlException extends TwilioException {
}

View File

@@ -0,0 +1,53 @@
<?php
namespace Twilio\Http\BearerToken;
use Twilio\CredentialProvider\NoAuthCredentialProvider;
use Twilio\Exceptions\TwilioException;
use Twilio\Rest\Client;
use Twilio\Rest\Oauth\V2;
use Twilio\Rest\Oauth\V2\TokenList;
use Twilio\Rest\OauthBase;
/**
* Class ApiTokenManager
* Token manager class for public OAuth
* @property string $token The bearer token
* @property string $tokenManager The manager for the bearer token
*/
class ApiTokenManager extends TokenManager {
private $options;
public function __construct(array $options = []) {
$this->options = $options;
}
public function getOptions(): array {
return $this->options;
}
/**
* Fetches the bearer token
* @throws TwilioException
*/
public function fetchToken(?Client $client = null): string {
if ($client === null) {
$client = new Client();
}
$noAuthCredentialProvider = new NoAuthCredentialProvider();
$client->setCredentialProvider($noAuthCredentialProvider);
$base = new OauthBase($client);
$v2 = new V2($base);
$tokenList = new TokenList($v2);
try {
return $tokenList->create(
$this->options
)->accessToken;
}
catch (TwilioException $e) {
throw new TwilioException($e->getMessage());
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace Twilio\Http\BearerToken;
use Twilio\CredentialProvider\NoAuthCredentialProvider;
use Twilio\Exceptions\TwilioException;
use Twilio\Rest\Client;
use Twilio\Rest\Oauth\V2;
use Twilio\Rest\Oauth\V2\TokenList;
use Twilio\Rest\OauthBase;
/**
* Class OrgsTokenManager
* Token manager class for public OAuth
* @property string $token The bearer token
* @property string $tokenManager The manager for the bearer token
*/
class OrgsTokenManager extends TokenManager {
private $options;
public function __construct(array $options = []) {
$this->options = $options;
}
public function getOptions(): array {
return $this->options;
}
/**
* Fetches the bearer token
* @throws TwilioException
*/
public function fetchToken(?Client $client = null): string {
if ($client === null) {
$client = new Client();
}
$noAuthCredentialProvider = new NoAuthCredentialProvider();
$client->setCredentialProvider($noAuthCredentialProvider);
$base = new OauthBase($client);
$v2 = new V2($base);
$tokenList = new TokenList($v2);
try {
return $tokenList->create(
$this->options
)->accessToken;
}
catch (TwilioException $e) {
throw new TwilioException($e->getMessage());
}
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Twilio\Http\BearerToken;
use Twilio\Rest\Client;
/**
* Class TokenManager
* Abstract parent class for all token managers
* @property string $token The bearer token
* @property string $tokenManager The manager for the bearer token
*/
abstract class TokenManager {
/**
* Fetches the bearer token
*
* @return string the bearer token
*/
abstract public function fetchToken(?Client $client = null): string;
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Twilio\Http;
use Twilio\AuthStrategy\AuthStrategy;
interface Client {
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
?string $user = null, ?string $password = null,
?int $timeout = null, ?AuthStrategy $authStrategy = null): Response;
}

View File

@@ -0,0 +1,267 @@
<?php
namespace Twilio\Http;
use Twilio\AuthStrategy\AuthStrategy;
use Twilio\Exceptions\ConfigurationException;
use Twilio\Exceptions\EnvironmentException;
class CurlClient implements Client {
public const DEFAULT_TIMEOUT = 60;
protected $curlOptions = [];
public $lastRequest;
public $lastResponse;
public function __construct(array $options = []) {
$this->curlOptions = $options;
}
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
?string $user = null, ?string $password = null,
?int $timeout = null, ?AuthStrategy $authStrategy = null): Response {
$options = $this->options($method, $url, $params, $data, $headers,
$user, $password, $timeout, $authStrategy);
$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) = (
\preg_match('/\AHTTP\/1.\d 100 Continue\Z/', $parts[0])
|| \preg_match('/\AHTTP\/1.\d 200 Connection established\Z/', $parts[0])
|| \preg_match('/\AHTTP\/1.\d 200 Tunnel established\Z/', $parts[0])
)
? array($parts[1], $parts[2])
: array($parts[0], $parts[1]);
$statusCode = \curl_getinfo($curl, CURLINFO_HTTP_CODE);
$responseHeaders = [];
$headerLines = \explode("\r\n", $head);
\array_shift($headerLines);
foreach ($headerLines as $line) {
list($key, $value) = \explode(':', $line, 2);
$responseHeaders[$key] = $value;
}
if (PHP_MAJOR_VERSION < 8) {
\curl_close($curl);
}
if (isset($options[CURLOPT_INFILE]) && \is_resource($options[CURLOPT_INFILE])) {
\fclose($options[CURLOPT_INFILE]);
}
$this->lastResponse = new Response($statusCode, $body, $responseHeaders);
return $this->lastResponse;
} catch (\ErrorException $e) {
if (PHP_MAJOR_VERSION < 8 && isset($curl) && \is_resource($curl)) {
\curl_close($curl);
}
if (isset($options[CURLOPT_INFILE]) && \is_resource($options[CURLOPT_INFILE])) {
\fclose($options[CURLOPT_INFILE]);
}
throw $e;
}
}
public function options(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
?string $user = null, ?string $password = null,
?int $timeout = null, ?AuthStrategy $authStrategy = null): array {
$timeout = $timeout ?? self::DEFAULT_TIMEOUT;
$options = $this->curlOptions + [
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_INFILESIZE => Null,
CURLOPT_HTTPHEADER => [],
CURLOPT_TIMEOUT => $timeout,
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS | CURLPROTO_HTTP
];
foreach ($headers as $key => $value) {
$options[CURLOPT_HTTPHEADER][] = "$key: $value";
}
if ($user && $password) {
$options[CURLOPT_HTTPHEADER][] = 'Authorization: Basic ' . \base64_encode("$user:$password");
}
elseif ($authStrategy) {
$options[CURLOPT_HTTPHEADER][] = 'Authorization: ' . $authStrategy->getAuthString();
}
$query = $this->buildQuery($params);
if ($query) {
$options[CURLOPT_URL] .= '?' . $query;
}
$methodName = \strtolower(\trim($method));
// Configure HTTP method-specific options
if ($methodName === 'get') {
$options[CURLOPT_HTTPGET] = true;
} elseif ($methodName === 'head') {
$options[CURLOPT_NOBODY] = true;
} elseif (\in_array($methodName, ['post', 'put', 'patch'])) {
// Handle methods that send data in the request body
$this->configureMethodWithData($options, $methodName, $method, $data, $headers);
} else {
// Handle other HTTP methods (DELETE, etc.)
$options[CURLOPT_CUSTOMREQUEST] = \strtoupper($method);
}
return $options;
}
/**
* Configure cURL options for HTTP methods that send data in the request body
* (POST, PUT, PATCH)
*/
private function configureMethodWithData(array &$options, string $methodName, string $method, array $data, array $headers): void
{
// Set the appropriate cURL option for the HTTP method
if ($methodName === 'post') {
$options[CURLOPT_POST] = true;
} else {
$options[CURLOPT_CUSTOMREQUEST] = \strtoupper($method);
}
// Configure the request body based on data type
if ($this->hasFile($data)) {
// Handle multipart/form-data for file uploads
[$headers, $body] = $this->buildMultipartOptions($data);
$options[CURLOPT_POSTFIELDS] = $body;
$options[CURLOPT_HTTPHEADER] = \array_merge($options[CURLOPT_HTTPHEADER], $headers);
} elseif (isset($headers['Content-Type']) && $headers['Content-Type'] === 'application/json') {
// Handle JSON data
$options[CURLOPT_POSTFIELDS] = \json_encode($data);
} else {
// Handle URL-encoded form data
$options[CURLOPT_POSTFIELDS] = $this->buildQuery($data);
}
}
public function buildQuery(?array $params): string {
$parts = [];
$params = $params ?: [];
foreach ($params as $key => $value) {
if (\is_array($value)) {
foreach ($value as $item) {
$parts[] = $this->encodeQueryComponent((string)$key) . '=' .
$this->encodeQueryComponent((string)$item);
}
} else {
$parts[] = $this->encodeQueryComponent((string)$key) . '=' .
$this->encodeQueryComponent((string)$value);
}
}
return \implode('&', $parts);
}
/**
* Custom encoder for query string components that:
* 1. Encodes spaces as '+' (like urlencode)
* 2. Preserves unreserved characters including tilde (like rawurlencode)
*/
private function encodeQueryComponent(string $string): string {
// Start with rawurlencode to encode as per RFC 3986
$encoded = \rawurlencode($string);
// Convert %20 back to + for query string compatibility
$encoded = \str_replace('%20', '+', $encoded);
return $encoded;
}
private function hasFile(array $data): bool {
foreach ($data as $value) {
if ($value instanceof File) {
return true;
}
}
return false;
}
private function buildMultipartOptions(array $data): array {
$boundary = \uniqid('', true);
$delimiter = "-------------{$boundary}";
$body = '';
foreach ($data as $key => $value) {
if ($value instanceof File) {
$contents = $value->getContents();
if ($contents === null) {
$chunk = \file_get_contents($value->getFileName());
$filename = \basename($value->getFileName());
} elseif (\is_resource($contents)) {
$chunk = '';
while (!\feof($contents)) {
$chunk .= \fread($contents, 8096);
}
$filename = $value->getFileName();
} elseif (\is_string($contents)) {
$chunk = $contents;
$filename = $value->getFileName();
} else {
throw new \InvalidArgumentException('Unsupported content type');
}
$headers = '';
$contentType = $value->getContentType();
if ($contentType !== null) {
$headers .= "Content-Type: {$contentType}\r\n";
}
$body .= \vsprintf("--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n%s\r\n%s\r\n", [
$delimiter,
$key,
$filename,
$headers,
$chunk,
]);
} else {
$body .= \vsprintf("--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", [
$delimiter,
$key,
$value,
]);
}
}
$body .= "--{$delimiter}--\r\n";
return [
[
"Content-Type: multipart/form-data; boundary={$delimiter}",
'Content-Length: ' . \strlen($body),
],
$body,
];
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Twilio\Http;
final class File {
/**
* @var string
*/
private $fileName;
/**
* @var resource|string|mixed|null
*/
private $contents;
/**
* @var string|null
*/
private $contentType;
/**
* @param string $fileName full file path or file name for passed $contents
* @param string|resource|mixed|null $contents
* @param ?string $contentType
*/
public function __construct(string $fileName, $contents = null, ?string $contentType = null) {
$this->fileName = $fileName;
$this->contents = $contents;
$this->contentType = $contentType;
}
/**
* @return resource|string|mixed|null
*/
public function getContents() {
return $this->contents;
}
public function getFileName(): string {
return $this->fileName;
}
public function getContentType(): ?string {
return $this->contentType;
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace Twilio\Http;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Psr7\Query;
use GuzzleHttp\Psr7\Request;
use Twilio\Exceptions\HttpException;
use Twilio\AuthStrategy\AuthStrategy;
final class GuzzleClient implements Client {
/**
* @var ClientInterface
*/
private $client;
public function __construct(ClientInterface $client) {
$this->client = $client;
}
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
?string $user = null, ?string $password = null,
?int $timeout = null, ?AuthStrategy $authStrategy = null): Response {
try {
$options = [
'timeout' => $timeout,
'allow_redirects' => false,
];
if($user && $password) {
$headers['Authorization'] = 'Basic ' . base64_encode($user . ':' . $password);
}
elseif ($authStrategy) {
$headers['Authorization'] = $authStrategy->getAuthString();
}
if ($params) {
$options['query'] = Query::build($params, PHP_QUERY_RFC1738);
}
if ($method === 'POST' || $method === 'PUT') {
if ($this->hasFile($data)) {
$options['multipart'] = $this->buildMultipartParam($data);
} else {
$options['body'] = Query::build($data, PHP_QUERY_RFC1738);
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
}
$response = $this->client->send(new Request($method, $url, $headers), $options);
} catch (BadResponseException $exception) {
$response = $exception->getResponse();
} catch (\Exception $exception) {
throw new HttpException('Unable to complete the HTTP request', 0, $exception);
}
// Casting the body (stream) to a string performs a rewind, ensuring we return the entire response.
// See https://stackoverflow.com/a/30549372/86696
return new Response($response->getStatusCode(), (string)$response->getBody(), $response->getHeaders());
}
private function hasFile(array $data): bool {
foreach ($data as $value) {
if ($value instanceof File) {
return true;
}
}
return false;
}
private function buildMultipartParam(array $data): array {
$multipart = [];
foreach ($data as $key => $value) {
if ($value instanceof File) {
$contents = $value->getContents();
if ($contents === null) {
$contents = fopen($value->getFileName(), 'rb');
}
$chunk = [
'name' => $key,
'contents' => $contents,
'filename' => $value->getFileName(),
];
if ($value->getContentType() !== null) {
$chunk['headers']['Content-Type'] = $value->getContentType();
}
} else {
$chunk = [
'name' => $key,
'contents' => $value,
];
}
$multipart[] = $chunk;
}
return $multipart;
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Twilio\Http;
class Response {
protected $headers;
protected $content;
protected $statusCode;
public function __construct(int $statusCode, ?string $content, ?array $headers = []) {
$this->statusCode = $statusCode;
$this->content = $content;
$this->headers = $headers;
}
/**
* @return mixed
*/
public function getContent() {
return \json_decode($this->content, true);
}
public function getStatusCode(): int {
return $this->statusCode;
}
public function getHeaders(): array {
return $this->headers;
}
public function ok(): bool {
return $this->getStatusCode() < 400;
}
public function __toString(): string {
return '[Response] HTTP ' . $this->getStatusCode() . ' ' . $this->content;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Twilio;
class InstanceContext {
protected $version;
protected $solution = [];
protected $uri;
public function __construct(Version $version) {
$this->version = $version;
}
public function __toString(): string {
return '[InstanceContext]';
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Twilio;
class InstanceResource {
protected $version;
protected $context;
protected $properties = [];
protected $solution = [];
public function __construct(Version $version) {
$this->version = $version;
}
public function toArray(): array {
return $this->properties;
}
public function __toString(): string {
return '[InstanceResource]';
}
public function __isset($name): bool {
return \array_key_exists($name, $this->properties);
}
}

View File

@@ -0,0 +1,169 @@
<?php
namespace Twilio\Jwt;
use Twilio\Jwt\Grants\Grant;
class AccessToken {
private $signingKeySid;
private $accountSid;
private $secret;
private $ttl;
private $identity;
private $nbf;
private $region;
/** @var Grant[] $grants */
private $grants;
/** @var string[] $customClaims */
private $customClaims;
public function __construct(string $accountSid, string $signingKeySid, string $secret, int $ttl = 3600, ?string $identity = null, ?string $region = null) {
$this->signingKeySid = $signingKeySid;
$this->accountSid = $accountSid;
$this->secret = $secret;
$this->ttl = $ttl;
$this->region = $region;
if ($identity !== null) {
$this->identity = $identity;
}
$this->grants = [];
$this->customClaims = [];
}
/**
* Set the identity of this access token
*
* @param string $identity identity of the grant
*
* @return $this updated access token
*/
public function setIdentity(string $identity): self {
$this->identity = $identity;
return $this;
}
/**
* Returns the identity of the grant
*
* @return string the identity
*/
public function getIdentity(): string {
return $this->identity;
}
/**
* Set the nbf of this access token
*
* @param int $nbf nbf in epoch seconds of the grant
*
* @return $this updated access token
*/
public function setNbf(int $nbf): self {
$this->nbf = $nbf;
return $this;
}
/**
* Returns the nbf of the grant
*
* @return int the nbf in epoch seconds
*/
public function getNbf(): int {
return $this->nbf;
}
/**
* Set the region of this access token
*
* @param string $region Home region of the account sid in this access token
*
* @return $this updated access token
*/
public function setRegion(string $region): self {
$this->region = $region;
return $this;
}
/**
* Returns the region of this access token
*
* @return string Home region of the account sid in this access token
*/
public function getRegion(): string {
return $this->region;
}
/**
* Add a grant to the access token
*
* @param Grant $grant to be added
*
* @return $this the updated access token
*/
public function addGrant(Grant $grant): self {
$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(string $name, string $value): void {
$this->customClaims[$name] = $value;
}
public function toJWT(string $algorithm = 'HS256'): string {
$header = [
'cty' => 'twilio-fpa;v=1',
'typ' => 'JWT'
];
if ($this->region) {
$header['twr'] = $this->region;
}
$now = \time();
$grants = [];
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, [
'jti' => $this->signingKeySid . '-' . $now,
'iss' => $this->signingKeySid,
'sub' => $this->accountSid,
'exp' => $now + $this->ttl,
'grants' => $grants
]);
if ($this->nbf !== null) {
$payload['nbf'] = $this->nbf;
}
return JWT::encode($payload, $this->secret, $algorithm, $header);
}
public function __toString(): string {
return $this->toJWT();
}
}

View File

@@ -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(string $service, string $privilege, array $params = []) {
$this->service = $service;
$this->privilege = $privilege;
$this->params = $params;
}
public function toString(): string {
$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(string $uri): ScopeURI {
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');
}
[$scheme, $service, $privilege] = $parts;
return new ScopeURI($service, $privilege, $params);
}
}

View File

@@ -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;
public $clientName;
/** @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(string $accountSid, string $authToken) {
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->scopes = [];
$this->clientName = false;
$this->customClaims = [];
}
/**
* 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 string $clientName
* @throws \InvalidArgumentException
*/
public function allowClientIncoming(string $clientName): void {
// 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 ($clientName === '') {
throw new \InvalidArgumentException(
'Client name must not be a zero length string.');
}
$this->clientName = $clientName;
$this->allow('client', 'incoming', ['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(string $appSid, array $appParams = []): void {
$this->allow('client', 'outgoing', [
'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 = []): void {
$this->allow('stream', 'subscribe', [
'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(string $name, string $value): void {
$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 string the newly generated token that is valid for $ttl seconds
*/
public function generateToken(int $ttl = 3600): string {
$payload = \array_merge($this->customClaims, [
'scope' => [],
'iss' => $this->accountSid,
'exp' => \time() + $ttl,
]);
$scopeStrings = [];
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(string $service, string $privilege, array $params): void {
$this->scopes[] = new ScopeURI($service, $privilege, $params);
}
}

View File

@@ -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(): string {
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(string $serviceSid): self {
$this->serviceSid = $serviceSid;
return $this;
}
/**
* Returns the endpoint id of the grant
*
* @return string the endpoint id
*/
public function getEndpointId(): string {
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(string $endpointId): self {
$this->endpointId = $endpointId;
return $this;
}
/**
* Returns the deployment role sid of the grant
*
* @return string the deployment role sid
*/
public function getDeploymentRoleSid(): string {
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(string $deploymentRoleSid): self {
$this->deploymentRoleSid = $deploymentRoleSid;
return $this;
}
/**
* Returns the push credential sid of the grant
*
* @return string the push credential sid
*/
public function getPushCredentialSid(): string {
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(string $pushCredentialSid): self {
$this->pushCredentialSid = $pushCredentialSid;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'chat';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
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;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Twilio\Jwt\Grants;
interface Grant {
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string;
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array;
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Twilio\Jwt\Grants;
class PlaybackGrant implements Grant {
private $grant;
/**
* Returns the grant
*
* @return array playback grant from the Twilio API
*/
public function getGrant(): array {
return $this->grant;
}
/**
* Set the playback grant that will allow access to a stream
*
* @param array $grant playback grant from Twilio API
* @return $this updated grant
*/
public function setGrant(array $grant): self {
$this->grant = $grant;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'player';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->grant) {
$payload = $this->grant;
}
return $payload;
}
}

View File

@@ -0,0 +1,126 @@
<?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(): string {
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(string $serviceSid): self {
$this->serviceSid = $serviceSid;
return $this;
}
/**
* Returns the endpoint id of the grant
*
* @return string the endpoint id
*/
public function getEndpointId(): string {
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(string $endpointId): self {
$this->endpointId = $endpointId;
return $this;
}
/**
* Returns the deployment role sid of the grant
*
* @return string the deployment role sid
*/
public function getDeploymentRoleSid(): string {
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(string $deploymentRoleSid): self {
$this->deploymentRoleSid = $deploymentRoleSid;
return $this;
}
/**
* Returns the push credential sid of the grant
*
* @return string the push credential sid
*/
public function getPushCredentialSid(): string {
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(string $pushCredentialSid): self {
$this->pushCredentialSid = $pushCredentialSid;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'data_sync';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
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;
}
}

View File

@@ -0,0 +1,101 @@
<?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(): string {
return $this->workspaceSid;
}
/**
* Set the workspace sid of this grant
*
* @param string $workspaceSid workspace sid of the grant
*
* @return $this updated grant
*/
public function setWorkspaceSid(string $workspaceSid): self {
$this->workspaceSid = $workspaceSid;
return $this;
}
/**
* Returns the worker sid
*
* @return string the worker sid
*/
public function getWorkerSid(): string {
return $this->workerSid;
}
/**
* Set the worker sid of this grant
*
* @param string $workerSid worker sid of the grant
*
* @return $this updated grant
*/
public function setWorkerSid(string $workerSid): self {
$this->workerSid = $workerSid;
return $this;
}
/**
* Returns the role
*
* @return string the role
*/
public function getRole(): string {
return $this->role;
}
/**
* Set the role of this grant
*
* @param string $role role of the grant
*
* @return $this updated grant
*/
public function setRole(string $role): self {
$this->role = $role;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'task_router';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
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;
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Twilio\Jwt\Grants;
class VideoGrant implements Grant {
private $room;
/**
* Returns the room
*
* @return string room name or sid set in this grant
*/
public function getRoom(): string {
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(string $roomSidOrName): self {
$this->room = $roomSidOrName;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'video';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->room) {
$payload['room'] = $this->room;
}
return $payload;
}
}

View File

@@ -0,0 +1,165 @@
<?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 bool whether incoming is allowed
*/
public function getIncomingAllow(): bool {
return $this->incomingAllow;
}
/**
* Set whether incoming is allowed
*
* @param bool $incomingAllow whether incoming is allowed
*
* @return $this updated grant
*/
public function setIncomingAllow(bool $incomingAllow): self {
$this->incomingAllow = $incomingAllow;
return $this;
}
/**
* Returns the outgoing application sid
*
* @return string the outgoing application sid
*/
public function getOutgoingApplicationSid(): string {
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(string $outgoingApplicationSid): self {
$this->outgoingApplicationSid = $outgoingApplicationSid;
return $this;
}
/**
* Returns the outgoing application params
*
* @return array the outgoing application params
*/
public function getOutgoingApplicationParams(): array {
return $this->outgoingApplicationParams;
}
/**
* Set the outgoing application of the the grant
*
* @param string $sid outgoing application sid of the grant
* @param array $params params to pass the the application
*
* @return $this updated grant
*/
public function setOutgoingApplication(string $sid, array $params): self {
$this->outgoingApplicationSid = $sid;
$this->outgoingApplicationParams = $params;
return $this;
}
/**
* Returns the push credential sid
*
* @return string the push credential sid
*/
public function getPushCredentialSid(): string {
return $this->pushCredentialSid;
}
/**
* Set the push credential sid
*
* @param string $pushCredentialSid
*
* @return $this updated grant
*/
public function setPushCredentialSid(string $pushCredentialSid): self {
$this->pushCredentialSid = $pushCredentialSid;
return $this;
}
/**
* Returns the endpoint id
*
* @return string the endpoint id
*/
public function getEndpointId(): string {
return $this->endpointId;
}
/**
* Set the endpoint id
*
* @param string $endpointId endpoint id
*
* @return $this updated grant
*/
public function setEndpointId(string $endpointId): self {
$this->endpointId = $endpointId;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'voice';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->incomingAllow === true) {
$incoming = [];
$incoming['allow'] = true;
$payload['incoming'] = $incoming;
}
if ($this->outgoingApplicationSid) {
$outgoing = [];
$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;
}
}

172
vendor/twilio/sdk/src/Twilio/Jwt/JWT.php vendored Normal file
View File

@@ -0,0 +1,172 @@
<?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(string $jwt, ?string $key = null, bool $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 (!hash_equals($sig, self::sign("$headb64.$payloadb64", $key, $header->alg))) {
throw new \UnexpectedValueException('Signature verification failed');
}
}
return $payload;
}
/**
* @param string $jwt The JWT
* @return object The JWT's header as a PHP object
* @throws \UnexpectedValueException
*/
public static function getHeader(string $jwt) {
$tks = \explode('.', $jwt);
if (\count($tks) !== 3) {
throw new \UnexpectedValueException('Wrong number of segments');
}
list($headb64) = $tks;
if (null === ($header = self::jsonDecode(self::urlsafeB64Decode($headb64)))
) {
throw new \UnexpectedValueException('Invalid segment encoding');
}
return $header;
}
/**
* @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, string $key, string $algo = 'HS256', array $additionalHeaders = []): string {
$header = ['typ' => 'JWT', 'alg' => $algo];
$header += $additionalHeaders;
$segments = [];
$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(string $msg, string $key, string $method = 'HS256'): string {
$methods = [
'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(string $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): string {
$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(string $input): string {
$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(string $input): string {
return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
}
/**
* @param int $errno An error number from json_last_error()
*
* @throws \DomainException
*/
private static function handleJsonError(int $errno): void {
$messages = [
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($messages[$errno] ?? 'Unknown JSON error: ' . $errno);
}
}

View File

@@ -0,0 +1,161 @@
<?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 = ['required' => true];
protected $optional = ['required' => false];
public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $channelId,
?string $resourceUrl = null, ?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->friendlyName = $channelId;
$this->policies = [];
$this->workspaceSid = $workspaceSid;
$this->channelId = $channelId;
if (isset($overrideBaseUrl)) {
$this->baseUrl = $overrideBaseUrl;
}
if (isset($overrideBaseWSUrl)) {
$this->baseWsUrl = $overrideBaseWSUrl;
}
$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(): void {
}
public function addPolicyDeconstructed(string $url, string $method, ?array $queryFilter = [], ?array $postFilter = [], bool $allow = true): Policy {
$policy = new Policy($url, $method, $queryFilter, $postFilter, $allow);
$this->policies[] = $policy;
return $policy;
}
public function allow(string $url, string $method, ?array $queryFilter = [], ?array $postFilter = []): void {
$this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, true);
}
public function deny(string $url, string $method, array $queryFilter = [], array $postFilter = []): void {
$this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, false);
}
private function validateJWT(): void {
if (!isset($this->accountSid) || \strpos($this->accountSid, 'AC') !== 0) {
throw new \Exception('Invalid AccountSid provided: ' . $this->accountSid);
}
if (!isset($this->workspaceSid) || \strpos($this->workspaceSid, 'WS') !== 0) {
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(): void {
$method = 'GET';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
}
public function allowUpdates(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
}
public function allowUpdatesSubresources(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
}
public function allowDelete(): void {
$method = 'DELETE';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
}
public function allowDeleteSubresources(): void {
$method = 'DELETE';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
}
public function generateToken(int $ttl = 3600, array $extraAttributes = []): string {
$payload = [
'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 (\strpos($this->channelId, 'WK') === 0) {
$payload['worker_sid'] = $this->channelId;
} else if (\strpos($this->channelId, 'WQ') === 0) {
$payload['taskqueue_sid'] = $this->channelId;
}
foreach ($extraAttributes as $key => $value) {
$payload[$key] = $value;
}
$policyStrings = [];
foreach ($this->policies as $policy) {
$policyStrings[] = $policy->toArray();
}
$payload['policies'] = $policyStrings;
return JWT::encode($payload, $this->authToken, 'HS256');
}
}

View File

@@ -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(string $url, string $method, ?array $queryFilter = [], ?array $postFilter = [], bool $allow = true) {
$this->url = $url;
$this->method = $method;
$this->queryFilter = $queryFilter;
$this->postFilter = $postFilter;
$this->allow = $allow;
}
public function addQueryFilter($queryFilter): void {
$this->queryFilter[] = $queryFilter;
}
public function addPostFilter($postFilter): void {
$this->postFilter[] = $postFilter;
}
public function toArray(): array {
$policy_array = ['url' => $this->url, 'method' => $this->method, 'allow' => $this->allow];
if ($this->queryFilter !== null) {
if (\count($this->queryFilter) > 0) {
$policy_array['query_filter'] = $this->queryFilter;
} else {
$policy_array['query_filter'] = new \stdClass();
}
}
if ($this->postFilter !== null) {
if (\count($this->postFilter) > 0) {
$policy_array['post_filter'] = $this->postFilter;
} else {
$policy_array['post_filter'] = new \stdClass();
}
}
return $policy_array;
}
}

View File

@@ -0,0 +1,21 @@
<?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(string $accountSid, string $authToken, string $workspaceSid, string $taskQueueSid,
?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
}
protected function setupResource(): void {
$this->resourceUrl = $this->baseUrl . '/TaskQueues/' . $this->channelId;
}
}

View File

@@ -0,0 +1,49 @@
<?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(string $accountSid, string $authToken, string $workspaceSid, string $workerSid,
?string $overrideBaseUrl = null, ?string $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(): void {
$this->resourceUrl = $this->baseUrl . '/Workers/' . $this->channelId;
}
public function allowActivityUpdates(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = ['ActivitySid' => $this->required];
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
}
public function allowReservationUpdates(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = [];
$this->allow($this->tasksUrl, $method, $queryFilter, $postFilter);
$this->allow($this->workerReservationsUrl, $method, $queryFilter, $postFilter);
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Twilio\Jwt\TaskRouter;
class WorkspaceCapability extends CapabilityToken {
public function __construct(string $accountSid, string $authToken, string $workspaceSid,
?string $overrideBaseUrl = null, ?string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $workspaceSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
}
protected function setupResource(): void {
$this->resourceUrl = $this->baseUrl;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Twilio;
class ListResource {
protected $version;
protected $solution = [];
protected $uri;
public function __construct(Version $version) {
$this->version = $version;
}
public function __toString(): string {
return '[ListResource]';
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Twilio;
abstract class Options implements \IteratorAggregate {
protected $options = [];
public function getIterator(): \Traversable {
return new \ArrayIterator($this->options);
}
}

203
vendor/twilio/sdk/src/Twilio/Page.php vendored Normal file
View File

@@ -0,0 +1,203 @@
<?php
namespace Twilio;
use Twilio\Exceptions\DeserializeException;
use Twilio\Exceptions\RestException;
use Twilio\Http\Response;
abstract class Page implements \Iterator {
protected static $metaKeys = [
'end',
'first_page_uri',
'next_page_uri',
'last_page_uri',
'page',
'page_size',
'previous_page_uri',
'total',
'num_pages',
'start',
'uri',
'totalResults',
'schemas'
];
protected $version;
protected $payload;
protected $solution;
protected $records;
abstract public function buildInstance(array $payload);
public function __construct(Version $version, Response $response) {
$payload = $this->processResponse($response);
$this->version = $version;
$this->payload = $payload;
$this->solution = [];
$this->records = new \ArrayIterator($this->loadPage());
}
protected function processResponse(Response $response) {
if ($response->getStatusCode() !== 200 && !$this->isPagingEol($response->getContent())) {
$message = '[HTTP ' . $response->getStatusCode() . '] Unable to fetch page';
$code = $response->getStatusCode();
$content = $response->getContent();
$details = [];
$moreInfo = '';
if (\is_array($content)) {
$message .= isset($content['message']) ? ': ' . $content['message'] : '';
$code = $content['code'] ?? $code;
$moreInfo = $content['more_info'] ?? '';
$details = $content['details'] ?? [] ;
}
throw new RestException($message, $code, $response->getStatusCode(), $moreInfo, $details);
}
return $response->getContent();
}
protected function isPagingEol(?array $content): bool {
return $content !== null && \array_key_exists('code', $content) && $content['code'] === 20006;
}
protected function hasMeta(string $key): bool {
return \array_key_exists('meta', $this->payload) && \array_key_exists($key, $this->payload['meta']);
}
protected function getMeta(string $key, ?string $default = null): ?string {
return $this->hasMeta($key) ? $this->payload['meta'][$key] : $default;
}
protected function loadPage(): array {
$key = $this->getMeta('key');
if ($key) {
return $this->payload[$key];
}
$keys = \array_keys($this->payload);
$key = \array_diff($keys, self::$metaKeys);
$key = \array_values($key);
if (\count($key) === 1) {
return $this->payload[$key[0]];
}
// handle end of results error code
if ($this->isPagingEol($this->payload)) {
return [];
}
throw new DeserializeException('Page Records can not be deserialized');
}
public function getPreviousPageUrl(): ?string {
if ($this->hasMeta('previous_page_url')) {
return $this->getMeta('previous_page_url');
}
if (\array_key_exists('previous_page_uri', $this->payload) && $this->payload['previous_page_uri']) {
return $this->getVersion()->getDomain()->absoluteUrl($this->payload['previous_page_uri']);
}
return null;
}
public function getNextPageUrl(): ?string {
if ($this->hasMeta('next_page_url')) {
return $this->getMeta('next_page_url');
}
if (\array_key_exists('next_page_uri', $this->payload) && $this->payload['next_page_uri']) {
return $this->getVersion()->getDomain()->absoluteUrl($this->payload['next_page_uri']);
}
return null;
}
public function nextPage(): ?Page {
if (!$this->getNextPageUrl()) {
return null;
}
$response = $this->getVersion()->getDomain()->getClient()->request('GET', $this->getNextPageUrl());
return new static($this->getVersion(), $response, $this->solution);
}
public function previousPage(): ?Page {
if (!$this->getPreviousPageUrl()) {
return null;
}
$response = $this->getVersion()->getDomain()->getClient()->request('GET', $this->getPreviousPageUrl());
return new static($this->getVersion(), $response, $this->solution);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
*/
#[\ReturnTypeWillChange]
public function current() {
return $this->buildInstance($this->records->current());
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
*/
public function next(): void {
$this->records->next();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
#[\ReturnTypeWillChange]
public function key() {
return $this->records->key();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return bool The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
public function valid(): bool {
return $this->records->valid();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
public function rewind(): void {
$this->records->rewind();
}
public function getVersion(): Version {
return $this->version;
}
public function __toString(): string {
return '[Page]';
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Twilio\Rest;
use Twilio\Rest\Accounts\V1;
class Accounts extends AccountsBase {
/**
* @deprecated Use v1->authTokenPromotion instead
*/
protected function getAuthTokenPromotion(): \Twilio\Rest\Accounts\V1\AuthTokenPromotionList {
echo "authTokenPromotion is deprecated. Use v1->authTokenPromotion instead.";
return $this->v1->authTokenPromotion;
}
/**
* @deprecated Use v1->authTokenPromotion() instead.
*/
protected function contextAuthTokenPromotion(): \Twilio\Rest\Accounts\V1\AuthTokenPromotionContext {
echo "authTokenPromotion() is deprecated. Use v1->authTokenPromotion() instead.";
return $this->v1->authTokenPromotion();
}
/**
* @deprecated Use v1->credentials instead.
*/
protected function getCredentials(): \Twilio\Rest\Accounts\V1\CredentialList {
echo "credentials is deprecated. Use v1->credentials instead.";
return $this->v1->credentials;
}
/**
* @deprecated Use v1->secondaryAuthToken instead.
*/
protected function getSecondaryAuthToken(): \Twilio\Rest\Accounts\V1\SecondaryAuthTokenList {
echo "secondaryAuthToken is deprecated. Use v1->secondaryAuthToken instead.";
return $this->v1->secondaryAuthToken;
}
/**
* @deprecated Use v1->secondaryAuthToken() instead.
*/
protected function contextSecondaryAuthToken(): \Twilio\Rest\Accounts\V1\SecondaryAuthTokenContext {
echo "secondaryAuthToken() is deprecated. Use v1->secondaryAuthToken() instead.";
return $this->v1->secondaryAuthToken();
}
}

View File

@@ -0,0 +1,160 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\Accounts\V1\AuthTokenPromotionList;
use Twilio\Rest\Accounts\V1\BulkConsentsList;
use Twilio\Rest\Accounts\V1\BulkContactsList;
use Twilio\Rest\Accounts\V1\CredentialList;
use Twilio\Rest\Accounts\V1\MessagingGeopermissionsList;
use Twilio\Rest\Accounts\V1\SafelistList;
use Twilio\Rest\Accounts\V1\SecondaryAuthTokenList;
use Twilio\Version;
/**
* @property AuthTokenPromotionList $authTokenPromotion
* @property BulkConsentsList $bulkConsents
* @property BulkContactsList $bulkContacts
* @property CredentialList $credentials
* @property MessagingGeopermissionsList $messagingGeopermissions
* @property SafelistList $safelist
* @property SecondaryAuthTokenList $secondaryAuthToken
*/
class V1 extends Version
{
protected $_authTokenPromotion;
protected $_bulkConsents;
protected $_bulkContacts;
protected $_credentials;
protected $_messagingGeopermissions;
protected $_safelist;
protected $_secondaryAuthToken;
/**
* Construct the V1 version of Accounts
*
* @param Domain $domain Domain that contains the version
*/
public function __construct(Domain $domain)
{
parent::__construct($domain);
$this->version = 'v1';
}
protected function getAuthTokenPromotion(): AuthTokenPromotionList
{
if (!$this->_authTokenPromotion) {
$this->_authTokenPromotion = new AuthTokenPromotionList($this);
}
return $this->_authTokenPromotion;
}
protected function getBulkConsents(): BulkConsentsList
{
if (!$this->_bulkConsents) {
$this->_bulkConsents = new BulkConsentsList($this);
}
return $this->_bulkConsents;
}
protected function getBulkContacts(): BulkContactsList
{
if (!$this->_bulkContacts) {
$this->_bulkContacts = new BulkContactsList($this);
}
return $this->_bulkContacts;
}
protected function getCredentials(): CredentialList
{
if (!$this->_credentials) {
$this->_credentials = new CredentialList($this);
}
return $this->_credentials;
}
protected function getMessagingGeopermissions(): MessagingGeopermissionsList
{
if (!$this->_messagingGeopermissions) {
$this->_messagingGeopermissions = new MessagingGeopermissionsList($this);
}
return $this->_messagingGeopermissions;
}
protected function getSafelist(): SafelistList
{
if (!$this->_safelist) {
$this->_safelist = new SafelistList($this);
}
return $this->_safelist;
}
protected function getSecondaryAuthToken(): SecondaryAuthTokenList
{
if (!$this->_secondaryAuthToken) {
$this->_secondaryAuthToken = new SecondaryAuthTokenList($this);
}
return $this->_secondaryAuthToken;
}
/**
* Magic getter to lazy load root resources
*
* @param string $name Resource to return
* @return \Twilio\ListResource The requested resource
* @throws TwilioException For unknown resource
*/
public function __get(string $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 InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments): InstanceContext
{
$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(): string
{
return '[Twilio.Accounts.V1]';
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
class AuthTokenPromotionContext extends InstanceContext
{
/**
* Initialize the AuthTokenPromotionContext
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/AuthTokens/Promote';
}
/**
* Update the AuthTokenPromotionInstance
*
* @return AuthTokenPromotionInstance Updated AuthTokenPromotionInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(): AuthTokenPromotionInstance
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->update('POST', $this->uri, [], [], $headers);
return new AuthTokenPromotionInstance(
$this->version,
$payload
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AuthTokenPromotionContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,122 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Deserialize;
/**
* @property string|null $accountSid
* @property string|null $authToken
* @property \DateTime|null $dateCreated
* @property \DateTime|null $dateUpdated
* @property string|null $url
*/
class AuthTokenPromotionInstance extends InstanceResource
{
/**
* Initialize the AuthTokenPromotionInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'authToken' => Values::array_get($payload, 'auth_token'),
'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 = [];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return AuthTokenPromotionContext Context for this AuthTokenPromotionInstance
*/
protected function proxy(): AuthTokenPromotionContext
{
if (!$this->context) {
$this->context = new AuthTokenPromotionContext(
$this->version
);
}
return $this->context;
}
/**
* Update the AuthTokenPromotionInstance
*
* @return AuthTokenPromotionInstance Updated AuthTokenPromotionInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(): AuthTokenPromotionInstance
{
return $this->proxy()->update();
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AuthTokenPromotionInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\ListResource;
use Twilio\Version;
class AuthTokenPromotionList extends ListResource
{
/**
* Construct the AuthTokenPromotionList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
}
/**
* Constructs a AuthTokenPromotionContext
*/
public function getContext(
): AuthTokenPromotionContext
{
return new AuthTokenPromotionContext(
$this->version
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.AuthTokenPromotionList]';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class AuthTokenPromotionPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return AuthTokenPromotionInstance \Twilio\Rest\Accounts\V1\AuthTokenPromotionInstance
*/
public function buildInstance(array $payload): AuthTokenPromotionInstance
{
return new AuthTokenPromotionInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.AuthTokenPromotionPage]';
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property array|null $items
*/
class BulkConsentsInstance extends InstanceResource
{
/**
* Initialize the BulkConsentsInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'items' => Values::array_get($payload, 'items'),
];
$this->solution = [];
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
return '[Twilio.Accounts.V1.BulkConsentsInstance]';
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Serialize;
class BulkConsentsList extends ListResource
{
/**
* Construct the BulkConsentsList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/Consents/Bulk';
}
/**
* Create the BulkConsentsInstance
*
* @param array[] $items This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty.
* @return BulkConsentsInstance Created BulkConsentsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $items): BulkConsentsInstance
{
$data = Values::of([
'Items' =>
Serialize::map($items,function ($e) { return Serialize::jsonObject($e); }),
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return new BulkConsentsInstance(
$this->version,
$payload
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.BulkConsentsList]';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class BulkConsentsPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return BulkConsentsInstance \Twilio\Rest\Accounts\V1\BulkConsentsInstance
*/
public function buildInstance(array $payload): BulkConsentsInstance
{
return new BulkConsentsInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.BulkConsentsPage]';
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property array|null $items
*/
class BulkContactsInstance extends InstanceResource
{
/**
* Initialize the BulkContactsInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'items' => Values::array_get($payload, 'items'),
];
$this->solution = [];
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
return '[Twilio.Accounts.V1.BulkContactsInstance]';
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Serialize;
class BulkContactsList extends ListResource
{
/**
* Construct the BulkContactsList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/Contacts/Bulk';
}
/**
* Create the BulkContactsInstance
*
* @param array[] $items A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code.
* @return BulkContactsInstance Created BulkContactsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $items): BulkContactsInstance
{
$data = Values::of([
'Items' =>
Serialize::map($items,function ($e) { return Serialize::jsonObject($e); }),
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return new BulkContactsInstance(
$this->version,
$payload
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.BulkContactsList]';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class BulkContactsPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return BulkContactsInstance \Twilio\Rest\Accounts\V1\BulkContactsInstance
*/
public function buildInstance(array $payload): BulkContactsInstance
{
return new BulkContactsInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.BulkContactsPage]';
}
}

View File

@@ -0,0 +1,126 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
class AwsContext extends InstanceContext
{
/**
* Initialize the AwsContext
*
* @param Version $version Version that contains the resource
* @param string $sid The Twilio-provided string that uniquely identifies the AWS resource to delete.
*/
public function __construct(
Version $version,
$sid
) {
parent::__construct($version);
// Path Solution
$this->solution = [
'sid' =>
$sid,
];
$this->uri = '/Credentials/AWS/' . \rawurlencode($sid)
.'';
}
/**
* Delete the AwsInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
}
/**
* Fetch the AwsInstance
*
* @return AwsInstance Fetched AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AwsInstance
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
return new AwsInstance(
$this->version,
$payload,
$this->solution['sid']
);
}
/**
* Update the AwsInstance
*
* @param array|Options $options Optional Arguments
* @return AwsInstance Updated AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AwsInstance
{
$options = new Values($options);
$data = Values::of([
'FriendlyName' =>
$options['friendlyName'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
return new AwsInstance(
$this->version,
$payload,
$this->solution['sid']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AwsContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\Deserialize;
/**
* @property string|null $sid
* @property string|null $accountSid
* @property string|null $friendlyName
* @property \DateTime|null $dateCreated
* @property \DateTime|null $dateUpdated
* @property string|null $url
*/
class AwsInstance extends InstanceResource
{
/**
* Initialize the AwsInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $sid The Twilio-provided string that uniquely identifies the AWS resource to delete.
*/
public function __construct(Version $version, array $payload, ?string $sid = null)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'accountSid' => Values::array_get($payload, 'account_sid'),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'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 = ['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 AwsContext Context for this AwsInstance
*/
protected function proxy(): AwsContext
{
if (!$this->context) {
$this->context = new AwsContext(
$this->version,
$this->solution['sid']
);
}
return $this->context;
}
/**
* Delete the AwsInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
return $this->proxy()->delete();
}
/**
* Fetch the AwsInstance
*
* @return AwsInstance Fetched AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AwsInstance
{
return $this->proxy()->fetch();
}
/**
* Update the AwsInstance
*
* @param array|Options $options Optional Arguments
* @return AwsInstance Updated AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AwsInstance
{
return $this->proxy()->update($options);
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AwsInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,196 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class AwsList extends ListResource
{
/**
* Construct the AwsList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/Credentials/AWS';
}
/**
* Create the AwsInstance
*
* @param string $credentials A string that contains the AWS access credentials in the format `<AWS_ACCESS_KEY_ID>:<AWS_SECRET_ACCESS_KEY>`. For example, `AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
* @param array|Options $options Optional Arguments
* @return AwsInstance Created AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $credentials, array $options = []): AwsInstance
{
$options = new Values($options);
$data = Values::of([
'Credentials' =>
$credentials,
'FriendlyName' =>
$options['friendlyName'],
'AccountSid' =>
$options['accountSid'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return new AwsInstance(
$this->version,
$payload
);
}
/**
* Reads AwsInstance 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 AwsInstance[] Array of results
*/
public function read(?int $limit = null, $pageSize = null): array
{
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Streams AwsInstance 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 Stream stream of results
*/
public function stream(?int $limit = null, $pageSize = null): Stream
{
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Retrieve a single page of AwsInstance 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 AwsPage Page of AwsInstance
*/
public function page(
$pageSize = Values::NONE,
string $pageToken = Values::NONE,
$pageNumber = Values::NONE
): AwsPage
{
$params = Values::of([
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
return new AwsPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of AwsInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return AwsPage Page of AwsInstance
*/
public function getPage(string $targetUrl): AwsPage
{
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new AwsPage($this->version, $response, $this->solution);
}
/**
* Constructs a AwsContext
*
* @param string $sid The Twilio-provided string that uniquely identifies the AWS resource to delete.
*/
public function getContext(
string $sid
): AwsContext
{
return new AwsContext(
$this->version,
$sid
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.AwsList]';
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Options;
use Twilio\Values;
abstract class AwsOptions
{
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @param string $accountSid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
* @return CreateAwsOptions Options builder
*/
public static function create(
string $friendlyName = Values::NONE,
string $accountSid = Values::NONE
): CreateAwsOptions
{
return new CreateAwsOptions(
$friendlyName,
$accountSid
);
}
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @return UpdateAwsOptions Options builder
*/
public static function update(
string $friendlyName = Values::NONE
): UpdateAwsOptions
{
return new UpdateAwsOptions(
$friendlyName
);
}
}
class CreateAwsOptions extends Options
{
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @param string $accountSid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
*/
public function __construct(
string $friendlyName = Values::NONE,
string $accountSid = Values::NONE
) {
$this->options['friendlyName'] = $friendlyName;
$this->options['accountSid'] = $accountSid;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
*
* @param string $accountSid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
* @return $this Fluent Builder
*/
public function setAccountSid(string $accountSid): self
{
$this->options['accountSid'] = $accountSid;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.CreateAwsOptions ' . $options . ']';
}
}
class UpdateAwsOptions extends Options
{
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*/
public function __construct(
string $friendlyName = Values::NONE
) {
$this->options['friendlyName'] = $friendlyName;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.UpdateAwsOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class AwsPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return AwsInstance \Twilio\Rest\Accounts\V1\Credential\AwsInstance
*/
public function buildInstance(array $payload): AwsInstance
{
return new AwsInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.AwsPage]';
}
}

View File

@@ -0,0 +1,126 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
class PublicKeyContext extends InstanceContext
{
/**
* Initialize the PublicKeyContext
*
* @param Version $version Version that contains the resource
* @param string $sid The Twilio-provided string that uniquely identifies the PublicKey resource to delete.
*/
public function __construct(
Version $version,
$sid
) {
parent::__construct($version);
// Path Solution
$this->solution = [
'sid' =>
$sid,
];
$this->uri = '/Credentials/PublicKeys/' . \rawurlencode($sid)
.'';
}
/**
* Delete the PublicKeyInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
}
/**
* Fetch the PublicKeyInstance
*
* @return PublicKeyInstance Fetched PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): PublicKeyInstance
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
return new PublicKeyInstance(
$this->version,
$payload,
$this->solution['sid']
);
}
/**
* Update the PublicKeyInstance
*
* @param array|Options $options Optional Arguments
* @return PublicKeyInstance Updated PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): PublicKeyInstance
{
$options = new Values($options);
$data = Values::of([
'FriendlyName' =>
$options['friendlyName'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
return new PublicKeyInstance(
$this->version,
$payload,
$this->solution['sid']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.PublicKeyContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\Deserialize;
/**
* @property string|null $sid
* @property string|null $accountSid
* @property string|null $friendlyName
* @property \DateTime|null $dateCreated
* @property \DateTime|null $dateUpdated
* @property string|null $url
*/
class PublicKeyInstance extends InstanceResource
{
/**
* Initialize the PublicKeyInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $sid The Twilio-provided string that uniquely identifies the PublicKey resource to delete.
*/
public function __construct(Version $version, array $payload, ?string $sid = null)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'accountSid' => Values::array_get($payload, 'account_sid'),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'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 = ['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 PublicKeyContext Context for this PublicKeyInstance
*/
protected function proxy(): PublicKeyContext
{
if (!$this->context) {
$this->context = new PublicKeyContext(
$this->version,
$this->solution['sid']
);
}
return $this->context;
}
/**
* Delete the PublicKeyInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
return $this->proxy()->delete();
}
/**
* Fetch the PublicKeyInstance
*
* @return PublicKeyInstance Fetched PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): PublicKeyInstance
{
return $this->proxy()->fetch();
}
/**
* Update the PublicKeyInstance
*
* @param array|Options $options Optional Arguments
* @return PublicKeyInstance Updated PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): PublicKeyInstance
{
return $this->proxy()->update($options);
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.PublicKeyInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,196 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class PublicKeyList extends ListResource
{
/**
* Construct the PublicKeyList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/Credentials/PublicKeys';
}
/**
* Create the PublicKeyInstance
*
* @param string $publicKey A URL encoded representation of the public key. For example, `-----BEGIN PUBLIC KEY-----MIIBIjANB.pa9xQIDAQAB-----END PUBLIC KEY-----`
* @param array|Options $options Optional Arguments
* @return PublicKeyInstance Created PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $publicKey, array $options = []): PublicKeyInstance
{
$options = new Values($options);
$data = Values::of([
'PublicKey' =>
$publicKey,
'FriendlyName' =>
$options['friendlyName'],
'AccountSid' =>
$options['accountSid'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return new PublicKeyInstance(
$this->version,
$payload
);
}
/**
* Reads PublicKeyInstance 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 PublicKeyInstance[] Array of results
*/
public function read(?int $limit = null, $pageSize = null): array
{
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Streams PublicKeyInstance 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 Stream stream of results
*/
public function stream(?int $limit = null, $pageSize = null): Stream
{
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Retrieve a single page of PublicKeyInstance 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 PublicKeyPage Page of PublicKeyInstance
*/
public function page(
$pageSize = Values::NONE,
string $pageToken = Values::NONE,
$pageNumber = Values::NONE
): PublicKeyPage
{
$params = Values::of([
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
return new PublicKeyPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of PublicKeyInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return PublicKeyPage Page of PublicKeyInstance
*/
public function getPage(string $targetUrl): PublicKeyPage
{
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new PublicKeyPage($this->version, $response, $this->solution);
}
/**
* Constructs a PublicKeyContext
*
* @param string $sid The Twilio-provided string that uniquely identifies the PublicKey resource to delete.
*/
public function getContext(
string $sid
): PublicKeyContext
{
return new PublicKeyContext(
$this->version,
$sid
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.PublicKeyList]';
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Options;
use Twilio\Values;
abstract class PublicKeyOptions
{
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @param string $accountSid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
* @return CreatePublicKeyOptions Options builder
*/
public static function create(
string $friendlyName = Values::NONE,
string $accountSid = Values::NONE
): CreatePublicKeyOptions
{
return new CreatePublicKeyOptions(
$friendlyName,
$accountSid
);
}
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @return UpdatePublicKeyOptions Options builder
*/
public static function update(
string $friendlyName = Values::NONE
): UpdatePublicKeyOptions
{
return new UpdatePublicKeyOptions(
$friendlyName
);
}
}
class CreatePublicKeyOptions extends Options
{
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @param string $accountSid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
*/
public function __construct(
string $friendlyName = Values::NONE,
string $accountSid = Values::NONE
) {
$this->options['friendlyName'] = $friendlyName;
$this->options['accountSid'] = $accountSid;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
*
* @param string $accountSid The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
* @return $this Fluent Builder
*/
public function setAccountSid(string $accountSid): self
{
$this->options['accountSid'] = $accountSid;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.CreatePublicKeyOptions ' . $options . ']';
}
}
class UpdatePublicKeyOptions extends Options
{
/**
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*/
public function __construct(
string $friendlyName = Values::NONE
) {
$this->options['friendlyName'] = $friendlyName;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A descriptive string that you create to describe the resource. It can be up to 64 characters long.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.UpdatePublicKeyOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class PublicKeyPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return PublicKeyInstance \Twilio\Rest\Accounts\V1\Credential\PublicKeyInstance
*/
public function buildInstance(array $payload): PublicKeyInstance
{
return new PublicKeyInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.PublicKeyPage]';
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Version;
class CredentialInstance extends InstanceResource
{
/**
* Initialize the CredentialInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
$this->solution = [];
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
return '[Twilio.Accounts.V1.CredentialInstance]';
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Version;
use Twilio\InstanceContext;
use Twilio\Rest\Accounts\V1\Credential\AwsList;
use Twilio\Rest\Accounts\V1\Credential\PublicKeyList;
/**
* @property AwsList $aws
* @property PublicKeyList $publicKey
* @method \Twilio\Rest\Accounts\V1\Credential\PublicKeyContext publicKey(string $sid)
* @method \Twilio\Rest\Accounts\V1\Credential\AwsContext aws(string $sid)
*/
class CredentialList extends ListResource
{
protected $_aws = null;
protected $_publicKey = null;
/**
* Construct the CredentialList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
}
/**
* Access the aws
*/
protected function getAws(): AwsList
{
if (!$this->_aws) {
$this->_aws = new AwsList(
$this->version
);
}
return $this->_aws;
}
/**
* Access the publicKey
*/
protected function getPublicKey(): PublicKeyList
{
if (!$this->_publicKey) {
$this->_publicKey = new PublicKeyList(
$this->version
);
}
return $this->_publicKey;
}
/**
* Magic getter to lazy load subresources
*
* @param string $name Subresource to return
* @return \Twilio\ListResource The requested subresource
* @throws TwilioException For unknown subresources
*/
public function __get(string $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 InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments): InstanceContext
{
$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(): string
{
return '[Twilio.Accounts.V1.CredentialList]';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class CredentialPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return CredentialInstance \Twilio\Rest\Accounts\V1\CredentialInstance
*/
public function buildInstance(array $payload): CredentialInstance
{
return new CredentialInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.CredentialPage]';
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property array|null $permissions
*/
class MessagingGeopermissionsInstance extends InstanceResource
{
/**
* Initialize the MessagingGeopermissionsInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'permissions' => Values::array_get($payload, 'permissions'),
];
$this->solution = [];
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
return '[Twilio.Accounts.V1.MessagingGeopermissionsInstance]';
}
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\Serialize;
class MessagingGeopermissionsList extends ListResource
{
/**
* Construct the MessagingGeopermissionsList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/Messaging/GeoPermissions';
}
/**
* Fetch the MessagingGeopermissionsInstance
*
* @param array|Options $options Optional Arguments
* @return MessagingGeopermissionsInstance Fetched MessagingGeopermissionsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(array $options = []): MessagingGeopermissionsInstance
{
$options = new Values($options);
$params = Values::of([
'CountryCode' =>
$options['countryCode'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->fetch('GET', $this->uri, $params, [], $headers);
return new MessagingGeopermissionsInstance(
$this->version,
$payload
);
}
/**
* Update the MessagingGeopermissionsInstance
*
* @param array[] $permissions A list of objects where each object represents the Geo Permission to be updated. Each object contains the following fields: `country_code`, unique code for each country of Geo Permission; `type`, permission type of the Geo Permission i.e. country; `enabled`, configure true for enabling the Geo Permission, false for disabling the Geo Permission.
* @return MessagingGeopermissionsInstance Updated MessagingGeopermissionsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $permissions): MessagingGeopermissionsInstance
{
$data = Values::of([
'Permissions' =>
Serialize::map($permissions,function ($e) { return Serialize::jsonObject($e); }),
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->update('PATCH', $this->uri, [], $data, $headers);
return new MessagingGeopermissionsInstance(
$this->version,
$payload
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.MessagingGeopermissionsList]';
}
}

View File

@@ -0,0 +1,78 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Options;
use Twilio\Values;
abstract class MessagingGeopermissionsOptions
{
/**
* @param string $countryCode The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.
* @return FetchMessagingGeopermissionsOptions Options builder
*/
public static function fetch(
string $countryCode = Values::NONE
): FetchMessagingGeopermissionsOptions
{
return new FetchMessagingGeopermissionsOptions(
$countryCode
);
}
}
class FetchMessagingGeopermissionsOptions extends Options
{
/**
* @param string $countryCode The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.
*/
public function __construct(
string $countryCode = Values::NONE
) {
$this->options['countryCode'] = $countryCode;
}
/**
* The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.
*
* @param string $countryCode The country code to filter the geo permissions. If provided, only the geo permission for the specified country will be returned.
* @return $this Fluent Builder
*/
public function setCountryCode(string $countryCode): self
{
$this->options['countryCode'] = $countryCode;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.FetchMessagingGeopermissionsOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class MessagingGeopermissionsPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return MessagingGeopermissionsInstance \Twilio\Rest\Accounts\V1\MessagingGeopermissionsInstance
*/
public function buildInstance(array $payload): MessagingGeopermissionsInstance
{
return new MessagingGeopermissionsInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.MessagingGeopermissionsPage]';
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string|null $sid
* @property string|null $phoneNumber
*/
class SafelistInstance extends InstanceResource
{
/**
* Initialize the SafelistInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
];
$this->solution = [];
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
return '[Twilio.Accounts.V1.SafelistInstance]';
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
class SafelistList extends ListResource
{
/**
* Construct the SafelistList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/SafeList/Numbers';
}
/**
* Create the SafelistInstance
*
* @param string $phoneNumber The phone number or phone number 1k prefix to be added in SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
* @return SafelistInstance Created SafelistInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $phoneNumber): SafelistInstance
{
$data = Values::of([
'PhoneNumber' =>
$phoneNumber,
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return new SafelistInstance(
$this->version,
$payload
);
}
/**
* Delete the SafelistInstance
*
* @param array|Options $options Optional Arguments
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(array $options = []): bool
{
$options = new Values($options);
$params = Values::of([
'PhoneNumber' =>
$options['phoneNumber'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
return $this->version->delete('DELETE', $this->uri, $params, [], $headers);
}
/**
* Fetch the SafelistInstance
*
* @param array|Options $options Optional Arguments
* @return SafelistInstance Fetched SafelistInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(array $options = []): SafelistInstance
{
$options = new Values($options);
$params = Values::of([
'PhoneNumber' =>
$options['phoneNumber'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->fetch('GET', $this->uri, $params, [], $headers);
return new SafelistInstance(
$this->version,
$payload
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.SafelistList]';
}
}

View File

@@ -0,0 +1,130 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Options;
use Twilio\Values;
abstract class SafelistOptions
{
/**
* @param string $phoneNumber The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
* @return DeleteSafelistOptions Options builder
*/
public static function delete(
string $phoneNumber = Values::NONE
): DeleteSafelistOptions
{
return new DeleteSafelistOptions(
$phoneNumber
);
}
/**
* @param string $phoneNumber The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
* @return FetchSafelistOptions Options builder
*/
public static function fetch(
string $phoneNumber = Values::NONE
): FetchSafelistOptions
{
return new FetchSafelistOptions(
$phoneNumber
);
}
}
class DeleteSafelistOptions extends Options
{
/**
* @param string $phoneNumber The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
*/
public function __construct(
string $phoneNumber = Values::NONE
) {
$this->options['phoneNumber'] = $phoneNumber;
}
/**
* The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
*
* @param string $phoneNumber The phone number or phone number 1k prefix to be removed from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
* @return $this Fluent Builder
*/
public function setPhoneNumber(string $phoneNumber): self
{
$this->options['phoneNumber'] = $phoneNumber;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.DeleteSafelistOptions ' . $options . ']';
}
}
class FetchSafelistOptions extends Options
{
/**
* @param string $phoneNumber The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
*/
public function __construct(
string $phoneNumber = Values::NONE
) {
$this->options['phoneNumber'] = $phoneNumber;
}
/**
* The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
*
* @param string $phoneNumber The phone number or phone number 1k prefix to be fetched from SafeList. Phone numbers must be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164).
* @return $this Fluent Builder
*/
public function setPhoneNumber(string $phoneNumber): self
{
$this->options['phoneNumber'] = $phoneNumber;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.FetchSafelistOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class SafelistPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return SafelistInstance \Twilio\Rest\Accounts\V1\SafelistInstance
*/
public function buildInstance(array $payload): SafelistInstance
{
return new SafelistInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.SafelistPage]';
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
class SecondaryAuthTokenContext extends InstanceContext
{
/**
* Initialize the SecondaryAuthTokenContext
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
$this->uri = '/AuthTokens/Secondary';
}
/**
* Create the SecondaryAuthTokenInstance
*
* @return SecondaryAuthTokenInstance Created SecondaryAuthTokenInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(): SecondaryAuthTokenInstance
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], [], $headers);
return new SecondaryAuthTokenInstance(
$this->version,
$payload
);
}
/**
* Delete the SecondaryAuthTokenInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.SecondaryAuthTokenContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,134 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Deserialize;
/**
* @property string|null $accountSid
* @property \DateTime|null $dateCreated
* @property \DateTime|null $dateUpdated
* @property string|null $secondaryAuthToken
* @property string|null $url
*/
class SecondaryAuthTokenInstance extends InstanceResource
{
/**
* Initialize the SecondaryAuthTokenInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'secondaryAuthToken' => Values::array_get($payload, 'secondary_auth_token'),
'url' => Values::array_get($payload, 'url'),
];
$this->solution = [];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return SecondaryAuthTokenContext Context for this SecondaryAuthTokenInstance
*/
protected function proxy(): SecondaryAuthTokenContext
{
if (!$this->context) {
$this->context = new SecondaryAuthTokenContext(
$this->version
);
}
return $this->context;
}
/**
* Create the SecondaryAuthTokenInstance
*
* @return SecondaryAuthTokenInstance Created SecondaryAuthTokenInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(): SecondaryAuthTokenInstance
{
return $this->proxy()->create();
}
/**
* Delete the SecondaryAuthTokenInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
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(string $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(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.SecondaryAuthTokenInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\ListResource;
use Twilio\Version;
class SecondaryAuthTokenList extends ListResource
{
/**
* Construct the SecondaryAuthTokenList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);
// Path Solution
$this->solution = [
];
}
/**
* Constructs a SecondaryAuthTokenContext
*/
public function getContext(
): SecondaryAuthTokenContext
{
return new SecondaryAuthTokenContext(
$this->version
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.SecondaryAuthTokenList]';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Accounts
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class SecondaryAuthTokenPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return SecondaryAuthTokenInstance \Twilio\Rest\Accounts\V1\SecondaryAuthTokenInstance
*/
public function buildInstance(array $payload): SecondaryAuthTokenInstance
{
return new SecondaryAuthTokenInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Accounts.V1.SecondaryAuthTokenPage]';
}
}

View File

@@ -0,0 +1,88 @@
<?php
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\Rest\Accounts\V1;
/**
* @property \Twilio\Rest\Accounts\V1 $v1
*/
class AccountsBase extends Domain {
protected $_v1;
/**
* Construct the Accounts Domain
*
* @param Client $client Client to communicate with Twilio
*/
public function __construct(Client $client) {
parent::__construct($client);
$this->baseUrl = 'https://accounts.twilio.com';
}
/**
* @return V1 Version v1 of accounts
*/
protected function getV1(): V1 {
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 TwilioException For unknown versions
*/
public function __get(string $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 TwilioException For unknown resource
*/
public function __call(string $name, array $arguments) {
$method = 'context' . \ucfirst($name);
if (\method_exists($this, $method)) {
return \call_user_func_array([$this, $method], $arguments);
}
throw new TwilioException('Unknown context ' . $name);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts]';
}
}

View File

@@ -0,0 +1,371 @@
<?php
namespace Twilio\Rest;
use Twilio\Rest\Api\V2010;
class Api extends ApiBase {
/**
* @return \Twilio\Rest\Api\V2010\AccountContext Account provided as the
* authenticating account
*/
protected function getAccount(): \Twilio\Rest\Api\V2010\AccountContext {
return $this->v2010->account;
}
protected function getAccounts(): \Twilio\Rest\Api\V2010\AccountList {
return $this->v2010->accounts;
}
/**
* @param string $sid Fetch by unique Account Sid
*/
protected function contextAccounts(string $sid): \Twilio\Rest\Api\V2010\AccountContext {
return $this->v2010->accounts($sid);
}
/**
* @deprecated Use account->addresses instead.
*/
protected function getAddresses(): \Twilio\Rest\Api\V2010\Account\AddressList {
echo "addresses is deprecated. Use account->addresses instead.";
return $this->v2010->account->addresses;
}
/**
* @deprecated Use account->addresses(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextAddresses(string $sid): \Twilio\Rest\Api\V2010\Account\AddressContext {
echo "addresses(\$sid) is deprecated. Use account->addresses(\$sid) instead.";
return $this->v2010->account->addresses($sid);
}
/**
* @deprecated Use account->applications instead.
*/
protected function getApplications(): \Twilio\Rest\Api\V2010\Account\ApplicationList {
echo "applications is deprecated. Use account->applications instead.";
return $this->v2010->account->applications;
}
/**
* @deprecated Use account->applications(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextApplications(string $sid): \Twilio\Rest\Api\V2010\Account\ApplicationContext {
echo "applications(\$sid) is deprecated. Use account->applications(\$sid) instead.";
return $this->v2010->account->applications($sid);
}
/**
* @deprecated Use account->authorizedConnectApps instead.
*/
protected function getAuthorizedConnectApps(): \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList {
echo "authorizedConnectApps is deprecated. Use account->authorizedConnectApps instead.";
return $this->v2010->account->authorizedConnectApps;
}
/**
* @deprecated Use account->authorizedConnectApps(\$connectAppSid) instead.
* @param string $connectAppSid The SID of the Connect App to fetch
*/
protected function contextAuthorizedConnectApps(string $connectAppSid): \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext {
echo "authorizedConnectApps(\$connectAppSid) is deprecated. Use account->authorizedConnectApps(\$connectAppSid) instead.";
return $this->v2010->account->authorizedConnectApps($connectAppSid);
}
/**
* @deprecated Use account->availablePhoneNumbers instead.
*/
protected function getAvailablePhoneNumbers(): \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList {
echo "availablePhoneNumbers is deprecated. Use account->availablePhoneNumbers instead.";
return $this->v2010->account->availablePhoneNumbers;
}
/**
* @deprecated Use account->availablePhoneNumbers(\$countryCode) instead.
* @param string $countryCode The ISO country code of the country to fetch
* available phone number information about
*/
protected function contextAvailablePhoneNumbers(string $countryCode): \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext {
echo "availablePhoneNumbers(\$countryCode) is deprecated. Use account->availablePhoneNumbers(\$countryCode) instead.";
return $this->v2010->account->availablePhoneNumbers($countryCode);
}
/**
* @deprecated Use account->balance instead.
*/
protected function getBalance(): \Twilio\Rest\Api\V2010\Account\BalanceList {
echo "balance is deprecated. Use account->balance instead.";
return $this->v2010->account->balance;
}
/**
* @deprecated Use account->calls instead
*/
protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList {
echo "calls is deprecated. Use account->calls instead.";
return $this->v2010->account->calls;
}
/**
* @deprecated Use account->calls(\$sid) instead.
* @param string $sid The SID of the Call resource to fetch
*/
protected function contextCalls(string $sid): \Twilio\Rest\Api\V2010\Account\CallContext {
echo "calls(\$sid) is deprecated. Use account->calls(\$sid) instead.";
return $this->v2010->account->calls($sid);
}
/**
* @deprecated Use account->conferences instead.
*/
protected function getConferences(): \Twilio\Rest\Api\V2010\Account\ConferenceList {
echo "conferences is deprecated. Use account->conferences instead.";
return $this->v2010->account->conferences;
}
/**
* @deprecated Use account->conferences(\$sid) instead.
* @param string $sid The unique string that identifies this resource
*/
protected function contextConferences(string $sid): \Twilio\Rest\Api\V2010\Account\ConferenceContext {
echo "conferences(\$sid) is deprecated. Use account->conferences(\$sid) instead.";
return $this->v2010->account->conferences($sid);
}
/**
* @deprecated Use account->connectApps instead.
*/
protected function getConnectApps(): \Twilio\Rest\Api\V2010\Account\ConnectAppList {
echo "connectApps is deprecated. Use account->connectApps instead.";
return $this->v2010->account->connectApps;
}
/**
* @deprecated account->connectApps(\$sid)
* @param string $sid The unique string that identifies the resource
*/
protected function contextConnectApps(string $sid): \Twilio\Rest\Api\V2010\Account\ConnectAppContext {
echo "connectApps(\$sid) is deprecated. Use account->connectApps(\$sid) instead.";
return $this->v2010->account->connectApps($sid);
}
/**
* @deprecated Use account->incomingPhoneNumbers instead
*/
protected function getIncomingPhoneNumbers(): \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList {
echo "incomingPhoneNumbers is deprecated. Use account->incomingPhoneNumbers instead.";
return $this->v2010->account->incomingPhoneNumbers;
}
/**
* @deprecated Use account->incomingPhoneNumbers(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextIncomingPhoneNumbers(string $sid): \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext {
echo "incomingPhoneNumbers(\$sid) is deprecated. Use account->incomingPhoneNumbers(\$sid) instead.";
return $this->v2010->account->incomingPhoneNumbers($sid);
}
/**
* @deprecated Use account->keys instead.
*/
protected function getKeys(): \Twilio\Rest\Api\V2010\Account\KeyList {
echo "keys is deprecated. Use account->keys instead.";
return $this->v2010->account->keys;
}
/**
* @deprecated Use account->keys(\$sid) instead
* @param string $sid The unique string that identifies the resource
*/
protected function contextKeys(string $sid): \Twilio\Rest\Api\V2010\Account\KeyContext {
echo "keys(\$sid) is deprecated. Use account->keys(\$sid) instead.";
return $this->v2010->account->keys($sid);
}
/**
* @deprecated Use account->messages instead.
*/
protected function getMessages(): \Twilio\Rest\Api\V2010\Account\MessageList {
echo "messages is deprecated. Use account->messages instead.";
return $this->v2010->account->messages;
}
/**
* @deprecated Use account->messages(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextMessages(string $sid): \Twilio\Rest\Api\V2010\Account\MessageContext {
echo "amessages(\$sid) is deprecated. Use account->messages(\$sid) instead.";
return $this->v2010->account->messages($sid);
}
/**
* @deprecated Use account->newKeys instead.
*/
protected function getNewKeys(): \Twilio\Rest\Api\V2010\Account\NewKeyList {
echo "newKeys is deprecated. Use account->newKeys instead.";
return $this->v2010->account->newKeys;
}
/**
* @deprecated Use account->newSigningKeys instead.
*/
protected function getNewSigningKeys(): \Twilio\Rest\Api\V2010\Account\NewSigningKeyList {
echo "newSigningKeys is deprecated. Use account->newSigningKeys instead.";
return $this->v2010->account->newSigningKeys;
}
/**
* @deprecated Use account->notifications instead.
*/
protected function getNotifications(): \Twilio\Rest\Api\V2010\Account\NotificationList {
echo "notifications is deprecated. Use account->notifications instead.";
return $this->v2010->account->notifications;
}
/**
* @deprecated Use account->notifications(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextNotifications(string $sid): \Twilio\Rest\Api\V2010\Account\NotificationContext {
echo "notifications(\$sid) is deprecated. Use account->notifications(\$sid) instead.";
return $this->v2010->account->notifications($sid);
}
/**
* @deprecated Use account->outgoingCallerIds instead.
*/
protected function getOutgoingCallerIds(): \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList {
echo "outgoingCallerIds is deprecated. Use account->outgoingCallerIds instead.";
return $this->v2010->account->outgoingCallerIds;
}
/**
* @deprecated Use account->outgoingCallerIds(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextOutgoingCallerIds(string $sid): \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext {
echo "outgoingCallerIds(\$sid) is deprecated. Use account->outgoingCallerIds(\$sid) instead.";
return $this->v2010->account->outgoingCallerIds($sid);
}
/**
* @deprecated Use account->queues instead.
*/
protected function getQueues(): \Twilio\Rest\Api\V2010\Account\QueueList {
echo "queues is deprecated. Use account->queues instead.";
return $this->v2010->account->queues;
}
/**
* @deprecated Use account->queues(\$sid) instead.
* @param string $sid The unique string that identifies this resource
*/
protected function contextQueues(string $sid): \Twilio\Rest\Api\V2010\Account\QueueContext {
echo "queues(\$sid) is deprecated. Use account->queues(\$sid) instead.";
return $this->v2010->account->queues($sid);
}
/**
* @deprecated Use account->recordings instead.
*/
protected function getRecordings(): \Twilio\Rest\Api\V2010\Account\RecordingList {
echo "recordings is deprecated. Use account->recordings instead.";
return $this->v2010->account->recordings;
}
/**
* @deprecated Use account->recordings(\$sid) instead.
* @param string $sid The unique string that identifies the resource
*/
protected function contextRecordings(string $sid): \Twilio\Rest\Api\V2010\Account\RecordingContext {
echo "recordings(\$sid) is deprecated. Use account->recordings(\$sid) instead.";
return $this->v2010->account->recordings($sid);
}
/**
* @deprecated Use account->signingKeys instead.
*/
protected function getSigningKeys(): \Twilio\Rest\Api\V2010\Account\SigningKeyList {
echo "signingKeys is deprecated. Use account->signingKeys instead.";
return $this->v2010->account->signingKeys;
}
/**
* @deprecated Use account->signingKeys(\$sid) instead.
* @param string $sid The sid
*/
protected function contextSigningKeys(string $sid): \Twilio\Rest\Api\V2010\Account\SigningKeyContext {
echo "signingKeys(\$sid) is deprecated. Use account->signingKeys(\$sid) instead.";
return $this->v2010->account->signingKeys($sid);
}
/**
* @deprecated Use account->sip instead.
*/
protected function getSip(): \Twilio\Rest\Api\V2010\Account\SipList {
echo "sip is deprecated. Use account->sip instead.";
return $this->v2010->account->sip;
}
/**
* @deprecated Use account->shortCodes instead.
*/
protected function getShortCodes(): \Twilio\Rest\Api\V2010\Account\ShortCodeList {
echo "shortCodes is deprecated. Use account->shortCodes instead.";
return $this->v2010->account->shortCodes;
}
/**
* @deprecated Use account->shortCodes(\$sid) instead.
* @param string $sid The unique string that identifies this resource
*/
protected function contextShortCodes(string $sid): \Twilio\Rest\Api\V2010\Account\ShortCodeContext {
echo "shortCodes(\$sid) is deprecated. Use account->shortCodes(\$sid) instead.";
return $this->v2010->account->shortCodes($sid);
}
/**
* @deprecated Use account->token instead.
*/
protected function getTokens(): \Twilio\Rest\Api\V2010\Account\TokenList {
echo "tokens is deprecated. Use account->token instead.";
return $this->v2010->account->tokens;
}
/**
* @deprecated Use account->transcriptions instead.
*/
protected function getTranscriptions(): \Twilio\Rest\Api\V2010\Account\TranscriptionList {
echo "transcriptions is deprecated. Use account->transcriptions instead.";
return $this->v2010->account->transcriptions;
}
/**
* @deprecated Use account->transcriptions(\$sid) instead
* @param string $sid The unique string that identifies the resource
*/
protected function contextTranscriptions(string $sid): \Twilio\Rest\Api\V2010\Account\TranscriptionContext {
echo "transcriptions(\$sid) is deprecated. Use account->transcriptions(\$sid) instead.";
return $this->v2010->account->transcriptions($sid);
}
/**
* @deprecated Use account->usage instead.
*/
protected function getUsage(): \Twilio\Rest\Api\V2010\Account\UsageList {
echo "usage is deprecated. Use account->usage instead.";
return $this->v2010->account->usage;
}
/**
* @deprecated Use account->validationRequests instead.
*/
protected function getValidationRequests(): \Twilio\Rest\Api\V2010\Account\ValidationRequestList {
echo "validationRequests is deprecated. Use account->validationRequests instead.";
return $this->v2010->account->validationRequests;
}
}

View File

@@ -0,0 +1,309 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\Api\V2010\AccountInstance;
use Twilio\Rest\Api\V2010\AccountList;
use Twilio\Rest\Api\V2010\AccountContext;
use Twilio\Version;
/**
* @property AccountList $accounts
* @property AccountContext $account
* @property \Twilio\Rest\Api\V2010\Account\RecordingList $recordings
* @property \Twilio\Rest\Api\V2010\Account\UsageList $usage
* @property \Twilio\Rest\Api\V2010\Account\MessageList $messages
* @property \Twilio\Rest\Api\V2010\Account\KeyList $keys
* @property \Twilio\Rest\Api\V2010\Account\NewKeyList $newKeys
* @property \Twilio\Rest\Api\V2010\Account\ApplicationList $applications
* @property \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList $incomingPhoneNumbers
* @property \Twilio\Rest\Api\V2010\Account\ConferenceList $conferences
* @property \Twilio\Rest\Api\V2010\Account\CallList $calls
* @property \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList $outgoingCallerIds
* @property \Twilio\Rest\Api\V2010\Account\ValidationRequestList $validationRequests
* @property \Twilio\Rest\Api\V2010\Account\TranscriptionList $transcriptions
* @property \Twilio\Rest\Api\V2010\Account\ConnectAppList $connectApps
* @property \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList $authorizedConnectApps
* @property \Twilio\Rest\Api\V2010\Account\TokenList $tokens
* @property \Twilio\Rest\Api\V2010\Account\BalanceList $balance
* @property \Twilio\Rest\Api\V2010\Account\SipList $sip
* @property \Twilio\Rest\Api\V2010\Account\NotificationList $notifications
* @property \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList $availablePhoneNumbers
* @property \Twilio\Rest\Api\V2010\Account\AddressList $addresses
* @property \Twilio\Rest\Api\V2010\Account\QueueList $queues
* @property \Twilio\Rest\Api\V2010\Account\ShortCodeList $shortCodes
* @property \Twilio\Rest\Api\V2010\Account\SigningKeyList $signingKeys
* @property \Twilio\Rest\Api\V2010\Account\NewSigningKeyList $newSigningKeys
* @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\ShortCodeContext shortCodes(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\SigningKeyContext signingKeys(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\TranscriptionContext transcriptions(string $sid)
*/
class V2010 extends Version
{
protected $_accounts;
protected $_account = null;
protected $_recordings = null;
protected $_usage = null;
protected $_messages = null;
protected $_keys = null;
protected $_newKeys = null;
protected $_applications = null;
protected $_incomingPhoneNumbers = null;
protected $_conferences = null;
protected $_calls = null;
protected $_outgoingCallerIds = null;
protected $_validationRequests = null;
protected $_transcriptions = null;
protected $_connectApps = null;
protected $_authorizedConnectApps = null;
protected $_tokens = null;
protected $_balance = null;
protected $_sip = null;
protected $_notifications = null;
protected $_availablePhoneNumbers = null;
protected $_addresses = null;
protected $_queues = null;
protected $_shortCodes = null;
protected $_signingKeys = null;
protected $_newSigningKeys = null;
/**
* Construct the V2010 version of Api
*
* @param Domain $domain Domain that contains the version
*/
public function __construct(Domain $domain)
{
parent::__construct($domain);
$this->version = '2010-04-01';
}
protected function getAccounts(): AccountList
{
if (!$this->_accounts) {
$this->_accounts = new AccountList($this);
}
return $this->_accounts;
}
/**
* @return AccountContext Account provided as the authenticating account
*/
protected function getAccount(): AccountContext
{
if (!$this->_account) {
$this->_account = new AccountContext(
$this,
$this->domain->getClient()->getAccountSid()
);
}
return $this->_account;
}
/**
* Setter to override the primary account
*
* @param AccountContext|AccountInstance $account account to use as the primary
* account
*/
public function setAccount($account): void
{
$this->_account = $account;
}
protected function getRecordings(): \Twilio\Rest\Api\V2010\Account\RecordingList
{
return $this->account->recordings;
}
protected function getUsage(): \Twilio\Rest\Api\V2010\Account\UsageList
{
return $this->account->usage;
}
protected function getMessages(): \Twilio\Rest\Api\V2010\Account\MessageList
{
return $this->account->messages;
}
protected function getKeys(): \Twilio\Rest\Api\V2010\Account\KeyList
{
return $this->account->keys;
}
protected function getNewKeys(): \Twilio\Rest\Api\V2010\Account\NewKeyList
{
return $this->account->newKeys;
}
protected function getApplications(): \Twilio\Rest\Api\V2010\Account\ApplicationList
{
return $this->account->applications;
}
protected function getIncomingPhoneNumbers(): \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList
{
return $this->account->incomingPhoneNumbers;
}
protected function getConferences(): \Twilio\Rest\Api\V2010\Account\ConferenceList
{
return $this->account->conferences;
}
protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList
{
return $this->account->calls;
}
protected function getOutgoingCallerIds(): \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList
{
return $this->account->outgoingCallerIds;
}
protected function getValidationRequests(): \Twilio\Rest\Api\V2010\Account\ValidationRequestList
{
return $this->account->validationRequests;
}
protected function getTranscriptions(): \Twilio\Rest\Api\V2010\Account\TranscriptionList
{
return $this->account->transcriptions;
}
protected function getConnectApps(): \Twilio\Rest\Api\V2010\Account\ConnectAppList
{
return $this->account->connectApps;
}
protected function getAuthorizedConnectApps(): \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList
{
return $this->account->authorizedConnectApps;
}
protected function getTokens(): \Twilio\Rest\Api\V2010\Account\TokenList
{
return $this->account->tokens;
}
protected function getBalance(): \Twilio\Rest\Api\V2010\Account\BalanceList
{
return $this->account->balance;
}
protected function getSip(): \Twilio\Rest\Api\V2010\Account\SipList
{
return $this->account->sip;
}
protected function getNotifications(): \Twilio\Rest\Api\V2010\Account\NotificationList
{
return $this->account->notifications;
}
protected function getAvailablePhoneNumbers(): \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList
{
return $this->account->availablePhoneNumbers;
}
protected function getAddresses(): \Twilio\Rest\Api\V2010\Account\AddressList
{
return $this->account->addresses;
}
protected function getQueues(): \Twilio\Rest\Api\V2010\Account\QueueList
{
return $this->account->queues;
}
protected function getShortCodes(): \Twilio\Rest\Api\V2010\Account\ShortCodeList
{
return $this->account->shortCodes;
}
protected function getSigningKeys(): \Twilio\Rest\Api\V2010\Account\SigningKeyList
{
return $this->account->signingKeys;
}
protected function getNewSigningKeys(): \Twilio\Rest\Api\V2010\Account\NewSigningKeyList
{
return $this->account->newSigningKeys;
}
/**
* Magic getter to lazy load root resources
*
* @param string $name Resource to return
* @return \Twilio\ListResource The requested resource
* @throws TwilioException For unknown resource
*/
public function __get(string $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 InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments): InstanceContext
{
$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(): string
{
return '[Twilio.Api.V2010]';
}
}

View File

@@ -0,0 +1,133 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account\Address;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Deserialize;
/**
* @property string|null $sid
* @property string|null $accountSid
* @property string|null $friendlyName
* @property string|null $phoneNumber
* @property string|null $voiceUrl
* @property string|null $voiceMethod
* @property string|null $voiceFallbackMethod
* @property string|null $voiceFallbackUrl
* @property bool|null $voiceCallerIdLookup
* @property \DateTime|null $dateCreated
* @property \DateTime|null $dateUpdated
* @property string|null $smsFallbackMethod
* @property string|null $smsFallbackUrl
* @property string|null $smsMethod
* @property string|null $smsUrl
* @property string $addressRequirements
* @property array|null $capabilities
* @property string|null $statusCallback
* @property string|null $statusCallbackMethod
* @property string|null $apiVersion
* @property string|null $smsApplicationSid
* @property string|null $voiceApplicationSid
* @property string|null $trunkSid
* @property string $emergencyStatus
* @property string|null $emergencyAddressSid
* @property string|null $uri
*/
class DependentPhoneNumberInstance extends InstanceResource
{
/**
* Initialize the DependentPhoneNumberInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DependentPhoneNumber resources to read.
* @param string $addressSid The SID of the Address resource associated with the phone number.
*/
public function __construct(Version $version, array $payload, string $accountSid, string $addressSid)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'accountSid' => Values::array_get($payload, 'account_sid'),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
'voiceUrl' => Values::array_get($payload, 'voice_url'),
'voiceMethod' => Values::array_get($payload, 'voice_method'),
'voiceFallbackMethod' => Values::array_get($payload, 'voice_fallback_method'),
'voiceFallbackUrl' => Values::array_get($payload, 'voice_fallback_url'),
'voiceCallerIdLookup' => Values::array_get($payload, 'voice_caller_id_lookup'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'smsFallbackMethod' => Values::array_get($payload, 'sms_fallback_method'),
'smsFallbackUrl' => Values::array_get($payload, 'sms_fallback_url'),
'smsMethod' => Values::array_get($payload, 'sms_method'),
'smsUrl' => Values::array_get($payload, 'sms_url'),
'addressRequirements' => Values::array_get($payload, 'address_requirements'),
'capabilities' => Values::array_get($payload, 'capabilities'),
'statusCallback' => Values::array_get($payload, 'status_callback'),
'statusCallbackMethod' => Values::array_get($payload, 'status_callback_method'),
'apiVersion' => Values::array_get($payload, 'api_version'),
'smsApplicationSid' => Values::array_get($payload, 'sms_application_sid'),
'voiceApplicationSid' => Values::array_get($payload, 'voice_application_sid'),
'trunkSid' => Values::array_get($payload, 'trunk_sid'),
'emergencyStatus' => Values::array_get($payload, 'emergency_status'),
'emergencyAddressSid' => Values::array_get($payload, 'emergency_address_sid'),
'uri' => Values::array_get($payload, 'uri'),
];
$this->solution = ['accountSid' => $accountSid, 'addressSid' => $addressSid, ];
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
return '[Twilio.Api.V2010.DependentPhoneNumberInstance]';
}
}

View File

@@ -0,0 +1,158 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account\Address;
use Twilio\ListResource;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class DependentPhoneNumberList extends ListResource
{
/**
* Construct the DependentPhoneNumberList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the DependentPhoneNumber resources to read.
* @param string $addressSid The SID of the Address resource associated with the phone number.
*/
public function __construct(
Version $version,
string $accountSid,
string $addressSid
) {
parent::__construct($version);
// Path Solution
$this->solution = [
'accountSid' =>
$accountSid,
'addressSid' =>
$addressSid,
];
$this->uri = '/Accounts/' . \rawurlencode($accountSid)
.'/Addresses/' . \rawurlencode($addressSid)
.'/DependentPhoneNumbers.json';
}
/**
* Reads DependentPhoneNumberInstance 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 DependentPhoneNumberInstance[] Array of results
*/
public function read(?int $limit = null, $pageSize = null): array
{
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Streams DependentPhoneNumberInstance 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 Stream stream of results
*/
public function stream(?int $limit = null, $pageSize = null): Stream
{
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Retrieve a single page of DependentPhoneNumberInstance 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 DependentPhoneNumberPage Page of DependentPhoneNumberInstance
*/
public function page(
$pageSize = Values::NONE,
string $pageToken = Values::NONE,
$pageNumber = Values::NONE
): DependentPhoneNumberPage
{
$params = Values::of([
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
return new DependentPhoneNumberPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of DependentPhoneNumberInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return DependentPhoneNumberPage Page of DependentPhoneNumberInstance
*/
public function getPage(string $targetUrl): DependentPhoneNumberPage
{
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new DependentPhoneNumberPage($this->version, $response, $this->solution);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Api.V2010.DependentPhoneNumberList]';
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account\Address;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class DependentPhoneNumberPage extends Page
{
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution)
{
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return DependentPhoneNumberInstance \Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberInstance
*/
public function buildInstance(array $payload): DependentPhoneNumberInstance
{
return new DependentPhoneNumberInstance($this->version, $payload, $this->solution['accountSid'], $this->solution['addressSid']);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Api.V2010.DependentPhoneNumberPage]';
}
}

View File

@@ -0,0 +1,208 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
use Twilio\Serialize;
use Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberList;
/**
* @property DependentPhoneNumberList $dependentPhoneNumbers
*/
class AddressContext extends InstanceContext
{
protected $_dependentPhoneNumbers;
/**
* Initialize the AddressContext
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will be responsible for the new Address resource.
* @param string $sid The Twilio-provided string that uniquely identifies the Address resource to delete.
*/
public function __construct(
Version $version,
$accountSid,
$sid
) {
parent::__construct($version);
// Path Solution
$this->solution = [
'accountSid' =>
$accountSid,
'sid' =>
$sid,
];
$this->uri = '/Accounts/' . \rawurlencode($accountSid)
.'/Addresses/' . \rawurlencode($sid)
.'.json';
}
/**
* Delete the AddressInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
}
/**
* Fetch the AddressInstance
*
* @return AddressInstance Fetched AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AddressInstance
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
return new AddressInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['sid']
);
}
/**
* Update the AddressInstance
*
* @param array|Options $options Optional Arguments
* @return AddressInstance Updated AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AddressInstance
{
$options = new Values($options);
$data = Values::of([
'FriendlyName' =>
$options['friendlyName'],
'CustomerName' =>
$options['customerName'],
'Street' =>
$options['street'],
'City' =>
$options['city'],
'Region' =>
$options['region'],
'PostalCode' =>
$options['postalCode'],
'EmergencyEnabled' =>
Serialize::booleanToString($options['emergencyEnabled']),
'AutoCorrectAddress' =>
Serialize::booleanToString($options['autoCorrectAddress']),
'StreetSecondary' =>
$options['streetSecondary'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
return new AddressInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['sid']
);
}
/**
* Access the dependentPhoneNumbers
*/
protected function getDependentPhoneNumbers(): DependentPhoneNumberList
{
if (!$this->_dependentPhoneNumbers) {
$this->_dependentPhoneNumbers = new DependentPhoneNumberList(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->_dependentPhoneNumbers;
}
/**
* Magic getter to lazy load subresources
*
* @param string $name Subresource to return
* @return ListResource The requested subresource
* @throws TwilioException For unknown subresources
*/
public function __get(string $name): ListResource
{
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 InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments): InstanceContext
{
$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(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.AddressContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,185 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
use Twilio\Deserialize;
use Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberList;
/**
* @property string|null $accountSid
* @property string|null $city
* @property string|null $customerName
* @property \DateTime|null $dateCreated
* @property \DateTime|null $dateUpdated
* @property string|null $friendlyName
* @property string|null $isoCountry
* @property string|null $postalCode
* @property string|null $region
* @property string|null $sid
* @property string|null $street
* @property string|null $uri
* @property bool|null $emergencyEnabled
* @property bool|null $validated
* @property bool|null $verified
* @property string|null $streetSecondary
*/
class AddressInstance extends InstanceResource
{
protected $_dependentPhoneNumbers;
/**
* Initialize the AddressInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will be responsible for the new Address resource.
* @param string $sid The Twilio-provided string that uniquely identifies the Address resource to delete.
*/
public function __construct(Version $version, array $payload, string $accountSid, ?string $sid = null)
{
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'city' => Values::array_get($payload, 'city'),
'customerName' => Values::array_get($payload, 'customer_name'),
'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'),
'isoCountry' => Values::array_get($payload, 'iso_country'),
'postalCode' => Values::array_get($payload, 'postal_code'),
'region' => Values::array_get($payload, 'region'),
'sid' => Values::array_get($payload, 'sid'),
'street' => Values::array_get($payload, 'street'),
'uri' => Values::array_get($payload, 'uri'),
'emergencyEnabled' => Values::array_get($payload, 'emergency_enabled'),
'validated' => Values::array_get($payload, 'validated'),
'verified' => Values::array_get($payload, 'verified'),
'streetSecondary' => Values::array_get($payload, 'street_secondary'),
];
$this->solution = ['accountSid' => $accountSid, '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 AddressContext Context for this AddressInstance
*/
protected function proxy(): AddressContext
{
if (!$this->context) {
$this->context = new AddressContext(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->context;
}
/**
* Delete the AddressInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool
{
return $this->proxy()->delete();
}
/**
* Fetch the AddressInstance
*
* @return AddressInstance Fetched AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AddressInstance
{
return $this->proxy()->fetch();
}
/**
* Update the AddressInstance
*
* @param array|Options $options Optional Arguments
* @return AddressInstance Updated AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AddressInstance
{
return $this->proxy()->update($options);
}
/**
* Access the dependentPhoneNumbers
*/
protected function getDependentPhoneNumbers(): DependentPhoneNumberList
{
return $this->proxy()->dependentPhoneNumbers;
}
/**
* Magic getter to access properties
*
* @param string $name Property to access
* @return mixed The requested property
* @throws TwilioException For unknown properties
*/
public function __get(string $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(): string
{
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.AddressInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,236 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
use Twilio\Serialize;
class AddressList extends ListResource
{
/**
* Construct the AddressList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will be responsible for the new Address resource.
*/
public function __construct(
Version $version,
string $accountSid
) {
parent::__construct($version);
// Path Solution
$this->solution = [
'accountSid' =>
$accountSid,
];
$this->uri = '/Accounts/' . \rawurlencode($accountSid)
.'/Addresses.json';
}
/**
* Create the AddressInstance
*
* @param string $customerName The name to associate with the new address.
* @param string $street The number and street address of the new address.
* @param string $city The city of the new address.
* @param string $region The state or region of the new address.
* @param string $postalCode The postal code of the new address.
* @param string $isoCountry The ISO country code of the new address.
* @param array|Options $options Optional Arguments
* @return AddressInstance Created AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $customerName, string $street, string $city, string $region, string $postalCode, string $isoCountry, array $options = []): AddressInstance
{
$options = new Values($options);
$data = Values::of([
'CustomerName' =>
$customerName,
'Street' =>
$street,
'City' =>
$city,
'Region' =>
$region,
'PostalCode' =>
$postalCode,
'IsoCountry' =>
$isoCountry,
'FriendlyName' =>
$options['friendlyName'],
'EmergencyEnabled' =>
Serialize::booleanToString($options['emergencyEnabled']),
'AutoCorrectAddress' =>
Serialize::booleanToString($options['autoCorrectAddress']),
'StreetSecondary' =>
$options['streetSecondary'],
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return new AddressInstance(
$this->version,
$payload,
$this->solution['accountSid']
);
}
/**
* Reads AddressInstance 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 AddressInstance[] Array of results
*/
public function read(array $options = [], ?int $limit = null, $pageSize = null): array
{
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
}
/**
* Streams AddressInstance 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 Stream stream of results
*/
public function stream(array $options = [], ?int $limit = null, $pageSize = null): Stream
{
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Retrieve a single page of AddressInstance 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 AddressPage Page of AddressInstance
*/
public function page(
array $options = [],
$pageSize = Values::NONE,
string $pageToken = Values::NONE,
$pageNumber = Values::NONE
): AddressPage
{
$options = new Values($options);
$params = Values::of([
'CustomerName' =>
$options['customerName'],
'FriendlyName' =>
$options['friendlyName'],
'EmergencyEnabled' =>
Serialize::booleanToString($options['emergencyEnabled']),
'IsoCountry' =>
$options['isoCountry'],
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
$response = $this->version->page('GET', $this->uri, $params, [], $headers);
return new AddressPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of AddressInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return AddressPage Page of AddressInstance
*/
public function getPage(string $targetUrl): AddressPage
{
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new AddressPage($this->version, $response, $this->solution);
}
/**
* Constructs a AddressContext
*
* @param string $sid The Twilio-provided string that uniquely identifies the Address resource to delete.
*/
public function getContext(
string $sid
): AddressContext
{
return new AddressContext(
$this->version,
$this->solution['accountSid'],
$sid
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.Api.V2010.AddressList]';
}
}

View File

@@ -0,0 +1,436 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Api
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Options;
use Twilio\Values;
abstract class AddressOptions
{
/**
* @param string $friendlyName A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
* @param bool $emergencyEnabled Whether to enable emergency calling on the new address. Can be: `true` or `false`.
* @param bool $autoCorrectAddress Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
* @param string $streetSecondary The additional number and street address of the address.
* @return CreateAddressOptions Options builder
*/
public static function create(
string $friendlyName = Values::NONE,
bool $emergencyEnabled = Values::BOOL_NONE,
bool $autoCorrectAddress = Values::BOOL_NONE,
string $streetSecondary = Values::NONE
): CreateAddressOptions
{
return new CreateAddressOptions(
$friendlyName,
$emergencyEnabled,
$autoCorrectAddress,
$streetSecondary
);
}
/**
* @param string $customerName The `customer_name` of the Address resources to read.
* @param string $friendlyName The string that identifies the Address resources to read.
* @param bool $emergencyEnabled Whether the address can be associated to a number for emergency calling.
* @param string $isoCountry The ISO country code of the Address resources to read.
* @return ReadAddressOptions Options builder
*/
public static function read(
string $customerName = Values::NONE,
string $friendlyName = Values::NONE,
bool $emergencyEnabled = Values::BOOL_NONE,
string $isoCountry = Values::NONE
): ReadAddressOptions
{
return new ReadAddressOptions(
$customerName,
$friendlyName,
$emergencyEnabled,
$isoCountry
);
}
/**
* @param string $friendlyName A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
* @param string $customerName The name to associate with the address.
* @param string $street The number and street address of the address.
* @param string $city The city of the address.
* @param string $region The state or region of the address.
* @param string $postalCode The postal code of the address.
* @param bool $emergencyEnabled Whether to enable emergency calling on the address. Can be: `true` or `false`.
* @param bool $autoCorrectAddress Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
* @param string $streetSecondary The additional number and street address of the address.
* @return UpdateAddressOptions Options builder
*/
public static function update(
string $friendlyName = Values::NONE,
string $customerName = Values::NONE,
string $street = Values::NONE,
string $city = Values::NONE,
string $region = Values::NONE,
string $postalCode = Values::NONE,
bool $emergencyEnabled = Values::BOOL_NONE,
bool $autoCorrectAddress = Values::BOOL_NONE,
string $streetSecondary = Values::NONE
): UpdateAddressOptions
{
return new UpdateAddressOptions(
$friendlyName,
$customerName,
$street,
$city,
$region,
$postalCode,
$emergencyEnabled,
$autoCorrectAddress,
$streetSecondary
);
}
}
class CreateAddressOptions extends Options
{
/**
* @param string $friendlyName A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
* @param bool $emergencyEnabled Whether to enable emergency calling on the new address. Can be: `true` or `false`.
* @param bool $autoCorrectAddress Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
* @param string $streetSecondary The additional number and street address of the address.
*/
public function __construct(
string $friendlyName = Values::NONE,
bool $emergencyEnabled = Values::BOOL_NONE,
bool $autoCorrectAddress = Values::BOOL_NONE,
string $streetSecondary = Values::NONE
) {
$this->options['friendlyName'] = $friendlyName;
$this->options['emergencyEnabled'] = $emergencyEnabled;
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
$this->options['streetSecondary'] = $streetSecondary;
}
/**
* A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
*
* @param string $friendlyName A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Whether to enable emergency calling on the new address. Can be: `true` or `false`.
*
* @param bool $emergencyEnabled Whether to enable emergency calling on the new address. Can be: `true` or `false`.
* @return $this Fluent Builder
*/
public function setEmergencyEnabled(bool $emergencyEnabled): self
{
$this->options['emergencyEnabled'] = $emergencyEnabled;
return $this;
}
/**
* Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
*
* @param bool $autoCorrectAddress Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
* @return $this Fluent Builder
*/
public function setAutoCorrectAddress(bool $autoCorrectAddress): self
{
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
return $this;
}
/**
* The additional number and street address of the address.
*
* @param string $streetSecondary The additional number and street address of the address.
* @return $this Fluent Builder
*/
public function setStreetSecondary(string $streetSecondary): self
{
$this->options['streetSecondary'] = $streetSecondary;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.CreateAddressOptions ' . $options . ']';
}
}
class ReadAddressOptions extends Options
{
/**
* @param string $customerName The `customer_name` of the Address resources to read.
* @param string $friendlyName The string that identifies the Address resources to read.
* @param bool $emergencyEnabled Whether the address can be associated to a number for emergency calling.
* @param string $isoCountry The ISO country code of the Address resources to read.
*/
public function __construct(
string $customerName = Values::NONE,
string $friendlyName = Values::NONE,
bool $emergencyEnabled = Values::BOOL_NONE,
string $isoCountry = Values::NONE
) {
$this->options['customerName'] = $customerName;
$this->options['friendlyName'] = $friendlyName;
$this->options['emergencyEnabled'] = $emergencyEnabled;
$this->options['isoCountry'] = $isoCountry;
}
/**
* The `customer_name` of the Address resources to read.
*
* @param string $customerName The `customer_name` of the Address resources to read.
* @return $this Fluent Builder
*/
public function setCustomerName(string $customerName): self
{
$this->options['customerName'] = $customerName;
return $this;
}
/**
* The string that identifies the Address resources to read.
*
* @param string $friendlyName The string that identifies the Address resources to read.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Whether the address can be associated to a number for emergency calling.
*
* @param bool $emergencyEnabled Whether the address can be associated to a number for emergency calling.
* @return $this Fluent Builder
*/
public function setEmergencyEnabled(bool $emergencyEnabled): self
{
$this->options['emergencyEnabled'] = $emergencyEnabled;
return $this;
}
/**
* The ISO country code of the Address resources to read.
*
* @param string $isoCountry The ISO country code of the Address resources to read.
* @return $this Fluent Builder
*/
public function setIsoCountry(string $isoCountry): self
{
$this->options['isoCountry'] = $isoCountry;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.ReadAddressOptions ' . $options . ']';
}
}
class UpdateAddressOptions extends Options
{
/**
* @param string $friendlyName A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
* @param string $customerName The name to associate with the address.
* @param string $street The number and street address of the address.
* @param string $city The city of the address.
* @param string $region The state or region of the address.
* @param string $postalCode The postal code of the address.
* @param bool $emergencyEnabled Whether to enable emergency calling on the address. Can be: `true` or `false`.
* @param bool $autoCorrectAddress Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
* @param string $streetSecondary The additional number and street address of the address.
*/
public function __construct(
string $friendlyName = Values::NONE,
string $customerName = Values::NONE,
string $street = Values::NONE,
string $city = Values::NONE,
string $region = Values::NONE,
string $postalCode = Values::NONE,
bool $emergencyEnabled = Values::BOOL_NONE,
bool $autoCorrectAddress = Values::BOOL_NONE,
string $streetSecondary = Values::NONE
) {
$this->options['friendlyName'] = $friendlyName;
$this->options['customerName'] = $customerName;
$this->options['street'] = $street;
$this->options['city'] = $city;
$this->options['region'] = $region;
$this->options['postalCode'] = $postalCode;
$this->options['emergencyEnabled'] = $emergencyEnabled;
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
$this->options['streetSecondary'] = $streetSecondary;
}
/**
* A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
*
* @param string $friendlyName A descriptive string that you create to describe the new address. It can be up to 64 characters long for Regulatory Compliance addresses and 32 characters long for Emergency addresses.
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self
{
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The name to associate with the address.
*
* @param string $customerName The name to associate with the address.
* @return $this Fluent Builder
*/
public function setCustomerName(string $customerName): self
{
$this->options['customerName'] = $customerName;
return $this;
}
/**
* The number and street address of the address.
*
* @param string $street The number and street address of the address.
* @return $this Fluent Builder
*/
public function setStreet(string $street): self
{
$this->options['street'] = $street;
return $this;
}
/**
* The city of the address.
*
* @param string $city The city of the address.
* @return $this Fluent Builder
*/
public function setCity(string $city): self
{
$this->options['city'] = $city;
return $this;
}
/**
* The state or region of the address.
*
* @param string $region The state or region of the address.
* @return $this Fluent Builder
*/
public function setRegion(string $region): self
{
$this->options['region'] = $region;
return $this;
}
/**
* The postal code of the address.
*
* @param string $postalCode The postal code of the address.
* @return $this Fluent Builder
*/
public function setPostalCode(string $postalCode): self
{
$this->options['postalCode'] = $postalCode;
return $this;
}
/**
* Whether to enable emergency calling on the address. Can be: `true` or `false`.
*
* @param bool $emergencyEnabled Whether to enable emergency calling on the address. Can be: `true` or `false`.
* @return $this Fluent Builder
*/
public function setEmergencyEnabled(bool $emergencyEnabled): self
{
$this->options['emergencyEnabled'] = $emergencyEnabled;
return $this;
}
/**
* Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
*
* @param bool $autoCorrectAddress Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
* @return $this Fluent Builder
*/
public function setAutoCorrectAddress(bool $autoCorrectAddress): self
{
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
return $this;
}
/**
* The additional number and street address of the address.
*
* @param string $streetSecondary The additional number and street address of the address.
* @return $this Fluent Builder
*/
public function setStreetSecondary(string $streetSecondary): self
{
$this->options['streetSecondary'] = $streetSecondary;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.UpdateAddressOptions ' . $options . ']';
}
}

Some files were not shown because too many files have changed in this diff Show More