update lock clucknut
All checks were successful
All checks were successful
This commit is contained in:
304
vendor/twilio/sdk/example/test_metadata_functions.php
vendored
Normal file
304
vendor/twilio/sdk/example/test_metadata_functions.php
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
require(__DIR__.'/../src/Twilio/autoload.php');
|
||||
|
||||
use Twilio\Rest\Client;
|
||||
use Twilio\Exceptions\TwilioException;
|
||||
|
||||
function printMessageObject($msg) {
|
||||
if(is_bool($msg)) {
|
||||
print "Status: " . $msg . "\n";
|
||||
}
|
||||
else {
|
||||
print "Sid: " . $msg->sid . "\n";
|
||||
print "From: " . $msg->from . "\n";
|
||||
print "To: " . $msg->to . "\n";
|
||||
print "Body: " . $msg->body . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function handleResponse($responseMetadata) {
|
||||
if(is_bool($responseMetadata)) {
|
||||
print printMessageObject($responseMetadata) . "\n\n";
|
||||
}
|
||||
else if(\method_exists($responseMetadata, "getHeaders")) {
|
||||
$resource = $responseMetadata->getResource();
|
||||
$statusCode = $responseMetadata->getStatusCode();
|
||||
print printMessageObject($resource) . "\n\n";
|
||||
print "Status code: " . $statusCode . "\n\n";
|
||||
print "Headers: " . json_encode($responseMetadata->getHeaders()) . "\n\n";
|
||||
}
|
||||
else {
|
||||
print printMessageObject($responseMetadata) . "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
function handlePage($page, $limit, $pageSize) {
|
||||
$current_page = $page;
|
||||
$pages = ceil($limit / $pageSize);
|
||||
for ($i = 0; $i < $pages; $i++) {
|
||||
print "Page: " . $i . "\n";
|
||||
if (\method_exists($page, "getHeaders")) {
|
||||
$headers = $page->getHeaders();
|
||||
$statusCode = $page->getStatusCode();
|
||||
print "Status code: " . $statusCode . "\n\n";
|
||||
print "Headers: " . json_encode($headers) . "\n\n";
|
||||
}
|
||||
foreach ($current_page as $msg) {
|
||||
print printMessageObject($msg) . "\n";
|
||||
}
|
||||
$current_page = $current_page->nextPage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function handleSteam($stream) {
|
||||
foreach ($stream as $msg) {
|
||||
if (\method_exists($stream, "getHeaders")) {
|
||||
$headers = $stream->getHeaders();
|
||||
$statusCode = $stream->getStatusCode();
|
||||
print "Status code: " . $statusCode . "\n\n";
|
||||
print "Headers: " . json_encode($headers) . "\n\n";
|
||||
}
|
||||
print printMessageObject($msg) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function handleRead($obj) {
|
||||
if(!is_array($obj))
|
||||
{
|
||||
if (\method_exists($obj, "getHeaders")) {
|
||||
$headers = $obj->getHeaders();
|
||||
$statusCode = $obj->getStatusCode();
|
||||
print "Status code: " . $statusCode . "\n\n";
|
||||
print "Headers: " . json_encode($headers) . "\n\n";
|
||||
}
|
||||
}
|
||||
foreach ($obj as $msg) {
|
||||
print printMessageObject($msg) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function createMessage(Client $client, string $from, string $to)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages->create($to,[
|
||||
'From' => $from,
|
||||
'Body' => 'Hello from metadata'
|
||||
]);
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function createMessageWithMetadata(Client $client, string $from, string $to)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages->createWithMetadata($to,[
|
||||
'From' => $from,
|
||||
'Body' => 'Hello from metadata'
|
||||
]);
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fetchMessage(Client $client, string $sid)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages($sid)->fetch();
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function fetchMessageWithMetadata(Client $client, string $sid)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages($sid)->fetchWithMetadata();
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateMessage(Client $client, string $sid)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages($sid)->update([
|
||||
'Body' => ''
|
||||
]);
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function updateMessageWithMetadata(Client $client, string $sid)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages($sid)->updateWithMetadata([
|
||||
'Body' => ''
|
||||
]);
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deleteMessage(Client $client, string $sid)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages($sid)->delete();
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function deleteMessageWithMetadata(Client $client, string $sid)
|
||||
{
|
||||
try {
|
||||
$message = $client->messages($sid)->deleteWithMetadata();
|
||||
handleResponse($message);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pageMessage(Client $client, string $to)
|
||||
{
|
||||
$limit = 6;
|
||||
$pageSize = 2;
|
||||
try {
|
||||
$response = $client->messages->page([
|
||||
'To' => $to,
|
||||
], $pageSize);
|
||||
handlePage($response, $limit, $pageSize);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function pageMessageWithMetadata(Client $client, string $to)
|
||||
{
|
||||
$limit = 6;
|
||||
$pageSize = 2;
|
||||
try {
|
||||
$response = $client->messages->pageWithMetadata([
|
||||
'To' => $to,
|
||||
], $pageSize);
|
||||
handlePage($response, $limit, $pageSize);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function streamMessage(Client $client, string $to)
|
||||
{
|
||||
$limit = 5;
|
||||
$pageSize = 2;
|
||||
try {
|
||||
$response = $client->messages->stream([
|
||||
'To' => $to,
|
||||
], $limit, $pageSize);
|
||||
handleSteam($response);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function streamMessageWithMetadata(Client $client, string $to)
|
||||
{
|
||||
$limit = 5;
|
||||
$pageSize = 2;
|
||||
try {
|
||||
$response = $client->messages->streamWithMetadata([
|
||||
'To' => $to,
|
||||
], $limit, $pageSize);
|
||||
handleSteam($response);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function readMessageWithMetadata(Client $client, string $to)
|
||||
{
|
||||
$limit = 5;
|
||||
$pageSize = 2;
|
||||
try {
|
||||
$response = $client->messages->readWithMetadata([], $limit, $pageSize);
|
||||
handleRead($response);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
function readMessage(Client $client, string $to)
|
||||
{
|
||||
$limit = 5;
|
||||
$pageSize = 2;
|
||||
try {
|
||||
$response = $client->messages->read([], $limit, $pageSize);
|
||||
handleRead($response);
|
||||
} catch (TwilioException $e) {
|
||||
print "Error: " . $e->getCode() . "\n" . $e->getMessage() . "\n" . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sid = getenv('TWILIO_ACCOUNT_SID');
|
||||
$token = getenv('TWILIO_AUTH_TOKEN');
|
||||
$client = new Client($sid, $token);
|
||||
$from = getenv('TWILIO_PHONE_NUMBER');
|
||||
$to = getenv('RECEIVER_PHONE_NUMBER');
|
||||
|
||||
$messageSid = getenv('MESSAGE_SID');
|
||||
|
||||
//createMessage($client, $from, $to);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//createMessageWithMetadata($client, $from, $to);
|
||||
|
||||
//fetchMessage($client, $messageSid);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//fetchMessageWithMetadata($client, $messageSid);
|
||||
|
||||
//updateMessage($client, $messageSid);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//updateMessageWithMetadata($client, $messageSid);
|
||||
|
||||
//deleteMessage($client, $messageSid);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//deleteMessageWithMetadata($client, $messageSid);
|
||||
|
||||
//pageMessage($client, $to);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//pageMessageWithMetadata($client, $to);
|
||||
|
||||
//streamMessage($client, $to);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//streamMessageWithMetadata($client, $to);
|
||||
|
||||
//readMessage($client, $to);
|
||||
//print "------------------------------------------------------------------------------------------------------\n";
|
||||
//readMessageWithMetadata($client, $to);
|
||||
25
vendor/twilio/sdk/src/Twilio/Base/BaseClient.php
vendored
25
vendor/twilio/sdk/src/Twilio/Base/BaseClient.php
vendored
@@ -67,6 +67,7 @@ public function __construct(
|
||||
$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);
|
||||
|
||||
@@ -161,30 +162,6 @@ public function request(
|
||||
$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');
|
||||
|
||||
58
vendor/twilio/sdk/src/Twilio/Metadata/ArrayMetadata.php
vendored
Normal file
58
vendor/twilio/sdk/src/Twilio/Metadata/ArrayMetadata.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Twilio\Metadata;
|
||||
|
||||
use Iterator;
|
||||
use ArrayIterator;
|
||||
|
||||
/**
|
||||
* Wrapper containing an array along with HTTP response metadata (headers, status code).
|
||||
* Allows access to response headers while maintaining backward compatibility.
|
||||
*
|
||||
* @template T of array
|
||||
*/
|
||||
class ArrayMetadata extends IteratorMetadata
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $array;
|
||||
|
||||
/**
|
||||
* Create array metadata wrapper.
|
||||
*
|
||||
* @param array $array the array returned by read()
|
||||
* @param int $statusCode HTTP status code
|
||||
* @param array<string, string> $headers HTTP response headers
|
||||
*/
|
||||
public function __construct(
|
||||
array $array,
|
||||
int $statusCode,
|
||||
array $headers
|
||||
) {
|
||||
$this->array = $array;
|
||||
// Convert array to ArrayIterator to satisfy parent constructor
|
||||
$arrayIterator = new ArrayIterator($array);
|
||||
parent::__construct($arrayIterator, $statusCode, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getArray(): array
|
||||
{
|
||||
return $this->array;
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of the array metadata.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'ArrayMetadata{' . parent::__toString();
|
||||
}
|
||||
}
|
||||
141
vendor/twilio/sdk/src/Twilio/Metadata/IteratorMetadata.php
vendored
Normal file
141
vendor/twilio/sdk/src/Twilio/Metadata/IteratorMetadata.php
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace Twilio\Metadata;
|
||||
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Wrapper containing an iterator object along with HTTP response metadata (headers, status code).
|
||||
* Allows access to response headers while maintaining backward compatibility.
|
||||
*
|
||||
* @template T of Iterator
|
||||
*/
|
||||
abstract class IteratorMetadata implements Iterator
|
||||
{
|
||||
/**
|
||||
* @var T
|
||||
*/
|
||||
private $iterator;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* Create metadata wrapper.
|
||||
*
|
||||
* @param T $iterator the iterator object (Page, Stream etc.)
|
||||
* @param int $statusCode HTTP status code
|
||||
* @param array<string, string> $headers HTTP response headers
|
||||
*/
|
||||
public function __construct(
|
||||
Iterator $iterator,
|
||||
int $statusCode,
|
||||
array $headers
|
||||
) {
|
||||
$this->iterator = $iterator;
|
||||
$this->statusCode = $statusCode;
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the iterator.
|
||||
*
|
||||
* @return Iterator
|
||||
*/
|
||||
public function getIterator(): Iterator {
|
||||
return $this->iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTTP response headers.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTTP status code.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific header value.
|
||||
*
|
||||
* @param string $headerName name of the header
|
||||
* @return string|null header value or null if not present
|
||||
*/
|
||||
public function getHeader(string $headerName): ?string
|
||||
{
|
||||
return $this->headers[$headerName] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of the page metadata.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string {
|
||||
return 'statusCode=' . $this->getStatusCode() .
|
||||
', headers=' . json_encode($this->getHeaders()) .
|
||||
', array=' . json_encode($this->iterator) .
|
||||
'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of Iterator interface
|
||||
*/
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 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->iterator->current();
|
||||
}
|
||||
|
||||
public function next(): void
|
||||
{
|
||||
$this->iterator->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 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->iterator->key();
|
||||
}
|
||||
|
||||
public function valid(): bool
|
||||
{
|
||||
return $this->iterator->valid();
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
{
|
||||
$this->iterator->rewind();
|
||||
}
|
||||
}
|
||||
75
vendor/twilio/sdk/src/Twilio/Metadata/PageMetadata.php
vendored
Normal file
75
vendor/twilio/sdk/src/Twilio/Metadata/PageMetadata.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Twilio\Metadata;
|
||||
|
||||
use Twilio\Page;
|
||||
|
||||
/**
|
||||
* Wrapper containing a page along with HTTP response metadata (headers, status code).
|
||||
* Allows access to response headers while maintaining backward compatibility.
|
||||
*
|
||||
* @template T of Page
|
||||
*/
|
||||
class PageMetadata extends IteratorMetadata
|
||||
{
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param int $statusCode
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(
|
||||
Page $page,
|
||||
int $statusCode,
|
||||
array $headers
|
||||
) {
|
||||
parent::__construct($page, $statusCode, $headers);
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page.
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function getPage(): Page
|
||||
{
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
public function nextPage(): ?PageMetadata
|
||||
{
|
||||
$nextPageUrl = $this->page->getNextPageUrl();
|
||||
if (!$nextPageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$response = $this->page->getResponse($nextPageUrl);
|
||||
return new static(
|
||||
$this->page->createPage($response),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
public function previousPage(): ?PageMetadata
|
||||
{
|
||||
$previousPageUrl = $this->page->getPreviousPageUrl();
|
||||
if (!$previousPageUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$response = $this->page->getResponse($previousPageUrl);
|
||||
return new static(
|
||||
$this->page->createPage($response),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'ArrayMetadata{' . parent::__toString();
|
||||
}
|
||||
}
|
||||
98
vendor/twilio/sdk/src/Twilio/Metadata/ResourceMetadata.php
vendored
Normal file
98
vendor/twilio/sdk/src/Twilio/Metadata/ResourceMetadata.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Twilio\Metadata;
|
||||
|
||||
use Twilio\InstanceResource;
|
||||
|
||||
/**
|
||||
* Wrapper containing a resource along with HTTP response metadata (headers, status code).
|
||||
* Allows access to response headers while maintaining backward compatibility.
|
||||
*
|
||||
* @template T of InstanceResource
|
||||
*/
|
||||
class ResourceMetadata
|
||||
{
|
||||
/**
|
||||
* @var InstanceResource
|
||||
*/
|
||||
private $resource;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* Create response metadata wrapper.
|
||||
*
|
||||
* @param ?InstanceResource $resource the resource object (Message, Call, etc.)
|
||||
* @param int $statusCode HTTP status code
|
||||
* @param array<string, string> $headers HTTP response headers
|
||||
*/
|
||||
public function __construct(
|
||||
?InstanceResource $resource,
|
||||
int $statusCode,
|
||||
array $headers
|
||||
) {
|
||||
$this->resource = $resource ?? true;
|
||||
$this->statusCode = $statusCode;
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resource.
|
||||
*/
|
||||
public function getResource() {
|
||||
return $this->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTTP response headers.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTTP status code.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific header value.
|
||||
*
|
||||
* @param string $headerName name of the header
|
||||
* @return string|null header value or null if not present
|
||||
*/
|
||||
public function getHeader(string $headerName): ?string
|
||||
{
|
||||
return $this->headers[$headerName] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of the response metadata.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'ResourceMetadata{' .
|
||||
'statusCode=' . $this->statusCode .
|
||||
', headers=' . json_encode($this->headers) .
|
||||
', resource=' . $this->resource .
|
||||
'}';
|
||||
}
|
||||
}
|
||||
47
vendor/twilio/sdk/src/Twilio/Metadata/StreamMetadata.php
vendored
Normal file
47
vendor/twilio/sdk/src/Twilio/Metadata/StreamMetadata.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Twilio\Metadata;
|
||||
|
||||
use Twilio\Page;
|
||||
use Twilio\Stream;
|
||||
use Iterator;
|
||||
|
||||
/**
|
||||
* Wrapper containing a page along with HTTP response metadata (headers, status code).
|
||||
* Allows access to response headers while maintaining backward compatibility.
|
||||
*
|
||||
* @template T of Stream
|
||||
*/
|
||||
class StreamMetadata extends IteratorMetadata
|
||||
{
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @param Stream $stream
|
||||
* @param int $statusCode
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(
|
||||
Stream $stream,
|
||||
int $statusCode,
|
||||
array $headers
|
||||
) {
|
||||
parent::__construct($stream, $statusCode, $headers);
|
||||
$this->stream = $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stream.
|
||||
*
|
||||
* @return Stream
|
||||
*/
|
||||
public function getStream(): Stream
|
||||
{
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'StreamMetadata{' . parent::__toString();
|
||||
}
|
||||
}
|
||||
24
vendor/twilio/sdk/src/Twilio/Page.php
vendored
24
vendor/twilio/sdk/src/Twilio/Page.php
vendored
@@ -120,22 +120,32 @@ public function getNextPageUrl(): ?string {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function nextPage(): ?Page {
|
||||
if (!$this->getNextPageUrl()) {
|
||||
public function getResponse(?string $url): ?Response {
|
||||
if (!$url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$response = $this->getVersion()->getDomain()->getClient()->request('GET', $this->getNextPageUrl());
|
||||
return $this->getVersion()->getDomain()->getClient()->request('GET', $url);
|
||||
}
|
||||
|
||||
public function createPage(Response $response): Page {
|
||||
return new static($this->getVersion(), $response, $this->solution);
|
||||
}
|
||||
|
||||
public function previousPage(): ?Page {
|
||||
if (!$this->getPreviousPageUrl()) {
|
||||
public function nextPage(): ?Page {
|
||||
$response = $this->getResponse($this->getNextPageUrl());
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
return $this->createPage($response);
|
||||
}
|
||||
|
||||
$response = $this->getVersion()->getDomain()->getClient()->request('GET', $this->getPreviousPageUrl());
|
||||
return new static($this->getVersion(), $response, $this->solution);
|
||||
public function previousPage(): ?Page {
|
||||
$response = $this->getResponse($this->getPreviousPageUrl());
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
return $this->createPage($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class AuthTokenPromotionContext extends InstanceContext
|
||||
@@ -42,6 +44,18 @@ public function __construct(
|
||||
$this->uri = '/AuthTokens/Promote';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], [], $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the AuthTokenPromotionInstance
|
||||
*
|
||||
@@ -50,13 +64,31 @@ public function __construct(
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_update();
|
||||
return new AuthTokenPromotionInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the AuthTokenPromotionInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update();
|
||||
$resource = new AuthTokenPromotionInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -42,6 +44,24 @@ public function __construct(
|
||||
$this->uri = '/Consents/Bulk';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Create
|
||||
*
|
||||
* @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 Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _create(array $items): Response
|
||||
{
|
||||
$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' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the BulkConsentsInstance
|
||||
*
|
||||
@@ -51,18 +71,32 @@ public function __construct(
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_create($items);
|
||||
return new BulkConsentsInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the BulkConsentsInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $items): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($items);
|
||||
$resource = new BulkConsentsInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -42,6 +44,24 @@ public function __construct(
|
||||
$this->uri = '/Contacts/Bulk';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Create
|
||||
*
|
||||
* @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 Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _create(array $items): Response
|
||||
{
|
||||
$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' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the BulkContactsInstance
|
||||
*
|
||||
@@ -51,18 +71,32 @@ public function __construct(
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_create($items);
|
||||
return new BulkContactsInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the BulkContactsInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $items): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($items);
|
||||
$resource = new BulkContactsInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class AwsContext extends InstanceContext
|
||||
@@ -48,6 +50,18 @@ public function __construct(
|
||||
.'';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AwsInstance
|
||||
*
|
||||
@@ -56,11 +70,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AwsInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AwsInstance
|
||||
@@ -70,18 +113,57 @@ public function delete(): bool
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AwsInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AwsInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AwsInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the AwsInstance
|
||||
*
|
||||
@@ -91,22 +173,35 @@ public function fetch(): AwsInstance
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_update($options);
|
||||
return new AwsInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the AwsInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new AwsInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class AwsList extends ListResource
|
||||
@@ -44,16 +49,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the AwsInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @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
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $credentials, array $options = []): AwsInstance
|
||||
private function _create(string $credentials, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -66,11 +70,46 @@ public function create(string $credentials, array $options = []): AwsInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$response = $this->_create( $credentials, $options);
|
||||
return new AwsInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the AwsInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $credentials, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $credentials, $options);
|
||||
$resource = new AwsInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,6 +134,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AwsInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -122,6 +187,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AwsInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AwsInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -137,19 +260,37 @@ public function page(
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AwsPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AwsInstance records with metadata
|
||||
* 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 PageMetadata of AwsInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AwsPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AwsInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class PublicKeyContext extends InstanceContext
|
||||
@@ -48,6 +50,18 @@ public function __construct(
|
||||
.'';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the PublicKeyInstance
|
||||
*
|
||||
@@ -56,11 +70,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the PublicKeyInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the PublicKeyInstance
|
||||
@@ -70,18 +113,57 @@ public function delete(): bool
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new PublicKeyInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the PublicKeyInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new PublicKeyInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the PublicKeyInstance
|
||||
*
|
||||
@@ -91,22 +173,35 @@ public function fetch(): PublicKeyInstance
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_update($options);
|
||||
return new PublicKeyInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the PublicKeyInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new PublicKeyInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class PublicKeyList extends ListResource
|
||||
@@ -44,16 +49,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the PublicKeyInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @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
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $publicKey, array $options = []): PublicKeyInstance
|
||||
private function _create(string $publicKey, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -66,11 +70,46 @@ public function create(string $publicKey, array $options = []): PublicKeyInstanc
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$response = $this->_create( $publicKey, $options);
|
||||
return new PublicKeyInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the PublicKeyInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $publicKey, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $publicKey, $options);
|
||||
$resource = new PublicKeyInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,6 +134,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams PublicKeyInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -122,6 +187,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams PublicKeyInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of PublicKeyInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -137,19 +260,37 @@ public function page(
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new PublicKeyPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of PublicKeyInstance records with metadata
|
||||
* 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 PageMetadata of PublicKeyInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new PublicKeyPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of PublicKeyInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -44,15 +46,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MessagingGeopermissionsInstance
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MessagingGeopermissionsInstance Fetched MessagingGeopermissionsInstance
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetch(array $options = []): MessagingGeopermissionsInstance
|
||||
private function _fetch(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
@@ -61,15 +62,66 @@ public function fetch(array $options = []): MessagingGeopermissionsInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, $params, [], $headers);
|
||||
return $this->version->handleRequest('GET', $this->uri, $params, [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$response = $this->_fetch($options);
|
||||
return new MessagingGeopermissionsInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MessagingGeopermissionsInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch($options);
|
||||
$resource = new MessagingGeopermissionsInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @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 Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(array $permissions): Response
|
||||
{
|
||||
$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' ]);
|
||||
return $this->version->handleRequest('PATCH', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the MessagingGeopermissionsInstance
|
||||
*
|
||||
@@ -79,18 +131,32 @@ public function fetch(array $options = []): MessagingGeopermissionsInstance
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_update($permissions);
|
||||
return new MessagingGeopermissionsInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the MessagingGeopermissionsInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $permissions): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($permissions);
|
||||
$resource = new MessagingGeopermissionsInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class SafelistList extends ListResource
|
||||
@@ -42,6 +44,24 @@ public function __construct(
|
||||
$this->uri = '/SafeList/Numbers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Create
|
||||
*
|
||||
* @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 Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _create(string $phoneNumber): Response
|
||||
{
|
||||
$data = Values::of([
|
||||
'PhoneNumber' =>
|
||||
$phoneNumber,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SafelistInstance
|
||||
*
|
||||
@@ -51,22 +71,56 @@ public function __construct(
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_create( $phoneNumber);
|
||||
return new SafelistInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SafelistInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $phoneNumber): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $phoneNumber);
|
||||
$resource = new SafelistInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, $params, [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the SafelistInstance
|
||||
*
|
||||
@@ -76,7 +130,39 @@ public function create(string $phoneNumber): SafelistInstance
|
||||
*/
|
||||
public function delete(array $options = []): bool
|
||||
{
|
||||
$response = $this->_delete($options);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the SafelistInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete($options);
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
@@ -84,11 +170,10 @@ public function delete(array $options = []): bool
|
||||
$options['phoneNumber'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, $params, [], $headers);
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, $params, [], $headers, "fetch");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the SafelistInstance
|
||||
*
|
||||
@@ -98,20 +183,32 @@ public function delete(array $options = []): bool
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_fetch($options);
|
||||
return new SafelistInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the SafelistInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch($options);
|
||||
$resource = new SafelistInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class SecondaryAuthTokenContext extends InstanceContext
|
||||
@@ -42,6 +44,18 @@ public function __construct(
|
||||
$this->uri = '/AuthTokens/Secondary';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Create
|
||||
*
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _create(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], [], $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SecondaryAuthTokenInstance
|
||||
*
|
||||
@@ -50,17 +64,47 @@ public function __construct(
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_create();
|
||||
return new SecondaryAuthTokenInstance(
|
||||
$this->version,
|
||||
$payload
|
||||
$response->getContent()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SecondaryAuthTokenInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create();
|
||||
$resource = new SecondaryAuthTokenInstance(
|
||||
$this->version,
|
||||
$response->getContent()
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the SecondaryAuthTokenInstance
|
||||
*
|
||||
@@ -69,9 +113,26 @@ public function create(): SecondaryAuthTokenInstance
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
/**
|
||||
* Delete the SecondaryAuthTokenInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class DependentPhoneNumberList extends ListResource
|
||||
@@ -73,6 +77,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams DependentPhoneNumberInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -100,6 +130,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams DependentPhoneNumberInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of DependentPhoneNumberInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -115,19 +203,37 @@ public function page(
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new DependentPhoneNumberPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of DependentPhoneNumberInstance records with metadata
|
||||
* 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 PageMetadata of DependentPhoneNumberInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new DependentPhoneNumberPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of DependentPhoneNumberInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberList;
|
||||
|
||||
@@ -61,6 +63,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AddressInstance
|
||||
*
|
||||
@@ -69,11 +83,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AddressInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AddressInstance
|
||||
@@ -83,29 +126,48 @@ public function delete(): bool
|
||||
*/
|
||||
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);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AddressInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AddressInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AddressInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the AddressInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return AddressInstance Updated AddressInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): AddressInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -130,14 +192,49 @@ public function update(array $options = []): AddressInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new AddressInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the AddressInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new AddressInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,7 +56,7 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the AddressInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $customerName The name to associate with the new address.
|
||||
* @param string $street The number and street address of the new address.
|
||||
@@ -60,12 +65,11 @@ public function __construct(
|
||||
* @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
|
||||
* @return Response Created Response
|
||||
* @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
|
||||
private function _create(string $customerName, string $street, string $city, string $region, string $postalCode, string $isoCountry, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -92,13 +96,59 @@ public function create(string $customerName, string $street, string $city, strin
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$response = $this->_create( $customerName, $street, $city, $region, $postalCode, $isoCountry, $options);
|
||||
return new AddressInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the AddressInstance with Metadata
|
||||
*
|
||||
* @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 ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $customerName, string $street, string $city, string $region, string $postalCode, string $isoCountry, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $customerName, $street, $city, $region, $postalCode, $isoCountry, $options);
|
||||
$resource = new AddressInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +173,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AddressInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -151,6 +228,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AddressInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$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']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AddressInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -167,28 +314,38 @@ public function page(
|
||||
$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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AddressPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AddressInstance records with metadata
|
||||
* 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 PageMetadata of AddressInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AddressPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AddressInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -54,6 +56,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ApplicationInstance
|
||||
*
|
||||
@@ -62,11 +76,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ApplicationInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ApplicationInstance
|
||||
@@ -76,29 +119,48 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): ApplicationInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new ApplicationInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ApplicationInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new ApplicationInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the ApplicationInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ApplicationInstance Updated ApplicationInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ApplicationInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -137,14 +199,49 @@ public function update(array $options = []): ApplicationInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ApplicationInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ApplicationInstance Updated ApplicationInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ApplicationInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new ApplicationInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ApplicationInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new ApplicationInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,15 +56,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ApplicationInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ApplicationInstance Created ApplicationInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): ApplicationInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -98,13 +102,47 @@ public function create(array $options = []): ApplicationInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ApplicationInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ApplicationInstance Created ApplicationInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): ApplicationInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new ApplicationInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ApplicationInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new ApplicationInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +167,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ApplicationInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ApplicationInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -157,6 +222,70 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ApplicationInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ApplicationInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -173,22 +302,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): ApplicationPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new ApplicationPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ApplicationInstance records with metadata
|
||||
* 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 PageMetadata of ApplicationInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new ApplicationPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ApplicationInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class AuthorizedConnectAppContext extends InstanceContext
|
||||
@@ -52,6 +54,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AuthorizedConnectAppInstance
|
||||
*
|
||||
@@ -60,16 +74,36 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): AuthorizedConnectAppInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AuthorizedConnectAppInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['connectAppSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AuthorizedConnectAppInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AuthorizedConnectAppInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['connectAppSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class AuthorizedConnectAppList extends ListResource
|
||||
@@ -67,6 +71,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads AuthorizedConnectAppInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AuthorizedConnectAppInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -94,6 +124,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AuthorizedConnectAppInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AuthorizedConnectAppInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -109,19 +197,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): AuthorizedConnectAppPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AuthorizedConnectAppPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AuthorizedConnectAppInstance records with metadata
|
||||
* 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 PageMetadata of AuthorizedConnectAppInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AuthorizedConnectAppPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AuthorizedConnectAppInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads LocalInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams LocalInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of LocalInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams LocalInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 LocalPage Page of LocalInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): LocalPage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of LocalInstance 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 LocalPage Page of LocalInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): LocalPage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new LocalPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of LocalInstance records with metadata
|
||||
* 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 PageMetadata of LocalInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new LocalPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of LocalInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MachineToMachineInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MachineToMachineInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MachineToMachineInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams MachineToMachineInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 MachineToMachinePage Page of MachineToMachineInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): MachineToMachinePage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MachineToMachineInstance 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 MachineToMachinePage Page of MachineToMachineInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): MachineToMachinePage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new MachineToMachinePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MachineToMachineInstance records with metadata
|
||||
* 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 PageMetadata of MachineToMachineInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new MachineToMachinePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MachineToMachineInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MobileInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MobileInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MobileInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams MobileInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 MobilePage Page of MobileInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): MobilePage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MobileInstance 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 MobilePage Page of MobileInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): MobilePage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new MobilePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MobileInstance records with metadata
|
||||
* 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 PageMetadata of MobileInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new MobilePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MobileInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads NationalInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams NationalInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NationalInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams NationalInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 NationalPage Page of NationalInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): NationalPage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NationalInstance 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 NationalPage Page of NationalInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): NationalPage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new NationalPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NationalInstance records with metadata
|
||||
* 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 PageMetadata of NationalInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new NationalPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of NationalInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads SharedCostInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams SharedCostInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of SharedCostInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams SharedCostInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 SharedCostPage Page of SharedCostInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): SharedCostPage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of SharedCostInstance 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 SharedCostPage Page of SharedCostInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): SharedCostPage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new SharedCostPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of SharedCostInstance records with metadata
|
||||
* 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 PageMetadata of SharedCostInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new SharedCostPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of SharedCostInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads TollFreeInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams TollFreeInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TollFreeInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams TollFreeInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 TollFreePage Page of TollFreeInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): TollFreePage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TollFreeInstance 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 TollFreePage Page of TollFreeInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): TollFreePage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new TollFreePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TollFreeInstance records with metadata
|
||||
* 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 PageMetadata of TollFreeInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new TollFreePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of TollFreeInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads VoipInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams VoipInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -105,20 +136,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of VoipInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams VoipInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 VoipPage Page of VoipInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): VoipPage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -159,17 +223,64 @@ public function page(
|
||||
$options['inLocality'],
|
||||
'FaxEnabled' =>
|
||||
Serialize::booleanToString($options['faxEnabled']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of VoipInstance 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 VoipPage Page of VoipInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): VoipPage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new VoipPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of VoipInstance records with metadata
|
||||
* 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 PageMetadata of VoipInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new VoipPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of VoipInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\VoipList;
|
||||
use Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\NationalList;
|
||||
use Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\MobileList;
|
||||
@@ -77,6 +79,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AvailablePhoneNumberCountryInstance
|
||||
*
|
||||
@@ -85,16 +99,36 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): AvailablePhoneNumberCountryInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AvailablePhoneNumberCountryInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['countryCode']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AvailablePhoneNumberCountryInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AvailablePhoneNumberCountryInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['countryCode']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class AvailablePhoneNumberCountryList extends ListResource
|
||||
@@ -67,6 +71,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads AvailablePhoneNumberCountryInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AvailablePhoneNumberCountryInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -94,6 +124,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AvailablePhoneNumberCountryInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -109,19 +197,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): AvailablePhoneNumberCountryPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AvailablePhoneNumberCountryPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AvailablePhoneNumberCountryInstance records with metadata
|
||||
* 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 PageMetadata of AvailablePhoneNumberCountryInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AvailablePhoneNumberCountryPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AvailablePhoneNumberCountryInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
use Twilio\ListResource;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class BalanceList extends ListResource
|
||||
@@ -47,6 +49,18 @@ public function __construct(
|
||||
.'/Balance.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the BalanceInstance
|
||||
*
|
||||
@@ -55,15 +69,34 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): BalanceInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new BalanceInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the BalanceInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new BalanceInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class EventList extends ListResource
|
||||
@@ -73,6 +77,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads EventInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams EventInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -100,6 +130,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams EventInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of EventInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -115,19 +203,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): EventPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new EventPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of EventInstance records with metadata
|
||||
* 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 PageMetadata of EventInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new EventPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of EventInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class NotificationContext extends InstanceContext
|
||||
@@ -57,6 +59,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the NotificationInstance
|
||||
*
|
||||
@@ -65,17 +79,38 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): NotificationInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new NotificationInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the NotificationInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new NotificationInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads NotificationInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams NotificationInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -104,6 +135,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams NotificationInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Log' =>
|
||||
$options['log'],
|
||||
'MessageDate<' =>
|
||||
Serialize::iso8601Date($options['messageDateBefore']),
|
||||
'MessageDate' =>
|
||||
Serialize::iso8601Date($options['messageDate']),
|
||||
'MessageDate>' =>
|
||||
Serialize::iso8601Date($options['messageDateAfter']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NotificationInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -120,28 +221,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): NotificationPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Log' =>
|
||||
$options['log'],
|
||||
'MessageDate<' =>
|
||||
Serialize::iso8601Date($options['messageDateBefore']),
|
||||
'MessageDate' =>
|
||||
Serialize::iso8601Date($options['messageDate']),
|
||||
'MessageDate>' =>
|
||||
Serialize::iso8601Date($options['messageDateAfter']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new NotificationPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NotificationInstance records with metadata
|
||||
* 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 PageMetadata of NotificationInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new NotificationPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of NotificationInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class PaymentContext extends InstanceContext
|
||||
@@ -59,17 +61,16 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the PaymentInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $idempotencyKey A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
* @param string $statusCallback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return PaymentInstance Updated PaymentInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(string $idempotencyKey, string $statusCallback, array $options = []): PaymentInstance
|
||||
private function _update(string $idempotencyKey, string $statusCallback, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -84,15 +85,55 @@ public function update(string $idempotencyKey, string $statusCallback, array $op
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the PaymentInstance
|
||||
*
|
||||
* @param string $idempotencyKey A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
* @param string $statusCallback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return PaymentInstance Updated PaymentInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(string $idempotencyKey, string $statusCallback, array $options = []): PaymentInstance
|
||||
{
|
||||
$response = $this->_update( $idempotencyKey, $statusCallback, $options);
|
||||
return new PaymentInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the PaymentInstance with Metadata
|
||||
*
|
||||
* @param string $idempotencyKey A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
* @param string $statusCallback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [Update](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-update) and [Complete/Cancel](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback-cancelcomplete) POST requests.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $idempotencyKey, string $statusCallback, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $idempotencyKey, $statusCallback, $options);
|
||||
$resource = new PaymentInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -56,17 +58,16 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the PaymentInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $idempotencyKey A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
* @param string $statusCallback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return PaymentInstance Created PaymentInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $idempotencyKey, string $statusCallback, array $options = []): PaymentInstance
|
||||
private function _create(string $idempotencyKey, string $statusCallback, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -102,17 +103,60 @@ public function create(string $idempotencyKey, string $statusCallback, array $op
|
||||
$options['tokenType'],
|
||||
'ValidCardTypes' =>
|
||||
$options['validCardTypes'],
|
||||
'RequireMatchingInputs' =>
|
||||
$options['requireMatchingInputs'],
|
||||
'Confirmation' =>
|
||||
$options['confirmation'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the PaymentInstance
|
||||
*
|
||||
* @param string $idempotencyKey A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
* @param string $statusCallback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return PaymentInstance Created PaymentInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $idempotencyKey, string $statusCallback, array $options = []): PaymentInstance
|
||||
{
|
||||
$response = $this->_create( $idempotencyKey, $statusCallback, $options);
|
||||
return new PaymentInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the PaymentInstance with Metadata
|
||||
*
|
||||
* @param string $idempotencyKey A unique token that will be used to ensure that multiple API calls with the same information do not result in multiple transactions. This should be a unique string value per API call and can be a randomly generated.
|
||||
* @param string $statusCallback Provide an absolute or relative URL to receive status updates regarding your Pay session. Read more about the [expected StatusCallback values](https://www.twilio.com/docs/voice/api/payment-resource#statuscallback)
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $idempotencyKey, string $statusCallback, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $idempotencyKey, $statusCallback, $options);
|
||||
$resource = new PaymentInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ abstract class PaymentOptions
|
||||
* @param int $timeout The number of seconds that <Pay> should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`.
|
||||
* @param string $tokenType
|
||||
* @param string $validCardTypes Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex`
|
||||
* @param string $requireMatchingInputs A comma-separated list of payment information fields that require the caller to enter the same value twice for confirmation. Supported values are `payment-card-number`, `expiration-date`, `security-code`, and `postal-code`.
|
||||
* @param string $confirmation Whether to prompt the caller to confirm their payment information before submitting to the payment gateway. If `true`, the caller will hear the last 4 digits of their card or account number and must press 1 to confirm or 2 to cancel. Default is `false`.
|
||||
* @return CreatePaymentOptions Options builder
|
||||
*/
|
||||
public static function create(
|
||||
@@ -52,7 +54,9 @@ public static function create(
|
||||
bool $securityCode = Values::BOOL_NONE,
|
||||
int $timeout = Values::INT_NONE,
|
||||
string $tokenType = Values::NONE,
|
||||
string $validCardTypes = Values::NONE
|
||||
string $validCardTypes = Values::NONE,
|
||||
string $requireMatchingInputs = Values::NONE,
|
||||
string $confirmation = Values::NONE
|
||||
|
||||
): CreatePaymentOptions
|
||||
{
|
||||
@@ -70,7 +74,9 @@ public static function create(
|
||||
$securityCode,
|
||||
$timeout,
|
||||
$tokenType,
|
||||
$validCardTypes
|
||||
$validCardTypes,
|
||||
$requireMatchingInputs,
|
||||
$confirmation
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,6 +117,8 @@ class CreatePaymentOptions extends Options
|
||||
* @param int $timeout The number of seconds that <Pay> should wait for the caller to press a digit between each subsequent digit, after the first one, before moving on to validate the digits captured. The default is `5`, maximum is `600`.
|
||||
* @param string $tokenType
|
||||
* @param string $validCardTypes Credit card types separated by space that Pay should accept. The default value is `visa mastercard amex`
|
||||
* @param string $requireMatchingInputs A comma-separated list of payment information fields that require the caller to enter the same value twice for confirmation. Supported values are `payment-card-number`, `expiration-date`, `security-code`, and `postal-code`.
|
||||
* @param string $confirmation Whether to prompt the caller to confirm their payment information before submitting to the payment gateway. If `true`, the caller will hear the last 4 digits of their card or account number and must press 1 to confirm or 2 to cancel. Default is `false`.
|
||||
*/
|
||||
public function __construct(
|
||||
|
||||
@@ -127,7 +135,9 @@ public function __construct(
|
||||
bool $securityCode = Values::BOOL_NONE,
|
||||
int $timeout = Values::INT_NONE,
|
||||
string $tokenType = Values::NONE,
|
||||
string $validCardTypes = Values::NONE
|
||||
string $validCardTypes = Values::NONE,
|
||||
string $requireMatchingInputs = Values::NONE,
|
||||
string $confirmation = Values::NONE
|
||||
|
||||
) {
|
||||
$this->options['bankAccountType'] = $bankAccountType;
|
||||
@@ -144,6 +154,8 @@ public function __construct(
|
||||
$this->options['timeout'] = $timeout;
|
||||
$this->options['tokenType'] = $tokenType;
|
||||
$this->options['validCardTypes'] = $validCardTypes;
|
||||
$this->options['requireMatchingInputs'] = $requireMatchingInputs;
|
||||
$this->options['confirmation'] = $confirmation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,6 +320,30 @@ public function setValidCardTypes(string $validCardTypes): self
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A comma-separated list of payment information fields that require the caller to enter the same value twice for confirmation. Supported values are `payment-card-number`, `expiration-date`, `security-code`, and `postal-code`.
|
||||
*
|
||||
* @param string $requireMatchingInputs A comma-separated list of payment information fields that require the caller to enter the same value twice for confirmation. Supported values are `payment-card-number`, `expiration-date`, `security-code`, and `postal-code`.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setRequireMatchingInputs(string $requireMatchingInputs): self
|
||||
{
|
||||
$this->options['requireMatchingInputs'] = $requireMatchingInputs;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to prompt the caller to confirm their payment information before submitting to the payment gateway. If `true`, the caller will hear the last 4 digits of their card or account number and must press 1 to confirm or 2 to cancel. Default is `false`.
|
||||
*
|
||||
* @param string $confirmation Whether to prompt the caller to confirm their payment information before submitting to the payment gateway. If `true`, the caller will hear the last 4 digits of their card or account number and must press 1 to confirm or 2 to cancel. Default is `false`.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setConfirmation(string $confirmation): self
|
||||
{
|
||||
$this->options['confirmation'] = $confirmation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class RecordingContext extends InstanceContext
|
||||
@@ -58,6 +60,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the RecordingInstance
|
||||
*
|
||||
@@ -66,11 +80,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the RecordingInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the RecordingInstance
|
||||
@@ -80,19 +123,63 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): RecordingInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new RecordingInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the RecordingInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new RecordingInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $status
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(string $status, array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
'PauseBehavior' =>
|
||||
$options['pauseBehavior'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the RecordingInstance
|
||||
@@ -104,26 +191,40 @@ public function fetch(): RecordingInstance
|
||||
*/
|
||||
public function update(string $status, array $options = []): RecordingInstance
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
'PauseBehavior' =>
|
||||
$options['pauseBehavior'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_update( $status, $options);
|
||||
return new RecordingInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the RecordingInstance with Metadata
|
||||
*
|
||||
* @param string $status
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $status, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $status, $options);
|
||||
$resource = new RecordingInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -57,15 +62,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the RecordingInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return RecordingInstance Created RecordingInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): RecordingInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -84,14 +88,49 @@ public function create(array $options = []): RecordingInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the RecordingInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return RecordingInstance Created RecordingInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): RecordingInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new RecordingInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the RecordingInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new RecordingInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +155,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads RecordingInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams RecordingInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -144,6 +210,74 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams RecordingInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'DateCreated<' =>
|
||||
Serialize::iso8601Date($options['dateCreatedBefore']),
|
||||
'DateCreated' =>
|
||||
Serialize::iso8601Date($options['dateCreated']),
|
||||
'DateCreated>' =>
|
||||
Serialize::iso8601Date($options['dateCreatedAfter']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of RecordingInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -160,26 +294,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): RecordingPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'DateCreated<' =>
|
||||
Serialize::iso8601Date($options['dateCreatedBefore']),
|
||||
'DateCreated' =>
|
||||
Serialize::iso8601Date($options['dateCreated']),
|
||||
'DateCreated>' =>
|
||||
Serialize::iso8601Date($options['dateCreatedAfter']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new RecordingPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of RecordingInstance records with metadata
|
||||
* 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 PageMetadata of RecordingInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new RecordingPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of RecordingInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class SiprecContext extends InstanceContext
|
||||
@@ -57,6 +59,24 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $status
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(string $status): Response
|
||||
{
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the SiprecInstance
|
||||
*
|
||||
@@ -66,22 +86,39 @@ public function __construct(
|
||||
*/
|
||||
public function update(string $status): SiprecInstance
|
||||
{
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_update( $status);
|
||||
return new SiprecInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the SiprecInstance with Metadata
|
||||
*
|
||||
* @param string $status
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $status): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $status);
|
||||
$resource = new SiprecInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class SiprecList extends ListResource
|
||||
@@ -55,15 +57,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SiprecInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return SiprecInstance Created SiprecInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): SiprecInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -476,14 +477,49 @@ public function create(array $options = []): SiprecInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SiprecInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return SiprecInstance Created SiprecInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): SiprecInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new SiprecInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the SiprecInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new SiprecInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class StreamContext extends InstanceContext
|
||||
@@ -58,6 +60,24 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $status
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(string $status): Response
|
||||
{
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the StreamInstance
|
||||
*
|
||||
@@ -67,22 +87,39 @@ public function __construct(
|
||||
*/
|
||||
public function update(string $status): StreamInstance
|
||||
{
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_update( $status);
|
||||
return new StreamInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the StreamInstance with Metadata
|
||||
*
|
||||
* @param string $status
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $status): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $status);
|
||||
$resource = new StreamInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class StreamList extends ListResource
|
||||
@@ -56,16 +58,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the StreamInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $url Relative or absolute URL where WebSocket connection will be established.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return StreamInstance Created StreamInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $url, array $options = []): StreamInstance
|
||||
private function _create(string $url, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -478,14 +479,51 @@ public function create(string $url, array $options = []): StreamInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the StreamInstance
|
||||
*
|
||||
* @param string $url Relative or absolute URL where WebSocket connection will be established.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return StreamInstance Created StreamInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $url, array $options = []): StreamInstance
|
||||
{
|
||||
$response = $this->_create( $url, $options);
|
||||
return new StreamInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the StreamInstance with Metadata
|
||||
*
|
||||
* @param string $url Relative or absolute URL where WebSocket connection will be established.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $url, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $url, $options);
|
||||
$resource = new StreamInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class TranscriptionContext extends InstanceContext
|
||||
@@ -57,6 +59,24 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $status
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(string $status): Response
|
||||
{
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the TranscriptionInstance
|
||||
*
|
||||
@@ -66,22 +86,39 @@ public function __construct(
|
||||
*/
|
||||
public function update(string $status): TranscriptionInstance
|
||||
{
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_update( $status);
|
||||
return new TranscriptionInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the TranscriptionInstance with Metadata
|
||||
*
|
||||
* @param string $status
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $status): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $status);
|
||||
$resource = new TranscriptionInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -56,15 +58,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TranscriptionInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return TranscriptionInstance Created TranscriptionInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): TranscriptionInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -96,17 +97,60 @@ public function create(array $options = []): TranscriptionInstance
|
||||
Serialize::booleanToString($options['enableAutomaticPunctuation']),
|
||||
'IntelligenceService' =>
|
||||
$options['intelligenceService'],
|
||||
'ConversationConfiguration' =>
|
||||
$options['conversationConfiguration'],
|
||||
'ConversationId' =>
|
||||
$options['conversationId'],
|
||||
'ConfigurationId' =>
|
||||
$options['configurationId'],
|
||||
'EnableProviderData' =>
|
||||
Serialize::booleanToString($options['enableProviderData']),
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TranscriptionInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return TranscriptionInstance Created TranscriptionInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): TranscriptionInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new TranscriptionInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TranscriptionInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new TranscriptionInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,11 @@ abstract class TranscriptionOptions
|
||||
* @param string $speechModel Recognition model used by the transcription engine, among those supported by the provider
|
||||
* @param string $hints A Phrase contains words and phrase \\\"hints\\\" so that the speech recognition engine is more likely to recognize them.
|
||||
* @param bool $enableAutomaticPunctuation The provider will add punctuation to recognition result
|
||||
* @param string $intelligenceService The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators .
|
||||
* @param string $intelligenceService The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators
|
||||
* @param string $conversationConfiguration The ID of the Conversations Configuration for customizing conversation behavior in Intelligence Service
|
||||
* @param string $conversationId The ID of the Conversation for associating this Transcription with an existing Conversation in Intelligence Service
|
||||
* @param string $configurationId The ID of the RealTimeTranscription Configuration for configuring all the non-default behaviors in one go.
|
||||
* @param bool $enableProviderData Whether the callback includes raw provider data.
|
||||
* @return CreateTranscriptionOptions Options builder
|
||||
*/
|
||||
public static function create(
|
||||
@@ -52,7 +56,11 @@ public static function create(
|
||||
string $speechModel = Values::NONE,
|
||||
string $hints = Values::NONE,
|
||||
bool $enableAutomaticPunctuation = Values::BOOL_NONE,
|
||||
string $intelligenceService = Values::NONE
|
||||
string $intelligenceService = Values::NONE,
|
||||
string $conversationConfiguration = Values::NONE,
|
||||
string $conversationId = Values::NONE,
|
||||
string $configurationId = Values::NONE,
|
||||
bool $enableProviderData = Values::BOOL_NONE
|
||||
|
||||
): CreateTranscriptionOptions
|
||||
{
|
||||
@@ -70,7 +78,11 @@ public static function create(
|
||||
$speechModel,
|
||||
$hints,
|
||||
$enableAutomaticPunctuation,
|
||||
$intelligenceService
|
||||
$intelligenceService,
|
||||
$conversationConfiguration,
|
||||
$conversationId,
|
||||
$configurationId,
|
||||
$enableProviderData
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,7 +105,11 @@ class CreateTranscriptionOptions extends Options
|
||||
* @param string $speechModel Recognition model used by the transcription engine, among those supported by the provider
|
||||
* @param string $hints A Phrase contains words and phrase \\\"hints\\\" so that the speech recognition engine is more likely to recognize them.
|
||||
* @param bool $enableAutomaticPunctuation The provider will add punctuation to recognition result
|
||||
* @param string $intelligenceService The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators .
|
||||
* @param string $intelligenceService The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators
|
||||
* @param string $conversationConfiguration The ID of the Conversations Configuration for customizing conversation behavior in Intelligence Service
|
||||
* @param string $conversationId The ID of the Conversation for associating this Transcription with an existing Conversation in Intelligence Service
|
||||
* @param string $configurationId The ID of the RealTimeTranscription Configuration for configuring all the non-default behaviors in one go.
|
||||
* @param bool $enableProviderData Whether the callback includes raw provider data.
|
||||
*/
|
||||
public function __construct(
|
||||
|
||||
@@ -110,7 +126,11 @@ public function __construct(
|
||||
string $speechModel = Values::NONE,
|
||||
string $hints = Values::NONE,
|
||||
bool $enableAutomaticPunctuation = Values::BOOL_NONE,
|
||||
string $intelligenceService = Values::NONE
|
||||
string $intelligenceService = Values::NONE,
|
||||
string $conversationConfiguration = Values::NONE,
|
||||
string $conversationId = Values::NONE,
|
||||
string $configurationId = Values::NONE,
|
||||
bool $enableProviderData = Values::BOOL_NONE
|
||||
|
||||
) {
|
||||
$this->options['name'] = $name;
|
||||
@@ -127,6 +147,10 @@ public function __construct(
|
||||
$this->options['hints'] = $hints;
|
||||
$this->options['enableAutomaticPunctuation'] = $enableAutomaticPunctuation;
|
||||
$this->options['intelligenceService'] = $intelligenceService;
|
||||
$this->options['conversationConfiguration'] = $conversationConfiguration;
|
||||
$this->options['conversationId'] = $conversationId;
|
||||
$this->options['configurationId'] = $configurationId;
|
||||
$this->options['enableProviderData'] = $enableProviderData;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,9 +308,9 @@ public function setEnableAutomaticPunctuation(bool $enableAutomaticPunctuation):
|
||||
}
|
||||
|
||||
/**
|
||||
* The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators .
|
||||
* The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators
|
||||
*
|
||||
* @param string $intelligenceService The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators .
|
||||
* @param string $intelligenceService The SID or unique name of the [Intelligence Service](https://www.twilio.com/docs/conversational-intelligence/api/service-resource) for persisting transcripts and running post-call Language Operators
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setIntelligenceService(string $intelligenceService): self
|
||||
@@ -295,6 +319,54 @@ public function setIntelligenceService(string $intelligenceService): self
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the Conversations Configuration for customizing conversation behavior in Intelligence Service
|
||||
*
|
||||
* @param string $conversationConfiguration The ID of the Conversations Configuration for customizing conversation behavior in Intelligence Service
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setConversationConfiguration(string $conversationConfiguration): self
|
||||
{
|
||||
$this->options['conversationConfiguration'] = $conversationConfiguration;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the Conversation for associating this Transcription with an existing Conversation in Intelligence Service
|
||||
*
|
||||
* @param string $conversationId The ID of the Conversation for associating this Transcription with an existing Conversation in Intelligence Service
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setConversationId(string $conversationId): self
|
||||
{
|
||||
$this->options['conversationId'] = $conversationId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the RealTimeTranscription Configuration for configuring all the non-default behaviors in one go.
|
||||
*
|
||||
* @param string $configurationId The ID of the RealTimeTranscription Configuration for configuring all the non-default behaviors in one go.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setConfigurationId(string $configurationId): self
|
||||
{
|
||||
$this->options['configurationId'] = $configurationId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the callback includes raw provider data.
|
||||
*
|
||||
* @param bool $enableProviderData Whether the callback includes raw provider data.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setEnableProviderData(bool $enableProviderData): self
|
||||
{
|
||||
$this->options['enableProviderData'] = $enableProviderData;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class UserDefinedMessageList extends ListResource
|
||||
@@ -55,16 +57,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the UserDefinedMessageInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $content The User Defined Message in the form of URL-encoded JSON string.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return UserDefinedMessageInstance Created UserDefinedMessageInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $content, array $options = []): UserDefinedMessageInstance
|
||||
private function _create(string $content, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -75,14 +76,51 @@ public function create(string $content, array $options = []): UserDefinedMessage
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the UserDefinedMessageInstance
|
||||
*
|
||||
* @param string $content The User Defined Message in the form of URL-encoded JSON string.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return UserDefinedMessageInstance Created UserDefinedMessageInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $content, array $options = []): UserDefinedMessageInstance
|
||||
{
|
||||
$response = $this->_create( $content, $options);
|
||||
return new UserDefinedMessageInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the UserDefinedMessageInstance with Metadata
|
||||
*
|
||||
* @param string $content The User Defined Message in the form of URL-encoded JSON string.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $content, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $content, $options);
|
||||
$resource = new UserDefinedMessageInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionContext extends InstanceContext
|
||||
@@ -57,6 +59,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the UserDefinedMessageSubscriptionInstance
|
||||
*
|
||||
@@ -65,9 +79,26 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
/**
|
||||
* Delete the UserDefinedMessageSubscriptionInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class UserDefinedMessageSubscriptionList extends ListResource
|
||||
@@ -55,16 +57,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the UserDefinedMessageSubscriptionInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $callback The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return UserDefinedMessageSubscriptionInstance Created UserDefinedMessageSubscriptionInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $callback, array $options = []): UserDefinedMessageSubscriptionInstance
|
||||
private function _create(string $callback, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -77,14 +78,51 @@ public function create(string $callback, array $options = []): UserDefinedMessag
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the UserDefinedMessageSubscriptionInstance
|
||||
*
|
||||
* @param string $callback The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return UserDefinedMessageSubscriptionInstance Created UserDefinedMessageSubscriptionInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $callback, array $options = []): UserDefinedMessageSubscriptionInstance
|
||||
{
|
||||
$response = $this->_create( $callback, $options);
|
||||
return new UserDefinedMessageSubscriptionInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the UserDefinedMessageSubscriptionInstance with Metadata
|
||||
*
|
||||
* @param string $callback The URL we should call using the `method` to send user defined events to your application. URLs must contain a valid hostname (underscores are not permitted).
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $callback, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $callback, $options);
|
||||
$resource = new UserDefinedMessageSubscriptionInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\Call\TranscriptionList;
|
||||
use Twilio\Rest\Api\V2010\Account\Call\RecordingList;
|
||||
use Twilio\Rest\Api\V2010\Account\Call\UserDefinedMessageSubscriptionList;
|
||||
@@ -91,6 +93,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the CallInstance
|
||||
*
|
||||
@@ -99,11 +113,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the CallInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the CallInstance
|
||||
@@ -113,29 +156,48 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): CallInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new CallInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the CallInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new CallInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the CallInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return CallInstance Updated CallInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): CallInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -160,14 +222,49 @@ public function update(array $options = []): CallInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the CallInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return CallInstance Updated CallInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): CallInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new CallInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the CallInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new CallInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,17 +56,16 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the CallInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $to The phone number, SIP address, or client identifier to call.
|
||||
* @param string $from The phone number or client identifier to use as the caller id. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `From` must also be a phone number.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return CallInstance Created CallInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $to, string $from, array $options = []): CallInstance
|
||||
private function _create(string $to, string $from, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -140,13 +144,51 @@ public function create(string $to, string $from, array $options = []): CallInsta
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the CallInstance
|
||||
*
|
||||
* @param string $to The phone number, SIP address, or client identifier to call.
|
||||
* @param string $from The phone number or client identifier to use as the caller id. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `From` must also be a phone number.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return CallInstance Created CallInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $to, string $from, array $options = []): CallInstance
|
||||
{
|
||||
$response = $this->_create( $to, $from, $options);
|
||||
return new CallInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the CallInstance with Metadata
|
||||
*
|
||||
* @param string $to The phone number, SIP address, or client identifier to call.
|
||||
* @param string $from The phone number or client identifier to use as the caller id. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `From` must also be a phone number.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $to, string $from, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $to, $from, $options);
|
||||
$resource = new CallInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +213,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads CallInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams CallInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -200,20 +269,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of CallInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams CallInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 CallPage Page of CallInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): CallPage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -238,17 +340,64 @@ public function page(
|
||||
Serialize::iso8601DateTime($options['endTime']),
|
||||
'EndTime>' =>
|
||||
Serialize::iso8601DateTime($options['endTimeAfter']),
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of CallInstance 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 CallPage Page of CallInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): CallPage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new CallPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of CallInstance records with metadata
|
||||
* 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 PageMetadata of CallInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new CallPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of CallInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -141,12 +141,12 @@ public static function create(
|
||||
* @param string $from Only include calls from this phone number, SIP address, Client identifier or SIM SID.
|
||||
* @param string $parentCallSid Only include calls spawned by calls with this SID.
|
||||
* @param string $status The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`.
|
||||
* @param string $startTimeBefore Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTime Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTimeAfter Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $endTimeBefore Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTime Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTimeAfter Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $startTimeBefore Only include calls that started before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started before this date.
|
||||
* @param string $startTime Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date.
|
||||
* @param string $startTimeAfter Only include calls that started on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on or after this date.
|
||||
* @param string $endTimeBefore Only include calls that ended before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended before this date.
|
||||
* @param string $endTime Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date.
|
||||
* @param string $endTimeAfter Only include calls that ended on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on or after this date.
|
||||
* @return ReadCallOptions Options builder
|
||||
*/
|
||||
public static function read(
|
||||
@@ -760,12 +760,12 @@ class ReadCallOptions extends Options
|
||||
* @param string $from Only include calls from this phone number, SIP address, Client identifier or SIM SID.
|
||||
* @param string $parentCallSid Only include calls spawned by calls with this SID.
|
||||
* @param string $status The status of the calls to include. Can be: `queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`.
|
||||
* @param string $startTimeBefore Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTime Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTimeAfter Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $endTimeBefore Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTime Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTimeAfter Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $startTimeBefore Only include calls that started before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started before this date.
|
||||
* @param string $startTime Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date.
|
||||
* @param string $startTimeAfter Only include calls that started on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on or after this date.
|
||||
* @param string $endTimeBefore Only include calls that ended before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended before this date.
|
||||
* @param string $endTime Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date.
|
||||
* @param string $endTimeAfter Only include calls that ended on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on or after this date.
|
||||
*/
|
||||
public function __construct(
|
||||
|
||||
@@ -842,9 +842,9 @@ public function setStatus(string $status): self
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* Only include calls that started before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started before this date.
|
||||
*
|
||||
* @param string $startTimeBefore Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTimeBefore Only include calls that started before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started before this date.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setStartTimeBefore(string $startTimeBefore): self
|
||||
@@ -854,9 +854,9 @@ public function setStartTimeBefore(string $startTimeBefore): self
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date.
|
||||
*
|
||||
* @param string $startTime Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTime Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setStartTime(string $startTime): self
|
||||
@@ -866,9 +866,9 @@ public function setStartTime(string $startTime): self
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* Only include calls that started on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on or after this date.
|
||||
*
|
||||
* @param string $startTimeAfter Only include calls that started on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on this date. You can also specify an inequality, such as `StartTime<=YYYY-MM-DD`, to read calls that started on or before midnight of this date, and `StartTime>=YYYY-MM-DD` to read calls that started on or after midnight of this date.
|
||||
* @param string $startTimeAfter Only include calls that started on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that started on or after this date.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setStartTimeAfter(string $startTimeAfter): self
|
||||
@@ -878,9 +878,9 @@ public function setStartTimeAfter(string $startTimeAfter): self
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* Only include calls that ended before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended before this date.
|
||||
*
|
||||
* @param string $endTimeBefore Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTimeBefore Only include calls that ended before this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended before this date.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setEndTimeBefore(string $endTimeBefore): self
|
||||
@@ -890,9 +890,9 @@ public function setEndTimeBefore(string $endTimeBefore): self
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date.
|
||||
*
|
||||
* @param string $endTime Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTime Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setEndTime(string $endTime): self
|
||||
@@ -902,9 +902,9 @@ public function setEndTime(string $endTime): self
|
||||
}
|
||||
|
||||
/**
|
||||
* Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* Only include calls that ended on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on or after this date.
|
||||
*
|
||||
* @param string $endTimeAfter Only include calls that ended on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on this date. You can also specify an inequality, such as `EndTime<=YYYY-MM-DD`, to read calls that ended on or before midnight of this date, and `EndTime>=YYYY-MM-DD` to read calls that ended on or after midnight of this date.
|
||||
* @param string $endTimeAfter Only include calls that ended on or after this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only calls that ended on or after this date.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setEndTimeAfter(string $endTimeAfter): self
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -59,6 +61,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ParticipantInstance
|
||||
*
|
||||
@@ -67,11 +81,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ParticipantInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ParticipantInstance
|
||||
@@ -81,30 +124,50 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): ParticipantInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new ParticipantInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ParticipantInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new ParticipantInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the ParticipantInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ParticipantInstance Updated ParticipantInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ParticipantInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -135,15 +198,51 @@ public function update(array $options = []): ParticipantInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ParticipantInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ParticipantInstance Updated ParticipantInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ParticipantInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new ParticipantInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ParticipantInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new ParticipantInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -57,17 +62,16 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ParticipantInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $from The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `from` must also be a phone number. If `to` is sip address, this value of `from` should be a username portion to be used to populate the P-Asserted-Identity header that is passed to the SIP endpoint.
|
||||
* @param string $to The phone number, SIP address, Client, TwiML App identifier that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `sip:name@company.com`. Client identifiers are formatted `client:name`. TwiML App identifiers are formatted `app:<APP_SID>`. [Custom parameters](https://www.twilio.com/docs/voice/api/conference-participant-resource#custom-parameters) may also be specified.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ParticipantInstance Created ParticipantInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $from, string $to, array $options = []): ParticipantInstance
|
||||
private function _create(string $from, string $to, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -174,14 +178,53 @@ public function create(string $from, string $to, array $options = []): Participa
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ParticipantInstance
|
||||
*
|
||||
* @param string $from The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `from` must also be a phone number. If `to` is sip address, this value of `from` should be a username portion to be used to populate the P-Asserted-Identity header that is passed to the SIP endpoint.
|
||||
* @param string $to The phone number, SIP address, Client, TwiML App identifier that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `sip:name@company.com`. Client identifiers are formatted `client:name`. TwiML App identifiers are formatted `app:<APP_SID>`. [Custom parameters](https://www.twilio.com/docs/voice/api/conference-participant-resource#custom-parameters) may also be specified.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ParticipantInstance Created ParticipantInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $from, string $to, array $options = []): ParticipantInstance
|
||||
{
|
||||
$response = $this->_create( $from, $to, $options);
|
||||
return new ParticipantInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ParticipantInstance with Metadata
|
||||
*
|
||||
* @param string $from The phone number, Client identifier, or username portion of SIP address that made this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). Client identifiers are formatted `client:name`. If using a phone number, it must be a Twilio number or a Verified [outgoing caller id](https://www.twilio.com/docs/voice/api/outgoing-caller-ids) for your account. If the `to` parameter is a phone number, `from` must also be a phone number. If `to` is sip address, this value of `from` should be a username portion to be used to populate the P-Asserted-Identity header that is passed to the SIP endpoint.
|
||||
* @param string $to The phone number, SIP address, Client, TwiML App identifier that received this call. Phone numbers are in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as `sip:name@company.com`. Client identifiers are formatted `client:name`. TwiML App identifiers are formatted `app:<APP_SID>`. [Custom parameters](https://www.twilio.com/docs/voice/api/conference-participant-resource#custom-parameters) may also be specified.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $from, string $to, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $from, $to, $options);
|
||||
$resource = new ParticipantInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -206,6 +249,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ParticipantInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ParticipantInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -234,6 +304,74 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ParticipantInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Muted' =>
|
||||
Serialize::booleanToString($options['muted']),
|
||||
'Hold' =>
|
||||
Serialize::booleanToString($options['hold']),
|
||||
'Coaching' =>
|
||||
Serialize::booleanToString($options['coaching']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ParticipantInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -250,26 +388,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): ParticipantPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Muted' =>
|
||||
Serialize::booleanToString($options['muted']),
|
||||
'Hold' =>
|
||||
Serialize::booleanToString($options['hold']),
|
||||
'Coaching' =>
|
||||
Serialize::booleanToString($options['coaching']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new ParticipantPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ParticipantInstance records with metadata
|
||||
* 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 PageMetadata of ParticipantInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new ParticipantPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ParticipantInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class RecordingContext extends InstanceContext
|
||||
@@ -58,6 +60,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the RecordingInstance
|
||||
*
|
||||
@@ -66,11 +80,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the RecordingInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the RecordingInstance
|
||||
@@ -80,19 +123,63 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): RecordingInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new RecordingInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the RecordingInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new RecordingInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $status
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(string $status, array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
'PauseBehavior' =>
|
||||
$options['pauseBehavior'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the RecordingInstance
|
||||
@@ -104,26 +191,40 @@ public function fetch(): RecordingInstance
|
||||
*/
|
||||
public function update(string $status, array $options = []): RecordingInstance
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'Status' =>
|
||||
$status,
|
||||
'PauseBehavior' =>
|
||||
$options['pauseBehavior'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_update( $status, $options);
|
||||
return new RecordingInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the RecordingInstance with Metadata
|
||||
*
|
||||
* @param string $status
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $status, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $status, $options);
|
||||
$resource = new RecordingInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['conferenceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads RecordingInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams RecordingInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -104,6 +135,74 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams RecordingInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'DateCreated<' =>
|
||||
Serialize::iso8601Date($options['dateCreatedBefore']),
|
||||
'DateCreated' =>
|
||||
Serialize::iso8601Date($options['dateCreated']),
|
||||
'DateCreated>' =>
|
||||
Serialize::iso8601Date($options['dateCreatedAfter']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of RecordingInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -120,26 +219,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): RecordingPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'DateCreated<' =>
|
||||
Serialize::iso8601Date($options['dateCreatedBefore']),
|
||||
'DateCreated' =>
|
||||
Serialize::iso8601Date($options['dateCreated']),
|
||||
'DateCreated>' =>
|
||||
Serialize::iso8601Date($options['dateCreatedAfter']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new RecordingPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of RecordingInstance records with metadata
|
||||
* 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 PageMetadata of RecordingInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new RecordingPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of RecordingInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\Conference\ParticipantList;
|
||||
use Twilio\Rest\Api\V2010\Account\Conference\RecordingList;
|
||||
|
||||
@@ -65,6 +67,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ConferenceInstance
|
||||
*
|
||||
@@ -73,29 +87,48 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): ConferenceInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new ConferenceInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ConferenceInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new ConferenceInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the ConferenceInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ConferenceInstance Updated ConferenceInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ConferenceInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -108,14 +141,49 @@ public function update(array $options = []): ConferenceInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ConferenceInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ConferenceInstance Updated ConferenceInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ConferenceInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new ConferenceInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ConferenceInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new ConferenceInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -70,6 +74,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ConferenceInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ConferenceInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -99,20 +130,53 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ConferenceInstance records from the API.
|
||||
* Request is executed immediately
|
||||
* Streams ConferenceInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 ConferencePage Page of ConferenceInstance
|
||||
* @return Response Paged Response
|
||||
*/
|
||||
public function page(
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): ConferencePage
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
@@ -133,17 +197,64 @@ public function page(
|
||||
$options['friendlyName'],
|
||||
'Status' =>
|
||||
$options['status'],
|
||||
|
||||
'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 $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ConferenceInstance 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 ConferencePage Page of ConferenceInstance
|
||||
*/
|
||||
public function page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): ConferencePage
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new ConferencePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ConferenceInstance records with metadata
|
||||
* 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 PageMetadata of ConferenceInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new ConferencePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ConferenceInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class ConnectAppContext extends InstanceContext
|
||||
@@ -53,6 +55,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ConnectAppInstance
|
||||
*
|
||||
@@ -61,11 +75,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the ConnectAppInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ConnectAppInstance
|
||||
@@ -75,29 +118,48 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): ConnectAppInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new ConnectAppInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the ConnectAppInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new ConnectAppInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the ConnectAppInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ConnectAppInstance Updated ConnectAppInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ConnectAppInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -120,14 +182,49 @@ public function update(array $options = []): ConnectAppInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ConnectAppInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ConnectAppInstance Updated ConnectAppInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): ConnectAppInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new ConnectAppInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ConnectAppInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new ConnectAppInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class ConnectAppList extends ListResource
|
||||
@@ -67,6 +71,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads ConnectAppInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ConnectAppInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -94,6 +124,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams ConnectAppInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ConnectAppInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -109,19 +197,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): ConnectAppPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new ConnectAppPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of ConnectAppInstance records with metadata
|
||||
* 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 PageMetadata of ConnectAppInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new ConnectAppPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of ConnectAppInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class AssignedAddOnExtensionContext extends InstanceContext
|
||||
@@ -62,6 +64,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AssignedAddOnExtensionInstance
|
||||
*
|
||||
@@ -70,18 +84,40 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): AssignedAddOnExtensionInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AssignedAddOnExtensionInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['resourceSid'],
|
||||
$this->solution['assignedAddOnSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AssignedAddOnExtensionInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AssignedAddOnExtensionInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['resourceSid'],
|
||||
$this->solution['assignedAddOnSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class AssignedAddOnExtensionList extends ListResource
|
||||
@@ -79,6 +83,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads AssignedAddOnExtensionInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AssignedAddOnExtensionInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -106,6 +136,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AssignedAddOnExtensionInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AssignedAddOnExtensionInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -121,19 +209,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): AssignedAddOnExtensionPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AssignedAddOnExtensionPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AssignedAddOnExtensionInstance records with metadata
|
||||
* 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 PageMetadata of AssignedAddOnExtensionInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AssignedAddOnExtensionPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AssignedAddOnExtensionInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\IncomingPhoneNumber\AssignedAddOn\AssignedAddOnExtensionList;
|
||||
|
||||
|
||||
@@ -65,6 +67,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AssignedAddOnInstance
|
||||
*
|
||||
@@ -73,11 +87,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AssignedAddOnInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AssignedAddOnInstance
|
||||
@@ -87,17 +130,38 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): AssignedAddOnInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AssignedAddOnInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['resourceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AssignedAddOnInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AssignedAddOnInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['resourceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class AssignedAddOnList extends ListResource
|
||||
@@ -54,6 +59,24 @@ public function __construct(
|
||||
.'/AssignedAddOns.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $installedAddOnSid The SID that identifies the Add-on installation.
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _create(string $installedAddOnSid): Response
|
||||
{
|
||||
$data = Values::of([
|
||||
'InstalledAddOnSid' =>
|
||||
$installedAddOnSid,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the AssignedAddOnInstance
|
||||
*
|
||||
@@ -63,21 +86,37 @@ public function __construct(
|
||||
*/
|
||||
public function create(string $installedAddOnSid): AssignedAddOnInstance
|
||||
{
|
||||
|
||||
$data = Values::of([
|
||||
'InstalledAddOnSid' =>
|
||||
$installedAddOnSid,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_create( $installedAddOnSid);
|
||||
return new AssignedAddOnInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['resourceSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the AssignedAddOnInstance with Metadata
|
||||
*
|
||||
* @param string $installedAddOnSid The SID that identifies the Add-on installation.
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $installedAddOnSid): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $installedAddOnSid);
|
||||
$resource = new AssignedAddOnInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['resourceSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +140,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads AssignedAddOnInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AssignedAddOnInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -128,6 +193,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AssignedAddOnInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AssignedAddOnInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -143,19 +266,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): AssignedAddOnPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AssignedAddOnPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AssignedAddOnInstance records with metadata
|
||||
* 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 PageMetadata of AssignedAddOnInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AssignedAddOnPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AssignedAddOnInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,16 +56,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the LocalInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return LocalInstance Created LocalInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $phoneNumber, array $options = []): LocalInstance
|
||||
private function _create(string $phoneNumber, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -113,13 +117,49 @@ public function create(string $phoneNumber, array $options = []): LocalInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the LocalInstance
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return LocalInstance Created LocalInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $phoneNumber, array $options = []): LocalInstance
|
||||
{
|
||||
$response = $this->_create( $phoneNumber, $options);
|
||||
return new LocalInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the LocalInstance with Metadata
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $phoneNumber, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $phoneNumber, $options);
|
||||
$resource = new LocalInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +184,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads LocalInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams LocalInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -172,6 +239,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams LocalInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of LocalInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -188,28 +325,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): LocalPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new LocalPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of LocalInstance records with metadata
|
||||
* 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 PageMetadata of LocalInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new LocalPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of LocalInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,16 +56,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the MobileInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MobileInstance Created MobileInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $phoneNumber, array $options = []): MobileInstance
|
||||
private function _create(string $phoneNumber, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -113,13 +117,49 @@ public function create(string $phoneNumber, array $options = []): MobileInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the MobileInstance
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MobileInstance Created MobileInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $phoneNumber, array $options = []): MobileInstance
|
||||
{
|
||||
$response = $this->_create( $phoneNumber, $options);
|
||||
return new MobileInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the MobileInstance with Metadata
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $phoneNumber, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $phoneNumber, $options);
|
||||
$resource = new MobileInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +184,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MobileInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MobileInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -172,6 +239,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MobileInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MobileInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -188,28 +325,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): MobilePage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new MobilePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MobileInstance records with metadata
|
||||
* 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 PageMetadata of MobileInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new MobilePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MobileInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,16 +56,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TollFreeInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return TollFreeInstance Created TollFreeInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $phoneNumber, array $options = []): TollFreeInstance
|
||||
private function _create(string $phoneNumber, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -113,13 +117,49 @@ public function create(string $phoneNumber, array $options = []): TollFreeInstan
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TollFreeInstance
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return TollFreeInstance Created TollFreeInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $phoneNumber, array $options = []): TollFreeInstance
|
||||
{
|
||||
$response = $this->_create( $phoneNumber, $options);
|
||||
return new TollFreeInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the TollFreeInstance with Metadata
|
||||
*
|
||||
* @param string $phoneNumber The phone number to purchase specified in [E.164](https://www.twilio.com/docs/glossary/what-e164) format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $phoneNumber, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $phoneNumber, $options);
|
||||
$resource = new TollFreeInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +184,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads TollFreeInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams TollFreeInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -172,6 +239,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams TollFreeInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TollFreeInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -188,28 +325,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): TollFreePage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new TollFreePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TollFreeInstance records with metadata
|
||||
* 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 PageMetadata of TollFreeInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new TollFreePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of TollFreeInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Rest\Api\V2010\Account\IncomingPhoneNumber\AssignedAddOnList;
|
||||
|
||||
@@ -62,6 +64,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the IncomingPhoneNumberInstance
|
||||
*
|
||||
@@ -70,11 +84,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the IncomingPhoneNumberInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the IncomingPhoneNumberInstance
|
||||
@@ -84,29 +127,48 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): IncomingPhoneNumberInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new IncomingPhoneNumberInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the IncomingPhoneNumberInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new IncomingPhoneNumberInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the IncomingPhoneNumberInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return IncomingPhoneNumberInstance Updated IncomingPhoneNumberInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): IncomingPhoneNumberInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -159,14 +221,49 @@ public function update(array $options = []): IncomingPhoneNumberInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the IncomingPhoneNumberInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return IncomingPhoneNumberInstance Updated IncomingPhoneNumberInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): IncomingPhoneNumberInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new IncomingPhoneNumberInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the IncomingPhoneNumberInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new IncomingPhoneNumberInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
* @property string $emergencyAddressStatus
|
||||
* @property string|null $bundleSid
|
||||
* @property string|null $status
|
||||
* @property string|null $type
|
||||
*/
|
||||
class IncomingPhoneNumberInstance extends InstanceResource
|
||||
{
|
||||
@@ -115,6 +116,7 @@ public function __construct(Version $version, array $payload, string $accountSid
|
||||
'emergencyAddressStatus' => Values::array_get($payload, 'emergency_address_status'),
|
||||
'bundleSid' => Values::array_get($payload, 'bundle_sid'),
|
||||
'status' => Values::array_get($payload, 'status'),
|
||||
'type' => Values::array_get($payload, 'type'),
|
||||
];
|
||||
|
||||
$this->solution = ['accountSid' => $accountSid, 'sid' => $sid ?: $this->properties['sid'], ];
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Rest\Api\V2010\Account\IncomingPhoneNumber\TollFreeList;
|
||||
use Twilio\Rest\Api\V2010\Account\IncomingPhoneNumber\LocalList;
|
||||
@@ -64,15 +69,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the IncomingPhoneNumberInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return IncomingPhoneNumberInstance Created IncomingPhoneNumberInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): IncomingPhoneNumberInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -127,13 +131,47 @@ public function create(array $options = []): IncomingPhoneNumberInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the IncomingPhoneNumberInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return IncomingPhoneNumberInstance Created IncomingPhoneNumberInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): IncomingPhoneNumberInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new IncomingPhoneNumberInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the IncomingPhoneNumberInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new IncomingPhoneNumberInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,6 +196,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads IncomingPhoneNumberInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams IncomingPhoneNumberInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -186,6 +251,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams IncomingPhoneNumberInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of IncomingPhoneNumberInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -202,28 +337,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): IncomingPhoneNumberPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Beta' =>
|
||||
Serialize::booleanToString($options['beta']),
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'Origin' =>
|
||||
$options['origin'],
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new IncomingPhoneNumberPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of IncomingPhoneNumberInstance records with metadata
|
||||
* 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 PageMetadata of IncomingPhoneNumberInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new IncomingPhoneNumberPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of IncomingPhoneNumberInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class KeyContext extends InstanceContext
|
||||
@@ -53,6 +55,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the KeyInstance
|
||||
*
|
||||
@@ -61,11 +75,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the KeyInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the KeyInstance
|
||||
@@ -75,18 +118,58 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): KeyInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new KeyInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the KeyInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new KeyInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the KeyInstance
|
||||
@@ -97,23 +180,37 @@ public function fetch(): KeyInstance
|
||||
*/
|
||||
public function update(array $options = []): KeyInstance
|
||||
{
|
||||
|
||||
$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);
|
||||
|
||||
$response = $this->_update($options);
|
||||
return new KeyInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the KeyInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new KeyInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class KeyList extends ListResource
|
||||
@@ -67,6 +71,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads KeyInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams KeyInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -94,6 +124,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams KeyInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of KeyInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -109,19 +197,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): KeyPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new KeyPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of KeyInstance records with metadata
|
||||
* 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 PageMetadata of KeyInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new KeyPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of KeyInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class FeedbackList extends ListResource
|
||||
@@ -55,15 +57,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the FeedbackInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return FeedbackInstance Created FeedbackInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): FeedbackInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -72,14 +73,49 @@ public function create(array $options = []): FeedbackInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the FeedbackInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return FeedbackInstance Created FeedbackInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): FeedbackInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new FeedbackInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['messageSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the FeedbackInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new FeedbackInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['messageSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class MediaContext extends InstanceContext
|
||||
@@ -57,6 +59,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the MediaInstance
|
||||
*
|
||||
@@ -65,11 +79,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the MediaInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MediaInstance
|
||||
@@ -79,17 +122,38 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): MediaInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new MediaInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['messageSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MediaInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new MediaInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['messageSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -76,6 +80,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MediaInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MediaInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -104,6 +135,74 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MediaInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'DateCreated<' =>
|
||||
Serialize::iso8601DateTime($options['dateCreatedBefore']),
|
||||
'DateCreated' =>
|
||||
Serialize::iso8601DateTime($options['dateCreated']),
|
||||
'DateCreated>' =>
|
||||
Serialize::iso8601DateTime($options['dateCreatedAfter']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MediaInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -120,26 +219,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): MediaPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'DateCreated<' =>
|
||||
Serialize::iso8601DateTime($options['dateCreatedBefore']),
|
||||
'DateCreated' =>
|
||||
Serialize::iso8601DateTime($options['dateCreated']),
|
||||
'DateCreated>' =>
|
||||
Serialize::iso8601DateTime($options['dateCreatedAfter']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new MediaPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MediaInstance records with metadata
|
||||
* 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 PageMetadata of MediaInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new MediaPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MediaInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\Message\FeedbackList;
|
||||
use Twilio\Rest\Api\V2010\Account\Message\MediaList;
|
||||
|
||||
@@ -64,6 +66,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the MessageInstance
|
||||
*
|
||||
@@ -72,11 +86,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the MessageInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MessageInstance
|
||||
@@ -86,29 +129,48 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): MessageInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new MessageInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MessageInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new MessageInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the MessageInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MessageInstance Updated MessageInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): MessageInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -119,14 +181,49 @@ public function update(array $options = []): MessageInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the MessageInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MessageInstance Updated MessageInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): MessageInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new MessageInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the MessageInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new MessageInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -51,16 +56,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the MessageInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MessageInstance Created MessageInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $to, array $options = []): MessageInstance
|
||||
private function _create(string $to, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -104,6 +108,8 @@ public function create(string $to, array $options = []): MessageInstance
|
||||
$options['riskCheck'],
|
||||
'From' =>
|
||||
$options['from'],
|
||||
'FallbackFrom' =>
|
||||
$options['fallbackFrom'],
|
||||
'MessagingServiceSid' =>
|
||||
$options['messagingServiceSid'],
|
||||
'Body' =>
|
||||
@@ -115,13 +121,49 @@ public function create(string $to, array $options = []): MessageInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the MessageInstance
|
||||
*
|
||||
* @param string $to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return MessageInstance Created MessageInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $to, array $options = []): MessageInstance
|
||||
{
|
||||
$response = $this->_create( $to, $options);
|
||||
return new MessageInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the MessageInstance with Metadata
|
||||
*
|
||||
* @param string $to The recipient's phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format (for SMS/MMS) or [channel address](https://www.twilio.com/docs/messaging/channels), e.g. `whatsapp:+15552229999`.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $to, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $to, $options);
|
||||
$resource = new MessageInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +188,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MessageInstance records from the API as a list
|
||||
* Unlike stream(), this operation is eager and will load `limit` records into
|
||||
* memory before returning.
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @param int $limit Upper limit for the number of records to return. read()
|
||||
* guarantees to never return more than limit. Default is no
|
||||
* limit
|
||||
* @param mixed $pageSize Number of records to fetch per request, when not set
|
||||
* will use the default value of 50 records. If no
|
||||
* page_size is defined but a limit is defined, read()
|
||||
* will attempt to read the limit with the most
|
||||
* efficient page size, i.e. min(limit, 1000)
|
||||
* @return ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MessageInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -174,6 +243,78 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MessageInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'To' =>
|
||||
$options['to'],
|
||||
'From' =>
|
||||
$options['from'],
|
||||
'DateSent<' =>
|
||||
Serialize::iso8601DateTime($options['dateSentBefore']),
|
||||
'DateSent' =>
|
||||
Serialize::iso8601DateTime($options['dateSent']),
|
||||
'DateSent>' =>
|
||||
Serialize::iso8601DateTime($options['dateSentAfter']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MessageInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -190,30 +331,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): MessagePage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'To' =>
|
||||
$options['to'],
|
||||
'From' =>
|
||||
$options['from'],
|
||||
'DateSent<' =>
|
||||
Serialize::iso8601DateTime($options['dateSentBefore']),
|
||||
'DateSent' =>
|
||||
Serialize::iso8601DateTime($options['dateSent']),
|
||||
'DateSent>' =>
|
||||
Serialize::iso8601DateTime($options['dateSentAfter']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new MessagePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MessageInstance records with metadata
|
||||
* 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 PageMetadata of MessageInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new MessagePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MessageInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -44,6 +44,7 @@ abstract class MessageOptions
|
||||
* @param bool $sendAsMms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media.
|
||||
* @param string $contentVariables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used.
|
||||
* @param string $riskCheck
|
||||
* @param string $fallbackFrom A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message.
|
||||
* @return CreateMessageOptions Options builder
|
||||
*/
|
||||
public static function create(
|
||||
@@ -70,7 +71,8 @@ public static function create(
|
||||
?\DateTime $sendAt = null,
|
||||
bool $sendAsMms = Values::BOOL_NONE,
|
||||
string $contentVariables = Values::NONE,
|
||||
string $riskCheck = Values::NONE
|
||||
string $riskCheck = Values::NONE,
|
||||
string $fallbackFrom = Values::NONE
|
||||
|
||||
): CreateMessageOptions
|
||||
{
|
||||
@@ -97,7 +99,8 @@ public static function create(
|
||||
$sendAt,
|
||||
$sendAsMms,
|
||||
$contentVariables,
|
||||
$riskCheck
|
||||
$riskCheck,
|
||||
$fallbackFrom
|
||||
);
|
||||
}
|
||||
|
||||
@@ -176,6 +179,7 @@ class CreateMessageOptions extends Options
|
||||
* @param bool $sendAsMms If set to `true`, Twilio delivers the message as a single MMS message, regardless of the presence of media.
|
||||
* @param string $contentVariables For [Content Editor/API](https://www.twilio.com/docs/content) only: Key-value pairs of [Template variables](https://www.twilio.com/docs/content/using-variables-with-content-api) and their substitution values. `content_sid` parameter must also be provided. If values are not defined in the `content_variables` parameter, the [Template's default placeholder values](https://www.twilio.com/docs/content/content-api-resources#create-templates) are used.
|
||||
* @param string $riskCheck
|
||||
* @param string $fallbackFrom A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message.
|
||||
*/
|
||||
public function __construct(
|
||||
|
||||
@@ -201,7 +205,8 @@ public function __construct(
|
||||
?\DateTime $sendAt = null,
|
||||
bool $sendAsMms = Values::BOOL_NONE,
|
||||
string $contentVariables = Values::NONE,
|
||||
string $riskCheck = Values::NONE
|
||||
string $riskCheck = Values::NONE,
|
||||
string $fallbackFrom = Values::NONE
|
||||
|
||||
) {
|
||||
$this->options['from'] = $from;
|
||||
@@ -227,6 +232,7 @@ public function __construct(
|
||||
$this->options['sendAsMms'] = $sendAsMms;
|
||||
$this->options['contentVariables'] = $contentVariables;
|
||||
$this->options['riskCheck'] = $riskCheck;
|
||||
$this->options['fallbackFrom'] = $fallbackFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,6 +501,18 @@ public function setRiskCheck(string $riskCheck): self
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message.
|
||||
*
|
||||
* @param string $fallbackFrom A fallback SMS sender to use when the recipient cannot be reached over RCS. This parameter may only be used when also providing a [Messaging Service](https://twilio.com/docs/messaging/services) containing an RCS sender. The fallback SMS sender must be either a Twilio phone number (in [E.164](https://en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](https://www.twilio.com/docs/sms/quickstart), or [short code](https://www.twilio.com/en-us/messaging/channels/sms/short-codes), hosted within Twilio and belong to the Account creating the Message.
|
||||
* @return $this Fluent Builder
|
||||
*/
|
||||
public function setFallbackFrom(string $fallbackFrom): self
|
||||
{
|
||||
$this->options['fallbackFrom'] = $fallbackFrom;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a friendly representation
|
||||
*
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class NewKeyList extends ListResource
|
||||
@@ -49,15 +51,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the NewKeyInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return NewKeyInstance Created NewKeyInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): NewKeyInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -66,13 +67,47 @@ public function create(array $options = []): NewKeyInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the NewKeyInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return NewKeyInstance Created NewKeyInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): NewKeyInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new NewKeyInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the NewKeyInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new NewKeyInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Options;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class NewSigningKeyList extends ListResource
|
||||
@@ -49,15 +51,14 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the NewSigningKeyInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return NewSigningKeyInstance Created NewSigningKeyInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): NewSigningKeyInstance
|
||||
private function _create(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -66,13 +67,47 @@ public function create(array $options = []): NewSigningKeyInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the NewSigningKeyInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return NewSigningKeyInstance Created NewSigningKeyInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(array $options = []): NewSigningKeyInstance
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
return new NewSigningKeyInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the NewSigningKeyInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create($options);
|
||||
$resource = new NewSigningKeyInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class NotificationContext extends InstanceContext
|
||||
@@ -52,6 +54,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the NotificationInstance
|
||||
*
|
||||
@@ -60,16 +74,36 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): NotificationInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new NotificationInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the NotificationInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new NotificationInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
use Twilio\Serialize;
|
||||
|
||||
|
||||
@@ -70,6 +74,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads NotificationInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams NotificationInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -98,6 +129,76 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams NotificationInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Log' =>
|
||||
$options['log'],
|
||||
'MessageDate<' =>
|
||||
Serialize::iso8601Date($options['messageDateBefore']),
|
||||
'MessageDate' =>
|
||||
Serialize::iso8601Date($options['messageDate']),
|
||||
'MessageDate>' =>
|
||||
Serialize::iso8601Date($options['messageDateAfter']),
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NotificationInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -114,28 +215,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): NotificationPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'Log' =>
|
||||
$options['log'],
|
||||
'MessageDate<' =>
|
||||
Serialize::iso8601Date($options['messageDateBefore']),
|
||||
'MessageDate' =>
|
||||
Serialize::iso8601Date($options['messageDate']),
|
||||
'MessageDate>' =>
|
||||
Serialize::iso8601Date($options['messageDateAfter']),
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new NotificationPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of NotificationInstance records with metadata
|
||||
* 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 PageMetadata of NotificationInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new NotificationPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of NotificationInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class OutgoingCallerIdContext extends InstanceContext
|
||||
@@ -53,6 +55,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the OutgoingCallerIdInstance
|
||||
*
|
||||
@@ -61,11 +75,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the OutgoingCallerIdInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the OutgoingCallerIdInstance
|
||||
@@ -75,18 +118,58 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): OutgoingCallerIdInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new OutgoingCallerIdInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the OutgoingCallerIdInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new OutgoingCallerIdInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the OutgoingCallerIdInstance
|
||||
@@ -97,23 +180,37 @@ public function fetch(): OutgoingCallerIdInstance
|
||||
*/
|
||||
public function update(array $options = []): OutgoingCallerIdInstance
|
||||
{
|
||||
|
||||
$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);
|
||||
|
||||
$response = $this->_update($options);
|
||||
return new OutgoingCallerIdInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the OutgoingCallerIdInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new OutgoingCallerIdInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class OutgoingCallerIdList extends ListResource
|
||||
@@ -69,6 +73,33 @@ public function read(array $options = [], ?int $limit = null, $pageSize = null):
|
||||
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads OutgoingCallerIdInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($options, $limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams OutgoingCallerIdInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -97,6 +128,72 @@ public function stream(array $options = [], ?int $limit = null, $pageSize = null
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams OutgoingCallerIdInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(array $options = [], ?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($options, $limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of OutgoingCallerIdInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -113,24 +210,38 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): OutgoingCallerIdPage
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'PhoneNumber' =>
|
||||
$options['phoneNumber'],
|
||||
'FriendlyName' =>
|
||||
$options['friendlyName'],
|
||||
'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);
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new OutgoingCallerIdPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of OutgoingCallerIdInstance records with metadata
|
||||
* 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 PageMetadata of OutgoingCallerIdInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
array $options = [],
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page($options, $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new OutgoingCallerIdPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of OutgoingCallerIdInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class MemberContext extends InstanceContext
|
||||
@@ -58,6 +60,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MemberInstance
|
||||
*
|
||||
@@ -66,19 +80,63 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): MemberInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new MemberInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['queueSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the MemberInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new MemberInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['queueSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param string $url The absolute URL of the Queue resource.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _update(string $url, array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'Url' =>
|
||||
$url,
|
||||
'Method' =>
|
||||
$options['method'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the MemberInstance
|
||||
@@ -90,26 +148,40 @@ public function fetch(): MemberInstance
|
||||
*/
|
||||
public function update(string $url, array $options = []): MemberInstance
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
'Url' =>
|
||||
$url,
|
||||
'Method' =>
|
||||
$options['method'],
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
|
||||
$response = $this->_update( $url, $options);
|
||||
return new MemberInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['queueSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the MemberInstance with Metadata
|
||||
*
|
||||
* @param string $url The absolute URL of the Queue resource.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(string $url, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update( $url, $options);
|
||||
$resource = new MemberInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['queueSid'],
|
||||
$this->solution['callSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class MemberList extends ListResource
|
||||
@@ -73,6 +77,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads MemberInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MemberInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -100,6 +130,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams MemberInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MemberInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -115,19 +203,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): MemberPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new MemberPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of MemberInstance records with metadata
|
||||
* 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 PageMetadata of MemberInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new MemberPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of MemberInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\Queue\MemberList;
|
||||
|
||||
|
||||
@@ -61,6 +63,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the QueueInstance
|
||||
*
|
||||
@@ -69,11 +83,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the QueueInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the QueueInstance
|
||||
@@ -83,29 +126,48 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): QueueInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new QueueInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the QueueInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new QueueInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the QueueInstance
|
||||
* Helper function for Update
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return QueueInstance Updated QueueInstance
|
||||
* @return Response Updated Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): QueueInstance
|
||||
private function _update(array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -116,14 +178,49 @@ public function update(array $options = []): QueueInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "update");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the QueueInstance
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return QueueInstance Updated QueueInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function update(array $options = []): QueueInstance
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
return new QueueInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the QueueInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Updated Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function updateWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_update($options);
|
||||
$resource = new QueueInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class QueueList extends ListResource
|
||||
@@ -50,16 +55,15 @@ public function __construct(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the QueueInstance
|
||||
* Helper function for Create
|
||||
*
|
||||
* @param string $friendlyName A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return QueueInstance Created QueueInstance
|
||||
* @return Response Created Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $friendlyName, array $options = []): QueueInstance
|
||||
private function _create(string $friendlyName, array $options = []): Response
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$data = Values::of([
|
||||
@@ -70,13 +74,49 @@ public function create(string $friendlyName, array $options = []): QueueInstance
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
|
||||
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the QueueInstance
|
||||
*
|
||||
* @param string $friendlyName A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return QueueInstance Created QueueInstance
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function create(string $friendlyName, array $options = []): QueueInstance
|
||||
{
|
||||
$response = $this->_create( $friendlyName, $options);
|
||||
return new QueueInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the QueueInstance with Metadata
|
||||
*
|
||||
* @param string $friendlyName A descriptive string that you created to describe this resource. It can be up to 64 characters long.
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Created Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function createWithMetadata(string $friendlyName, array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_create( $friendlyName, $options);
|
||||
$resource = new QueueInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +140,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads QueueInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams QueueInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -127,6 +193,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams QueueInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of QueueInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -142,19 +266,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): QueuePage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new QueuePage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of QueueInstance records with metadata
|
||||
* 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 PageMetadata of QueueInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new QueuePage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of QueueInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class DataContext extends InstanceContext
|
||||
@@ -62,6 +64,18 @@ public function __construct(
|
||||
.'/Data.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the DataInstance
|
||||
*
|
||||
@@ -70,18 +84,40 @@ public function __construct(
|
||||
*/
|
||||
public function fetch(): DataInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new DataInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['referenceSid'],
|
||||
$this->solution['addOnResultSid'],
|
||||
$this->solution['payloadSid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the DataInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new DataInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['referenceSid'],
|
||||
$this->solution['addOnResultSid'],
|
||||
$this->solution['payloadSid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\Recording\AddOnResult\Payload\DataList;
|
||||
|
||||
|
||||
@@ -70,6 +72,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the PayloadInstance
|
||||
*
|
||||
@@ -78,11 +92,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the PayloadInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the PayloadInstance
|
||||
@@ -92,18 +135,40 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): PayloadInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new PayloadInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['referenceSid'],
|
||||
$this->solution['addOnResultSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the PayloadInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new PayloadInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['referenceSid'],
|
||||
$this->solution['addOnResultSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class PayloadList extends ListResource
|
||||
@@ -79,6 +83,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads PayloadInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams PayloadInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -106,6 +136,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams PayloadInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of PayloadInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -121,19 +209,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): PayloadPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new PayloadPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of PayloadInstance records with metadata
|
||||
* 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 PageMetadata of PayloadInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new PayloadPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of PayloadInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Rest\Api\V2010\Account\Recording\AddOnResult\PayloadList;
|
||||
|
||||
|
||||
@@ -65,6 +67,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AddOnResultInstance
|
||||
*
|
||||
@@ -73,11 +87,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the AddOnResultInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AddOnResultInstance
|
||||
@@ -87,17 +130,38 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): AddOnResultInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new AddOnResultInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['referenceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the AddOnResultInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new AddOnResultInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['referenceSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class AddOnResultList extends ListResource
|
||||
@@ -73,6 +77,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads AddOnResultInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AddOnResultInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -100,6 +130,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams AddOnResultInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AddOnResultInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -115,19 +203,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): AddOnResultPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new AddOnResultPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of AddOnResultInstance records with metadata
|
||||
* 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 PageMetadata of AddOnResultInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new AddOnResultPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of AddOnResultInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
|
||||
|
||||
class TranscriptionContext extends InstanceContext
|
||||
@@ -57,6 +59,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the TranscriptionInstance
|
||||
*
|
||||
@@ -65,11 +79,40 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the TranscriptionInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, [], [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the TranscriptionInstance
|
||||
@@ -79,17 +122,38 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(): TranscriptionInstance
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, [], [], $headers);
|
||||
|
||||
$response = $this->_fetch();
|
||||
return new TranscriptionInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['recordingSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the TranscriptionInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch();
|
||||
$resource = new TranscriptionInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['recordingSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
use Twilio\Stream;
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ArrayMetadata;
|
||||
use Twilio\Metadata\PageMetadata;
|
||||
use Twilio\Metadata\StreamMetadata;
|
||||
|
||||
|
||||
class TranscriptionList extends ListResource
|
||||
@@ -73,6 +77,32 @@ public function read(?int $limit = null, $pageSize = null): array
|
||||
return \iterator_to_array($this->stream($limit, $pageSize), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads TranscriptionInstance 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 ArrayMetadata Array of results along with metadata
|
||||
*/
|
||||
public function readWithMetadata(?int $limit = null, $pageSize = null): ArrayMetadata
|
||||
{
|
||||
$streamWithMetadata = $this->streamWithMetadata($limit, $pageSize);
|
||||
$readResponse = \iterator_to_array($streamWithMetadata, false);
|
||||
return new ArrayMetadata(
|
||||
$readResponse,
|
||||
$streamWithMetadata->getStatusCode(),
|
||||
$streamWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams TranscriptionInstance records from the API as a generator stream.
|
||||
* This operation lazily loads records as efficiently as possible until the
|
||||
@@ -100,6 +130,64 @@ public function stream(?int $limit = null, $pageSize = null): Stream
|
||||
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams TranscriptionInstance records from the API as a generator stream and returns result with Metadata
|
||||
* 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 StreamMetadata stream of results with metadata
|
||||
*/
|
||||
public function streamWithMetadata(?int $limit = null, $pageSize = null): StreamMetadata
|
||||
{
|
||||
$limits = $this->version->readLimits($limit, $pageSize);
|
||||
|
||||
$pageWithMetadata = $this->pageWithMetadata($limits['pageSize']);
|
||||
|
||||
$stream = $this->version->stream($pageWithMetadata->getPage(), $limits['limit'], $limits['pageLimit']);
|
||||
|
||||
return new StreamMetadata(
|
||||
$stream,
|
||||
$pageWithMetadata->getStatusCode(),
|
||||
$pageWithMetadata->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Page
|
||||
*
|
||||
* @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 Response Paged Response
|
||||
*/
|
||||
private function _page(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): Response
|
||||
{
|
||||
|
||||
$params = Values::of([
|
||||
'PageToken' => $pageToken,
|
||||
'Page' => $pageNumber,
|
||||
'PageSize' => $pageSize,
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
|
||||
return $this->version->page('GET', $this->uri, $params, [], $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TranscriptionInstance records from the API.
|
||||
* Request is executed immediately
|
||||
@@ -115,19 +203,37 @@ public function page(
|
||||
$pageNumber = Values::NONE
|
||||
): TranscriptionPage
|
||||
{
|
||||
|
||||
$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);
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
return new TranscriptionPage($this->version, $response, $this->solution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single page of TranscriptionInstance records with metadata
|
||||
* 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 PageMetadata of TranscriptionInstance
|
||||
*/
|
||||
public function pageWithMetadata(
|
||||
$pageSize = Values::NONE,
|
||||
string $pageToken = Values::NONE,
|
||||
$pageNumber = Values::NONE
|
||||
): PageMetadata
|
||||
{
|
||||
$response = $this->_page( $pageSize, $pageToken, $pageNumber);
|
||||
|
||||
$resource = new TranscriptionPage($this->version, $response, $this->solution);
|
||||
|
||||
return new PageMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific page of TranscriptionInstance records from the API.
|
||||
* Request is executed immediately
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
use Twilio\Values;
|
||||
use Twilio\Version;
|
||||
use Twilio\InstanceContext;
|
||||
use Twilio\Http\Response;
|
||||
use Twilio\Metadata\ResourceMetadata;
|
||||
use Twilio\Serialize;
|
||||
use Twilio\Rest\Api\V2010\Account\Recording\AddOnResultList;
|
||||
use Twilio\Rest\Api\V2010\Account\Recording\TranscriptionList;
|
||||
@@ -66,6 +68,18 @@ public function __construct(
|
||||
.'.json';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for Delete
|
||||
*
|
||||
* @return Response Deleted Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _delete(): Response
|
||||
{
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->handleRequest('DELETE', $this->uri, [], [], $headers, "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the RecordingInstance
|
||||
*
|
||||
@@ -74,11 +88,48 @@ public function __construct(
|
||||
*/
|
||||
public function delete(): bool
|
||||
{
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]);
|
||||
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
|
||||
$response = $this->_delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the RecordingInstance with Metadata
|
||||
*
|
||||
* @return ResourceMetadata The Deleted Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function deleteWithMetadata(): ResourceMetadata
|
||||
{
|
||||
$response = $this->_delete();
|
||||
|
||||
return new ResourceMetadata(
|
||||
null,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function for Fetch
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return Response Fetched Response
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
private function _fetch(array $options = []): Response
|
||||
{
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'IncludeSoftDeleted' =>
|
||||
Serialize::booleanToString($options['includeSoftDeleted']),
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
return $this->version->handleRequest('GET', $this->uri, $params, [], $headers, "fetch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the RecordingInstance
|
||||
@@ -89,23 +140,37 @@ public function delete(): bool
|
||||
*/
|
||||
public function fetch(array $options = []): RecordingInstance
|
||||
{
|
||||
|
||||
$options = new Values($options);
|
||||
|
||||
$params = Values::of([
|
||||
'IncludeSoftDeleted' =>
|
||||
Serialize::booleanToString($options['includeSoftDeleted']),
|
||||
]);
|
||||
|
||||
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
|
||||
$payload = $this->version->fetch('GET', $this->uri, $params, [], $headers);
|
||||
|
||||
$response = $this->_fetch($options);
|
||||
return new RecordingInstance(
|
||||
$this->version,
|
||||
$payload,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the RecordingInstance with Metadata
|
||||
*
|
||||
* @param array|Options $options Optional Arguments
|
||||
* @return ResourceMetadata The Fetched Resource with Metadata
|
||||
* @throws TwilioException When an HTTP error occurs.
|
||||
*/
|
||||
public function fetchWithMetadata(array $options = []): ResourceMetadata
|
||||
{
|
||||
$response = $this->_fetch($options);
|
||||
$resource = new RecordingInstance(
|
||||
$this->version,
|
||||
$response->getContent(),
|
||||
$this->solution['accountSid'],
|
||||
$this->solution['sid']
|
||||
);
|
||||
return new ResourceMetadata(
|
||||
$resource,
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user