Вход Регистрация
Файл: sngine-v2.8/Script/includes/libs/Twilio/Rest/Client.php
Строк: 1418
<?php

/**
 * This code was generated by
 *  / _    _  _|   _  _
 * | (_)/(_)(_|/| |(/_  v1.0.0
 * /       /
 */

namespace TwilioRest;

use 
TwilioExceptionsConfigurationException;
use 
TwilioExceptionsTwilioException;
use 
TwilioHttpClient as HttpClient;
use 
TwilioHttpCurlClient;
use 
TwilioSecurityRequestValidator;
use 
TwilioVersionInfo;

/**
 * A client for accessing the Twilio API.
 *
 * @property Accounts $accounts
 * @property Api $api
 * @property Authy $authy
 * @property Autopilot $autopilot
 * @property Chat $chat
 * @property Conversations $conversations
 * @property Fax $fax
 * @property FlexApi $flexApi
 * @property Insights $insights
 * @property IpMessaging $ipMessaging
 * @property Lookups $lookups
 * @property Messaging $messaging
 * @property Monitor $monitor
 * @property Notify $notify
 * @property Numbers $numbers
 * @property Preview $preview
 * @property Pricing $pricing
 * @property Proxy $proxy
 * @property Serverless $serverless
 * @property Studio $studio
 * @property Sync $sync
 * @property Taskrouter $taskrouter
 * @property Trunking $trunking
 * @property Verify $verify
 * @property Video $video
 * @property Voice $voice
 * @property Wireless $wireless
 * @property Supersim $supersim
 * @property Bulkexports $bulkexports
 * @property TwilioRestApiV2010AccountInstance $account
 * @property TwilioRestApiV2010AccountAddressList $addresses
 * @property TwilioRestApiV2010AccountApplicationList $applications
 * @property TwilioRestApiV2010AccountAuthorizedConnectAppList $authorizedConnectApps
 * @property TwilioRestApiV2010AccountAvailablePhoneNumberCountryList $availablePhoneNumbers
 * @property TwilioRestApiV2010AccountBalanceList $balance
 * @property TwilioRestApiV2010AccountCallList $calls
 * @property TwilioRestApiV2010AccountConferenceList $conferences
 * @property TwilioRestApiV2010AccountConnectAppList $connectApps
 * @property TwilioRestApiV2010AccountIncomingPhoneNumberList $incomingPhoneNumbers
 * @property TwilioRestApiV2010AccountKeyList $keys
 * @property TwilioRestApiV2010AccountMessageList $messages
 * @property TwilioRestApiV2010AccountNewKeyList $newKeys
 * @property TwilioRestApiV2010AccountNewSigningKeyList $newSigningKeys
 * @property TwilioRestApiV2010AccountNotificationList $notifications
 * @property TwilioRestApiV2010AccountOutgoingCallerIdList $outgoingCallerIds
 * @property TwilioRestApiV2010AccountQueueList $queues
 * @property TwilioRestApiV2010AccountRecordingList $recordings
 * @property TwilioRestApiV2010AccountSigningKeyList $signingKeys
 * @property TwilioRestApiV2010AccountSipList $sip
 * @property TwilioRestApiV2010AccountShortCodeList $shortCodes
 * @property TwilioRestApiV2010AccountTokenList $tokens
 * @property TwilioRestApiV2010AccountTranscriptionList $transcriptions
 * @property TwilioRestApiV2010AccountUsageList $usage
 * @property TwilioRestApiV2010AccountValidationRequestList $validationRequests
 * @method TwilioRestApiV2010AccountContext accounts(string $sid)
 * @method TwilioRestApiV2010AccountAddressContext addresses(string $sid)
 * @method TwilioRestApiV2010AccountApplicationContext applications(string $sid)
 * @method TwilioRestApiV2010AccountAuthorizedConnectAppContext authorizedConnectApps(string $connectAppSid)
 * @method TwilioRestApiV2010AccountAvailablePhoneNumberCountryContext availablePhoneNumbers(string $countryCode)
 * @method TwilioRestApiV2010AccountCallContext calls(string $sid)
 * @method TwilioRestApiV2010AccountConferenceContext conferences(string $sid)
 * @method TwilioRestApiV2010AccountConnectAppContext connectApps(string $sid)
 * @method TwilioRestApiV2010AccountIncomingPhoneNumberContext incomingPhoneNumbers(string $sid)
 * @method TwilioRestApiV2010AccountKeyContext keys(string $sid)
 * @method TwilioRestApiV2010AccountMessageContext messages(string $sid)
 * @method TwilioRestApiV2010AccountNotificationContext notifications(string $sid)
 * @method TwilioRestApiV2010AccountOutgoingCallerIdContext outgoingCallerIds(string $sid)
 * @method TwilioRestApiV2010AccountQueueContext queues(string $sid)
 * @method TwilioRestApiV2010AccountRecordingContext recordings(string $sid)
 * @method TwilioRestApiV2010AccountSigningKeyContext signingKeys(string $sid)
 * @method TwilioRestApiV2010AccountShortCodeContext shortCodes(string $sid)
 * @method TwilioRestApiV2010AccountTranscriptionContext transcriptions(string $sid)
 */
class Client {
    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';

    protected 
$username;
    protected 
$password;
    protected 
$accountSid;
    protected 
$region;
    protected 
$edge;
    protected 
$httpClient;
    protected 
$environment;
    protected 
$_account;
    protected 
$_accounts;
    protected 
$_api;
    protected 
$_authy;
    protected 
$_autopilot;
    protected 
$_chat;
    protected 
$_conversations;
    protected 
$_fax;
    protected 
$_flexApi;
    protected 
$_insights;
    protected 
$_ipMessaging;
    protected 
$_lookups;
    protected 
$_messaging;
    protected 
$_monitor;
    protected 
$_notify;
    protected 
$_numbers;
    protected 
$_preview;
    protected 
$_pricing;
    protected 
$_proxy;
    protected 
$_serverless;
    protected 
$_studio;
    protected 
$_sync;
    protected 
$_taskrouter;
    protected 
$_trunking;
    protected 
$_verify;
    protected 
$_video;
    protected 
$_voice;
    protected 
$_wireless;
    protected 
$_supersim;
    protected 
$_bulkexports;

    
/**
     * 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
     * @throws ConfigurationException If valid authentication is not present
     */
    
public function __construct(string $username nullstring $password nullstring $accountSid nullstring $region nullHttpClient $httpClient null, array $environment null) {
        
$this->environment $environment ?: getenv();

        
$this->username $this->getArg($usernameself::ENV_ACCOUNT_SID);
        
$this->password $this->getArg($passwordself::ENV_AUTH_TOKEN);
        
$this->region $this->getArg($regionself::ENV_REGION);
        
$this->edge $this->getArg(nullself::ENV_EDGE);

        if (!
$this->username || !$this->password) {
            throw new 
ConfigurationException('Credentials are required to create a Client');
        }

        
$this->accountSid $accountSid ?: $this->username;

        if (
$httpClient) {
            
$this->httpClient $httpClient;
        } else {
            
$this->httpClient = new CurlClient();
        }
    }

    
/**
     * 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 $argstring $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
     * @return TwilioHttpResponse Response from the Twilio API
     */
    
public function request(string $methodstring $uri, array $params = [], array $data = [], array $headers = [], string $username nullstring $password nullint $timeout null): TwilioHttpResponse {
        
$username $username ?: $this->username;
        
$password $password ?: $this->password;

        
$headers['User-Agent'] = 'twilio-php/' VersionInfo::string() .
                                 
' (PHP ' PHP_VERSION ')';
        
$headers['Accept-Charset'] = 'utf-8';

        if (
$method === 'POST' && !array_key_exists('Content-Type'$headers)) {
            
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
        }

        if (!
array_key_exists('Accept'$headers)) {
            
$headers['Accept'] = 'application/json';
        }

        
$uri $this->buildUri($uri);

        return 
$this->getHttpClient()->request(
            
$method,
            
$uri,
            
$params,
            
$data,
            
$headers,
            
$username,
            
$password,
            
$timeout
        
);
    }

    
/**
     * 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);
    }

    
/**
     * 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 $uri Edge to use, unsets the Edge when called with no arguments
     */
    
public function setEdge(string $edge null): void {
        
$this->edge $this->getArg($edgeself::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;
    }

    
/**
     * Access the Accounts Twilio Domain
     *
     * @return Accounts Accounts Twilio Domain
     */
    
protected function getAccounts(): Accounts {
        if (!
$this->_accounts) {
            
$this->_accounts = new Accounts($this);
        }
        return 
$this->_accounts;
    }

    
/**
     * Access the Api Twilio Domain
     *
     * @return Api Api Twilio Domain
     */
    
protected function getApi(): Api {
        if (!
$this->_api) {
            
$this->_api = new Api($this);
        }
        return 
$this->_api;
    }

    
/**
     * @return TwilioRestApiV2010AccountContext Account provided as the
     *                                               authenticating account
     */
    
public function getAccount(): TwilioRestApiV2010AccountContext {
        return 
$this->api->v2010->account;
    }

    protected function 
getAddresses(): TwilioRestApiV2010AccountAddressList {
        return 
$this->api->v2010->account->addresses;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextAddresses(string $sid): TwilioRestApiV2010AccountAddressContext {
        return 
$this->api->v2010->account->addresses($sid);
    }

    protected function 
getApplications(): TwilioRestApiV2010AccountApplicationList {
        return 
$this->api->v2010->account->applications;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextApplications(string $sid): TwilioRestApiV2010AccountApplicationContext {
        return 
$this->api->v2010->account->applications($sid);
    }

    protected function 
getAuthorizedConnectApps(): TwilioRestApiV2010AccountAuthorizedConnectAppList {
        return 
$this->api->v2010->account->authorizedConnectApps;
    }

    
/**
     * @param string $connectAppSid The SID of the Connect App to fetch
     */
    
protected function contextAuthorizedConnectApps(string $connectAppSid): TwilioRestApiV2010AccountAuthorizedConnectAppContext {
        return 
$this->api->v2010->account->authorizedConnectApps($connectAppSid);
    }

    protected function 
getAvailablePhoneNumbers(): TwilioRestApiV2010AccountAvailablePhoneNumberCountryList {
        return 
$this->api->v2010->account->availablePhoneNumbers;
    }

    
/**
     * @param string $countryCode The ISO country code of the country to fetch
     *                            available phone number information about
     */
    
protected function contextAvailablePhoneNumbers(string $countryCode): TwilioRestApiV2010AccountAvailablePhoneNumberCountryContext {
        return 
$this->api->v2010->account->availablePhoneNumbers($countryCode);
    }

    protected function 
getBalance(): TwilioRestApiV2010AccountBalanceList {
        return 
$this->api->v2010->account->balance;
    }

    protected function 
getCalls(): TwilioRestApiV2010AccountCallList {
        return 
$this->api->v2010->account->calls;
    }

    
/**
     * @param string $sid The SID of the Call resource to fetch
     */
    
protected function contextCalls(string $sid): TwilioRestApiV2010AccountCallContext {
        return 
$this->api->v2010->account->calls($sid);
    }

    protected function 
getConferences(): TwilioRestApiV2010AccountConferenceList {
        return 
$this->api->v2010->account->conferences;
    }

    
/**
     * @param string $sid The unique string that identifies this resource
     */
    
protected function contextConferences(string $sid): TwilioRestApiV2010AccountConferenceContext {
        return 
$this->api->v2010->account->conferences($sid);
    }

    protected function 
getConnectApps(): TwilioRestApiV2010AccountConnectAppList {
        return 
$this->api->v2010->account->connectApps;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextConnectApps(string $sid): TwilioRestApiV2010AccountConnectAppContext {
        return 
$this->api->v2010->account->connectApps($sid);
    }

    protected function 
getIncomingPhoneNumbers(): TwilioRestApiV2010AccountIncomingPhoneNumberList {
        return 
$this->api->v2010->account->incomingPhoneNumbers;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextIncomingPhoneNumbers(string $sid): TwilioRestApiV2010AccountIncomingPhoneNumberContext {
        return 
$this->api->v2010->account->incomingPhoneNumbers($sid);
    }

    protected function 
getKeys(): TwilioRestApiV2010AccountKeyList {
        return 
$this->api->v2010->account->keys;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextKeys(string $sid): TwilioRestApiV2010AccountKeyContext {
        return 
$this->api->v2010->account->keys($sid);
    }

    protected function 
getMessages(): TwilioRestApiV2010AccountMessageList {
        return 
$this->api->v2010->account->messages;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextMessages(string $sid): TwilioRestApiV2010AccountMessageContext {
        return 
$this->api->v2010->account->messages($sid);
    }

    protected function 
getNewKeys(): TwilioRestApiV2010AccountNewKeyList {
        return 
$this->api->v2010->account->newKeys;
    }

    protected function 
getNewSigningKeys(): TwilioRestApiV2010AccountNewSigningKeyList {
        return 
$this->api->v2010->account->newSigningKeys;
    }

    protected function 
getNotifications(): TwilioRestApiV2010AccountNotificationList {
        return 
$this->api->v2010->account->notifications;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextNotifications(string $sid): TwilioRestApiV2010AccountNotificationContext {
        return 
$this->api->v2010->account->notifications($sid);
    }

    protected function 
getOutgoingCallerIds(): TwilioRestApiV2010AccountOutgoingCallerIdList {
        return 
$this->api->v2010->account->outgoingCallerIds;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextOutgoingCallerIds(string $sid): TwilioRestApiV2010AccountOutgoingCallerIdContext {
        return 
$this->api->v2010->account->outgoingCallerIds($sid);
    }

    protected function 
getQueues(): TwilioRestApiV2010AccountQueueList {
        return 
$this->api->v2010->account->queues;
    }

    
/**
     * @param string $sid The unique string that identifies this resource
     */
    
protected function contextQueues(string $sid): TwilioRestApiV2010AccountQueueContext {
        return 
$this->api->v2010->account->queues($sid);
    }

    protected function 
getRecordings(): TwilioRestApiV2010AccountRecordingList {
        return 
$this->api->v2010->account->recordings;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextRecordings(string $sid): TwilioRestApiV2010AccountRecordingContext {
        return 
$this->api->v2010->account->recordings($sid);
    }

    protected function 
getSigningKeys(): TwilioRestApiV2010AccountSigningKeyList {
        return 
$this->api->v2010->account->signingKeys;
    }

    
/**
     * @param string $sid The sid
     */
    
protected function contextSigningKeys(string $sid): TwilioRestApiV2010AccountSigningKeyContext {
        return 
$this->api->v2010->account->signingKeys($sid);
    }

    protected function 
getSip(): TwilioRestApiV2010AccountSipList {
        return 
$this->api->v2010->account->sip;
    }

    protected function 
getShortCodes(): TwilioRestApiV2010AccountShortCodeList {
        return 
$this->api->v2010->account->shortCodes;
    }

    
/**
     * @param string $sid The unique string that identifies this resource
     */
    
protected function contextShortCodes(string $sid): TwilioRestApiV2010AccountShortCodeContext {
        return 
$this->api->v2010->account->shortCodes($sid);
    }

    protected function 
getTokens(): TwilioRestApiV2010AccountTokenList {
        return 
$this->api->v2010->account->tokens;
    }

    protected function 
getTranscriptions(): TwilioRestApiV2010AccountTranscriptionList {
        return 
$this->api->v2010->account->transcriptions;
    }

    
/**
     * @param string $sid The unique string that identifies the resource
     */
    
protected function contextTranscriptions(string $sid): TwilioRestApiV2010AccountTranscriptionContext {
        return 
$this->api->v2010->account->transcriptions($sid);
    }

    protected function 
getUsage(): TwilioRestApiV2010AccountUsageList {
        return 
$this->api->v2010->account->usage;
    }

    protected function 
getValidationRequests(): TwilioRestApiV2010AccountValidationRequestList {
        return 
$this->api->v2010->account->validationRequests;
    }

    
/**
     * Access the Authy Twilio Domain
     *
     * @return Authy Authy Twilio Domain
     */
    
protected function getAuthy(): Authy {
        if (!
$this->_authy) {
            
$this->_authy = new Authy($this);
        }
        return 
$this->_authy;
    }

    
/**
     * Access the Autopilot Twilio Domain
     *
     * @return Autopilot Autopilot Twilio Domain
     */
    
protected function getAutopilot(): Autopilot {
        if (!
$this->_autopilot) {
            
$this->_autopilot = new Autopilot($this);
        }
        return 
$this->_autopilot;
    }

    
/**
     * Access the Chat Twilio Domain
     *
     * @return Chat Chat Twilio Domain
     */
    
protected function getChat(): Chat {
        if (!
$this->_chat) {
            
$this->_chat = new Chat($this);
        }
        return 
$this->_chat;
    }

    
/**
     * Access the Conversations Twilio Domain
     *
     * @return Conversations Conversations Twilio Domain
     */
    
protected function getConversations(): Conversations {
        if (!
$this->_conversations) {
            
$this->_conversations = new Conversations($this);
        }
        return 
$this->_conversations;
    }

    
/**
     * Access the Fax Twilio Domain
     *
     * @return Fax Fax Twilio Domain
     */
    
protected function getFax(): Fax {
        if (!
$this->_fax) {
            
$this->_fax = new Fax($this);
        }
        return 
$this->_fax;
    }

    
/**
     * Access the FlexApi Twilio Domain
     *
     * @return FlexApi FlexApi Twilio Domain
     */
    
protected function getFlexApi(): FlexApi {
        if (!
$this->_flexApi) {
            
$this->_flexApi = new FlexApi($this);
        }
        return 
$this->_flexApi;
    }

    
/**
     * Access the Insights Twilio Domain
     *
     * @return Insights Insights Twilio Domain
     */
    
protected function getInsights(): Insights {
        if (!
$this->_insights) {
            
$this->_insights = new Insights($this);
        }
        return 
$this->_insights;
    }

    
/**
     * Access the IpMessaging Twilio Domain
     *
     * @return IpMessaging IpMessaging Twilio Domain
     */
    
protected function getIpMessaging(): IpMessaging {
        if (!
$this->_ipMessaging) {
            
$this->_ipMessaging = new IpMessaging($this);
        }
        return 
$this->_ipMessaging;
    }

    
/**
     * Access the Lookups Twilio Domain
     *
     * @return Lookups Lookups Twilio Domain
     */
    
protected function getLookups(): Lookups {
        if (!
$this->_lookups) {
            
$this->_lookups = new Lookups($this);
        }
        return 
$this->_lookups;
    }

    
/**
     * Access the Messaging Twilio Domain
     *
     * @return Messaging Messaging Twilio Domain
     */
    
protected function getMessaging(): Messaging {
        if (!
$this->_messaging) {
            
$this->_messaging = new Messaging($this);
        }
        return 
$this->_messaging;
    }

    
/**
     * Access the Monitor Twilio Domain
     *
     * @return Monitor Monitor Twilio Domain
     */
    
protected function getMonitor(): Monitor {
        if (!
$this->_monitor) {
            
$this->_monitor = new Monitor($this);
        }
        return 
$this->_monitor;
    }

    
/**
     * Access the Notify Twilio Domain
     *
     * @return Notify Notify Twilio Domain
     */
    
protected function getNotify(): Notify {
        if (!
$this->_notify) {
            
$this->_notify = new Notify($this);
        }
        return 
$this->_notify;
    }

    
/**
     * Access the Numbers Twilio Domain
     *
     * @return Numbers Numbers Twilio Domain
     */
    
protected function getNumbers(): Numbers {
        if (!
$this->_numbers) {
            
$this->_numbers = new Numbers($this);
        }
        return 
$this->_numbers;
    }

    
/**
     * Access the Preview Twilio Domain
     *
     * @return Preview Preview Twilio Domain
     */
    
protected function getPreview(): Preview {
        if (!
$this->_preview) {
            
$this->_preview = new Preview($this);
        }
        return 
$this->_preview;
    }

    
/**
     * Access the Pricing Twilio Domain
     *
     * @return Pricing Pricing Twilio Domain
     */
    
protected function getPricing(): Pricing {
        if (!
$this->_pricing) {
            
$this->_pricing = new Pricing($this);
        }
        return 
$this->_pricing;
    }

    
/**
     * Access the Proxy Twilio Domain
     *
     * @return Proxy Proxy Twilio Domain
     */
    
protected function getProxy(): Proxy {
        if (!
$this->_proxy) {
            
$this->_proxy = new Proxy($this);
        }
        return 
$this->_proxy;
    }

    
/**
     * Access the Serverless Twilio Domain
     *
     * @return Serverless Serverless Twilio Domain
     */
    
protected function getServerless(): Serverless {
        if (!
$this->_serverless) {
            
$this->_serverless = new Serverless($this);
        }
        return 
$this->_serverless;
    }

    
/**
     * Access the Studio Twilio Domain
     *
     * @return Studio Studio Twilio Domain
     */
    
protected function getStudio(): Studio {
        if (!
$this->_studio) {
            
$this->_studio = new Studio($this);
        }
        return 
$this->_studio;
    }

    
/**
     * Access the Sync Twilio Domain
     *
     * @return Sync Sync Twilio Domain
     */
    
protected function getSync(): Sync {
        if (!
$this->_sync) {
            
$this->_sync = new Sync($this);
        }
        return 
$this->_sync;
    }

    
/**
     * Access the Taskrouter Twilio Domain
     *
     * @return Taskrouter Taskrouter Twilio Domain
     */
    
protected function getTaskrouter(): Taskrouter {
        if (!
$this->_taskrouter) {
            
$this->_taskrouter = new Taskrouter($this);
        }
        return 
$this->_taskrouter;
    }

    
/**
     * Access the Trunking Twilio Domain
     *
     * @return Trunking Trunking Twilio Domain
     */
    
protected function getTrunking(): Trunking {
        if (!
$this->_trunking) {
            
$this->_trunking = new Trunking($this);
        }
        return 
$this->_trunking;
    }

    
/**
     * Access the Verify Twilio Domain
     *
     * @return Verify Verify Twilio Domain
     */
    
protected function getVerify(): Verify {
        if (!
$this->_verify) {
            
$this->_verify = new Verify($this);
        }
        return 
$this->_verify;
    }

    
/**
     * Access the Video Twilio Domain
     *
     * @return Video Video Twilio Domain
     */
    
protected function getVideo(): Video {
        if (!
$this->_video) {
            
$this->_video = new Video($this);
        }
        return 
$this->_video;
    }

    
/**
     * Access the Voice Twilio Domain
     *
     * @return Voice Voice Twilio Domain
     */
    
protected function getVoice(): Voice {
        if (!
$this->_voice) {
            
$this->_voice = new Voice($this);
        }
        return 
$this->_voice;
    }

    
/**
     * Access the Wireless Twilio Domain
     *
     * @return Wireless Wireless Twilio Domain
     */
    
protected function getWireless(): Wireless {
        if (!
$this->_wireless) {
            
$this->_wireless = new Wireless($this);
        }
        return 
$this->_wireless;
    }

    
/**
     * Access the Supersim Twilio Domain
     *
     * @return Supersim Supersim Twilio Domain
     */
    
protected function getSupersim(): Supersim {
        if (!
$this->_supersim) {
            
$this->_supersim = new Supersim($this);
        }
        return 
$this->_supersim;
    }

    
/**
     * Access the Bulkexports Twilio Domain
     *
     * @return Bulkexports Bulkexports Twilio Domain
     */
    
protected function getBulkexports(): Bulkexports {
        if (!
$this->_bulkexports) {
            
$this->_bulkexports = new Bulkexports($this);
        }
        return 
$this->_bulkexports;
    }

    
/**
     * Magic getter to lazy load domains
     *
     * @param string $name Domain to return
     * @return TwilioDomain 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 TwilioInstanceContext 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://api.twilio.com:8443');

        if (
$response->getStatusCode() < 200 || $response->getStatusCode() > 300) {
            throw new 
TwilioException('Failed to validate SSL certificate');
        }
    }
}
Онлайн: 0
Реклама