diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 0ffaa45c69..fc94bb5cd2 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - php: [ 7.2, 7.3, 7.4, 8.0, 8.1 ] + php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 ] dependencies: - "lowest" - "highest" @@ -119,4 +119,4 @@ jobs: SLACK_MSG_AUTHOR: twilio-dx SLACK_FOOTER: Posted automatically using GitHub Actions SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - MSG_MINIMAL: true \ No newline at end of file + MSG_MINIMAL: true diff --git a/README.md b/README.md index 6020cea9b4..0d9b24d1c3 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ This library supports the following PHP implementations: - PHP 7.4 - PHP 8.0 - PHP 8.1 +- PHP 8.2 +- PHP 8.3 ## Installation diff --git a/UPGRADE.md b/UPGRADE.md index b68ac96177..171d2dc145 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,6 +2,13 @@ _MAJOR version bumps will have upgrade notes posted here._ +[2023-03-25] 7.x.x to 8.x.x +--------------------------- +Twilio Php Helper Library’s major version 8.0.0 is now available. We ensured that you can upgrade to Php helper Library 8.0.0 version without any breaking changes of existing apis + +Behind the scenes Php Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages. +We're pleased to inform you that version 8.0.0 adds support for the application/json content type in the request body. + [2023-03-08] 6.x.x to 7.x.x --------------------------- Twilio Php Helper Library’s major version 7.0.1 is now available. We ensured that you can upgrade to Php helper Library 7.0.1 version without any breaking changes. diff --git a/example/messaging_bulk.php b/example/messaging_bulk.php new file mode 100644 index 0000000000..3456ad960b --- /dev/null +++ b/example/messaging_bulk.php @@ -0,0 +1,54 @@ + $phoneNumber1, + ] +); +$message2 = MessageModels::createMessagingV1Message( + [ + 'to' => $phoneNumber2, + ] +); + +// Create list of the message objects +$messages = [$message1, $message2]; + +// This must be a Twilio phone number that you own, formatted with a '+' and country code +$twilioPurchasedNumber = "+XXXXXXXXXX"; +// Specify the message to be sent - JSON string supported +$messageBody = "Hello from twilio-php!"; + +// Create Message Request object +$createMessagesRequest = MessageModels::createCreateMessagesRequest( + [ + 'messages' => $messages, + 'from' => $twilioPurchasedNumber, + 'body' => $messageBody, + ] +); + +// Send a Bulk Message +$message = $client->previewMessaging->v1->messages->create($createMessagesRequest); + +// Print how many messages were successful +print($message->successCount . " messages sent successfully!" . "\n\n"); + +// Print the message details +foreach ($message->messageReceipts as $msg) { + print("ID:: " . $msg["sid"] . " | " . "TO:: " . $msg["to"] . "\n"); +} diff --git a/src/Twilio/Http/CurlClient.php b/src/Twilio/Http/CurlClient.php index 788cf23caf..95f1d50525 100644 --- a/src/Twilio/Http/CurlClient.php +++ b/src/Twilio/Http/CurlClient.php @@ -120,7 +120,11 @@ public function options(string $method, string $url, [$headers, $body] = $this->buildMultipartOptions($data); $options[CURLOPT_POSTFIELDS] = $body; $options[CURLOPT_HTTPHEADER] = \array_merge($options[CURLOPT_HTTPHEADER], $headers); - } else { + } + elseif (array_key_exists('Content-Type', $headers)) { + $options[CURLOPT_POSTFIELDS] = json_encode($data); + } + else { $options[CURLOPT_POSTFIELDS] = $this->buildQuery($data); $options[CURLOPT_HTTPHEADER][] = 'Content-Type: application/x-www-form-urlencoded'; } diff --git a/src/Twilio/Rest/Client.php b/src/Twilio/Rest/Client.php index dd9b0490ed..73ceeefc5d 100644 --- a/src/Twilio/Rest/Client.php +++ b/src/Twilio/Rest/Client.php @@ -31,6 +31,7 @@ * @property Intelligence $intelligence * @property IpMessaging $ipMessaging * @property Lookups $lookups + * @property PreviewMessaging $previewMessaging * @property Messaging $messaging * @property Microvisor $microvisor * @property Monitor $monitor @@ -109,6 +110,7 @@ class Client extends BaseClient { protected $_intelligence; protected $_ipMessaging; protected $_lookups; + protected $_previewMessaging; protected $_messaging; protected $_microvisor; protected $_monitor; @@ -274,6 +276,17 @@ protected function getLookups(): Lookups { } return $this->_lookups; } + /** + * Access the PreviewMessaging Twilio Domain + * + * @return PreviewMessaging PreviewMessaging Twilio Domain + */ + protected function getPreviewMessaging(): PreviewMessaging { + if (!$this->_previewMessaging) { + $this->_previewMessaging = new PreviewMessaging($this); + } + return $this->_previewMessaging; + } /** * Access the Messaging Twilio Domain * diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalCreateInstance.php b/src/Twilio/Rest/Content/V1/Content/ApprovalCreateInstance.php new file mode 100644 index 0000000000..5d58539790 --- /dev/null +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalCreateInstance.php @@ -0,0 +1,91 @@ +properties = [ + 'name' => Values::array_get($payload, 'name'), + 'category' => Values::array_get($payload, 'category'), + 'contentType' => Values::array_get($payload, 'content_type'), + 'status' => Values::array_get($payload, 'status'), + 'rejectionReason' => Values::array_get($payload, 'rejection_reason'), + 'allowCategoryChange' => Values::array_get($payload, 'allow_category_change'), + ]; + + $this->solution = ['contentSid' => $contentSid, ]; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Content.V1.ApprovalCreateInstance]'; + } +} + diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalCreateList.php b/src/Twilio/Rest/Content/V1/Content/ApprovalCreateList.php new file mode 100644 index 0000000000..33f0d9a759 --- /dev/null +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalCreateList.php @@ -0,0 +1,80 @@ +solution = [ + 'contentSid' => + $contentSid, + + ]; + + $this->uri = '/Content/' . \rawurlencode($contentSid) + .'/ApprovalRequests/whatsapp'; + } + + /** + * Create the ApprovalCreateInstance + * + * @param ContentApprovalRequest $contentApprovalRequest + * @return ApprovalCreateInstance Created ApprovalCreateInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(ContentApprovalRequest $contentApprovalRequest): ApprovalCreateInstance + { + + $data = $contentApprovalRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new ApprovalCreateInstance( + $this->version, + $payload, + $this->solution['contentSid'] + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Content.V1.ApprovalCreateList]'; + } +} diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalCreateModels.php b/src/Twilio/Rest/Content/V1/Content/ApprovalCreateModels.php new file mode 100644 index 0000000000..c1581bb6a1 --- /dev/null +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalCreateModels.php @@ -0,0 +1,58 @@ +name = Values::array_get($payload, 'name'); + $this->category = Values::array_get($payload, 'category'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'name' => $this->name, + 'category' => $this->category + ]; + } +} + diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalCreatePage.php b/src/Twilio/Rest/Content/V1/Content/ApprovalCreatePage.php new file mode 100644 index 0000000000..2e9085413e --- /dev/null +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalCreatePage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return ApprovalCreateInstance \Twilio\Rest\Content\V1\Content\ApprovalCreateInstance + */ + public function buildInstance(array $payload): ApprovalCreateInstance + { + return new ApprovalCreateInstance($this->version, $payload, $this->solution['contentSid']); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Content.V1.ApprovalCreatePage]'; + } +} diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php index a5e52ed901..44178edbb5 100644 --- a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php @@ -28,21 +28,21 @@ class ApprovalFetchContext extends InstanceContext * Initialize the ApprovalFetchContext * * @param Version $version Version that contains the resource - * @param string $sid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + * @param string $contentSid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. */ public function __construct( Version $version, - $sid + $contentSid ) { parent::__construct($version); // Path Solution $this->solution = [ - 'sid' => - $sid, + 'contentSid' => + $contentSid, ]; - $this->uri = '/Content/' . \rawurlencode($sid) + $this->uri = '/Content/' . \rawurlencode($contentSid) .'/ApprovalRequests'; } @@ -60,7 +60,7 @@ public function fetch(): ApprovalFetchInstance return new ApprovalFetchInstance( $this->version, $payload, - $this->solution['sid'] + $this->solution['contentSid'] ); } diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchInstance.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchInstance.php index ee3d34d362..44a96fa284 100644 --- a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchInstance.php +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchInstance.php @@ -36,9 +36,9 @@ class ApprovalFetchInstance extends InstanceResource * * @param Version $version Version that contains the resource * @param mixed[] $payload The response payload - * @param string $sid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + * @param string $contentSid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. */ - public function __construct(Version $version, array $payload, string $sid) + public function __construct(Version $version, array $payload, string $contentSid) { parent::__construct($version); @@ -50,7 +50,7 @@ public function __construct(Version $version, array $payload, string $sid) 'url' => Values::array_get($payload, 'url'), ]; - $this->solution = ['sid' => $sid, ]; + $this->solution = ['contentSid' => $contentSid, ]; } /** @@ -64,7 +64,7 @@ protected function proxy(): ApprovalFetchContext if (!$this->context) { $this->context = new ApprovalFetchContext( $this->version, - $this->solution['sid'] + $this->solution['contentSid'] ); } diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchList.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchList.php index 9bb948a712..35301ef375 100644 --- a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchList.php +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchList.php @@ -26,18 +26,18 @@ class ApprovalFetchList extends ListResource * Construct the ApprovalFetchList * * @param Version $version Version that contains the resource - * @param string $sid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + * @param string $contentSid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. */ public function __construct( Version $version, - string $sid + string $contentSid ) { parent::__construct($version); // Path Solution $this->solution = [ - 'sid' => - $sid, + 'contentSid' => + $contentSid, ]; } @@ -51,7 +51,7 @@ public function getContext( { return new ApprovalFetchContext( $this->version, - $this->solution['sid'] + $this->solution['contentSid'] ); } diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchPage.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchPage.php index b205cd3850..1bc0791e79 100644 --- a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchPage.php +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchPage.php @@ -40,7 +40,7 @@ public function __construct(Version $version, Response $response, array $solutio */ public function buildInstance(array $payload): ApprovalFetchInstance { - return new ApprovalFetchInstance($this->version, $payload, $this->solution['sid']); + return new ApprovalFetchInstance($this->version, $payload, $this->solution['contentSid']); } /** diff --git a/src/Twilio/Rest/Content/V1/ContentContext.php b/src/Twilio/Rest/Content/V1/ContentContext.php index 001c4aaf21..f81387ed3a 100644 --- a/src/Twilio/Rest/Content/V1/ContentContext.php +++ b/src/Twilio/Rest/Content/V1/ContentContext.php @@ -21,15 +21,18 @@ use Twilio\ListResource; use Twilio\Version; use Twilio\InstanceContext; +use Twilio\Rest\Content\V1\Content\ApprovalCreateList; use Twilio\Rest\Content\V1\Content\ApprovalFetchList; /** + * @property ApprovalCreateList $approvalCreate * @property ApprovalFetchList $approvalFetch * @method \Twilio\Rest\Content\V1\Content\ApprovalFetchContext approvalFetch() */ class ContentContext extends InstanceContext { + protected $_approvalCreate; protected $_approvalFetch; /** @@ -86,6 +89,21 @@ public function fetch(): ContentInstance } + /** + * Access the approvalCreate + */ + protected function getApprovalCreate(): ApprovalCreateList + { + if (!$this->_approvalCreate) { + $this->_approvalCreate = new ApprovalCreateList( + $this->version, + $this->solution['sid'] + ); + } + + return $this->_approvalCreate; + } + /** * Access the approvalFetch */ diff --git a/src/Twilio/Rest/Content/V1/ContentInstance.php b/src/Twilio/Rest/Content/V1/ContentInstance.php index 49395d319a..166c9b912c 100644 --- a/src/Twilio/Rest/Content/V1/ContentInstance.php +++ b/src/Twilio/Rest/Content/V1/ContentInstance.php @@ -22,6 +22,7 @@ use Twilio\Values; use Twilio\Version; use Twilio\Deserialize; +use Twilio\Rest\Content\V1\Content\ApprovalCreateList; use Twilio\Rest\Content\V1\Content\ApprovalFetchList; @@ -39,6 +40,7 @@ */ class ContentInstance extends InstanceResource { + protected $_approvalCreate; protected $_approvalFetch; /** @@ -111,6 +113,14 @@ public function fetch(): ContentInstance return $this->proxy()->fetch(); } + /** + * Access the approvalCreate + */ + protected function getApprovalCreate(): ApprovalCreateList + { + return $this->proxy()->approvalCreate; + } + /** * Access the approvalFetch */ diff --git a/src/Twilio/Rest/Content/V1/ContentList.php b/src/Twilio/Rest/Content/V1/ContentList.php index 6005e973e1..6d611f1ad8 100644 --- a/src/Twilio/Rest/Content/V1/ContentList.php +++ b/src/Twilio/Rest/Content/V1/ContentList.php @@ -16,6 +16,7 @@ namespace Twilio\Rest\Content\V1; +use Twilio\Exceptions\TwilioException; use Twilio\ListResource; use Twilio\Stream; use Twilio\Values; @@ -41,6 +42,27 @@ public function __construct( $this->uri = '/Content'; } + /** + * Create the ContentInstance + * + * @param ContentCreateRequest $contentCreateRequest + * @return ContentInstance Created ContentInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(ContentCreateRequest $contentCreateRequest): ContentInstance + { + + $data = $contentCreateRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new ContentInstance( + $this->version, + $payload + ); + } + + /** * Reads ContentInstance records from the API as a list. * Unlike stream(), this operation is eager and will load `limit` records into diff --git a/src/Twilio/Rest/Content/V1/ContentModels.php b/src/Twilio/Rest/Content/V1/ContentModels.php new file mode 100644 index 0000000000..eee21de9e2 --- /dev/null +++ b/src/Twilio/Rest/Content/V1/ContentModels.php @@ -0,0 +1,835 @@ + $variables Key value pairs of variable name to value + * @property string $language Language code for the content + * @property Types $types + */ + public static function createContentCreateRequest(array $payload = []): ContentCreateRequest + { + return new ContentCreateRequest($payload); + } + +} + +class TwilioText implements \JsonSerializable +{ + /** + * @property string $body + */ + protected $body; + public function __construct(array $payload = []) { + $this->body = Values::array_get($payload, 'body'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'body' => $this->body + ]; + } +} + +class TwilioMedia implements \JsonSerializable +{ + /** + * @property string $body + * @property string[] $media + */ + protected $body; + protected $media; + public function __construct(array $payload = []) { + $this->body = Values::array_get($payload, 'body'); + $this->media = Values::array_get($payload, 'media'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'body' => $this->body, + 'media' => $this->media + ]; + } +} + +class TwilioLocation implements \JsonSerializable +{ + /** + * @property string $latitude + * @property string $longitude + * @property string $label + */ + protected $latitude; + protected $longitude; + protected $label; + public function __construct(array $payload = []) { + $this->latitude = Values::array_get($payload, 'latitude'); + $this->longitude = Values::array_get($payload, 'longitude'); + $this->label = Values::array_get($payload, 'label'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'latitude' => $this->latitude, + 'longitude' => $this->longitude, + 'label' => $this->label + ]; + } +} + +class ListItem implements \JsonSerializable +{ + /** + * @property string $id + * @property string $item + * @property string $description + */ + protected $id; + protected $item; + protected $description; + public function __construct(array $payload = []) { + $this->id = Values::array_get($payload, 'id'); + $this->item = Values::array_get($payload, 'item'); + $this->description = Values::array_get($payload, 'description'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'id' => $this->id, + 'item' => $this->item, + 'description' => $this->description + ]; + } +} + +class TwilioListPicker implements \JsonSerializable +{ + /** + * @property string $body + * @property string $button + * @property ListItem[] $items + */ + protected $body; + protected $button; + protected $items; + public function __construct(array $payload = []) { + $this->body = Values::array_get($payload, 'body'); + $this->button = Values::array_get($payload, 'button'); + $this->items = Values::array_get($payload, 'items'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'body' => $this->body, + 'button' => $this->button, + 'items' => $this->items + ]; + } +} + +class CallToActionAction implements \JsonSerializable +{ + /** + * @property string $type + * @property string $title + * @property string $url + * @property string $phone + * @property string $id + */ + protected $type; + protected $title; + protected $url; + protected $phone; + protected $id; + public function __construct(array $payload = []) { + $this->type = Values::array_get($payload, 'type'); + $this->title = Values::array_get($payload, 'title'); + $this->url = Values::array_get($payload, 'url'); + $this->phone = Values::array_get($payload, 'phone'); + $this->id = Values::array_get($payload, 'id'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'type' => $this->type, + 'title' => $this->title, + 'url' => $this->url, + 'phone' => $this->phone, + 'id' => $this->id + ]; + } +} + +class TwilioCallToAction implements \JsonSerializable +{ + /** + * @property string $body + * @property CallToActionAction[] $actions + */ + protected $body; + protected $actions; + public function __construct(array $payload = []) { + $this->body = Values::array_get($payload, 'body'); + $this->actions = Values::array_get($payload, 'actions'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'body' => $this->body, + 'actions' => $this->actions + ]; + } +} + +class QuickReplyAction implements \JsonSerializable +{ + /** + * @property string $type + * @property string $title + * @property string $id + */ + protected $type; + protected $title; + protected $id; + public function __construct(array $payload = []) { + $this->type = Values::array_get($payload, 'type'); + $this->title = Values::array_get($payload, 'title'); + $this->id = Values::array_get($payload, 'id'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'type' => $this->type, + 'title' => $this->title, + 'id' => $this->id + ]; + } +} + +class TwilioQuickReply implements \JsonSerializable +{ + /** + * @property string $body + * @property QuickReplyAction[] $actions + */ + protected $body; + protected $actions; + public function __construct(array $payload = []) { + $this->body = Values::array_get($payload, 'body'); + $this->actions = Values::array_get($payload, 'actions'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'body' => $this->body, + 'actions' => $this->actions + ]; + } +} + +class CardAction implements \JsonSerializable +{ + /** + * @property string $type + * @property string $title + * @property string $url + * @property string $phone + * @property string $id + */ + protected $type; + protected $title; + protected $url; + protected $phone; + protected $id; + public function __construct(array $payload = []) { + $this->type = Values::array_get($payload, 'type'); + $this->title = Values::array_get($payload, 'title'); + $this->url = Values::array_get($payload, 'url'); + $this->phone = Values::array_get($payload, 'phone'); + $this->id = Values::array_get($payload, 'id'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'type' => $this->type, + 'title' => $this->title, + 'url' => $this->url, + 'phone' => $this->phone, + 'id' => $this->id + ]; + } +} + +class TwilioCard implements \JsonSerializable +{ + /** + * @property string $title + * @property string $subtitle + * @property string[] $media + * @property CardAction[] $actions + */ + protected $title; + protected $subtitle; + protected $media; + protected $actions; + public function __construct(array $payload = []) { + $this->title = Values::array_get($payload, 'title'); + $this->subtitle = Values::array_get($payload, 'subtitle'); + $this->media = Values::array_get($payload, 'media'); + $this->actions = Values::array_get($payload, 'actions'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'title' => $this->title, + 'subtitle' => $this->subtitle, + 'media' => $this->media, + 'actions' => $this->actions + ]; + } +} + +class CatalogItem implements \JsonSerializable +{ + /** + * @property string $id + * @property string $sectionTitle + * @property string $name + * @property string $mediaUrl + * @property string $price + * @property string $description + */ + protected $id; + protected $sectionTitle; + protected $name; + protected $mediaUrl; + protected $price; + protected $description; + public function __construct(array $payload = []) { + $this->id = Values::array_get($payload, 'id'); + $this->sectionTitle = Values::array_get($payload, 'sectionTitle'); + $this->name = Values::array_get($payload, 'name'); + $this->mediaUrl = Values::array_get($payload, 'mediaUrl'); + $this->price = Values::array_get($payload, 'price'); + $this->description = Values::array_get($payload, 'description'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'id' => $this->id, + 'sectionTitle' => $this->sectionTitle, + 'name' => $this->name, + 'mediaUrl' => $this->mediaUrl, + 'price' => $this->price, + 'description' => $this->description + ]; + } +} + +class TwilioCatalog implements \JsonSerializable +{ + /** + * @property string $title + * @property string $body + * @property string $subtitle + * @property string $id + * @property CatalogItem[] $items + * @property string $dynamicItems + */ + protected $title; + protected $body; + protected $subtitle; + protected $id; + protected $items; + protected $dynamicItems; + public function __construct(array $payload = []) { + $this->title = Values::array_get($payload, 'title'); + $this->body = Values::array_get($payload, 'body'); + $this->subtitle = Values::array_get($payload, 'subtitle'); + $this->id = Values::array_get($payload, 'id'); + $this->items = Values::array_get($payload, 'items'); + $this->dynamicItems = Values::array_get($payload, 'dynamicItems'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'title' => $this->title, + 'body' => $this->body, + 'subtitle' => $this->subtitle, + 'id' => $this->id, + 'items' => $this->items, + 'dynamicItems' => $this->dynamicItems + ]; + } +} + +class WhatsappCard implements \JsonSerializable +{ + /** + * @property string $body + * @property string $footer + * @property string[] $media + * @property string $headerText + * @property CardAction[] $actions + */ + protected $body; + protected $footer; + protected $media; + protected $headerText; + protected $actions; + public function __construct(array $payload = []) { + $this->body = Values::array_get($payload, 'body'); + $this->footer = Values::array_get($payload, 'footer'); + $this->media = Values::array_get($payload, 'media'); + $this->headerText = Values::array_get($payload, 'headerText'); + $this->actions = Values::array_get($payload, 'actions'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'body' => $this->body, + 'footer' => $this->footer, + 'media' => $this->media, + 'headerText' => $this->headerText, + 'actions' => $this->actions + ]; + } +} + +class AuthenticationAction implements \JsonSerializable +{ + /** + * @property string $type + * @property string $copyCodeText + */ + protected $type; + protected $copyCodeText; + public function __construct(array $payload = []) { + $this->type = Values::array_get($payload, 'type'); + $this->copyCodeText = Values::array_get($payload, 'copyCodeText'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'type' => $this->type, + 'copyCodeText' => $this->copyCodeText + ]; + } +} + +class WhatsappAuthentication implements \JsonSerializable +{ + /** + * @property bool $addSecurityRecommendation + * @property string $codeExpirationMinutes + * @property AuthenticationAction[] $actions + */ + protected $addSecurityRecommendation; + protected $codeExpirationMinutes; + protected $actions; + public function __construct(array $payload = []) { + $this->addSecurityRecommendation = Values::array_get($payload, 'addSecurityRecommendation'); + $this->codeExpirationMinutes = Values::array_get($payload, 'codeExpirationMinutes'); + $this->actions = Values::array_get($payload, 'actions'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'addSecurityRecommendation' => $this->addSecurityRecommendation, + 'codeExpirationMinutes' => $this->codeExpirationMinutes, + 'actions' => $this->actions + ]; + } +} + +class Types implements \JsonSerializable +{ + /** + * @property TwilioText $twilioText + * @property TwilioMedia $twilioMedia + * @property TwilioLocation $twilioLocation + * @property TwilioListPicker $twilioListPicker + * @property TwilioCallToAction $twilioCallToAction + * @property TwilioQuickReply $twilioQuickReply + * @property TwilioCard $twilioCard + * @property TwilioCatalog $twilioCatalog + * @property WhatsappCard $whatsappCard + * @property WhatsappAuthentication $whatsappAuthentication + */ + protected $twilioText; + protected $twilioMedia; + protected $twilioLocation; + protected $twilioListPicker; + protected $twilioCallToAction; + protected $twilioQuickReply; + protected $twilioCard; + protected $twilioCatalog; + protected $whatsappCard; + protected $whatsappAuthentication; + public function __construct(array $payload = []) { + $this->twilioText = Values::array_get($payload, 'twilioText'); + $this->twilioMedia = Values::array_get($payload, 'twilioMedia'); + $this->twilioLocation = Values::array_get($payload, 'twilioLocation'); + $this->twilioListPicker = Values::array_get($payload, 'twilioListPicker'); + $this->twilioCallToAction = Values::array_get($payload, 'twilioCallToAction'); + $this->twilioQuickReply = Values::array_get($payload, 'twilioQuickReply'); + $this->twilioCard = Values::array_get($payload, 'twilioCard'); + $this->twilioCatalog = Values::array_get($payload, 'twilioCatalog'); + $this->whatsappCard = Values::array_get($payload, 'whatsappCard'); + $this->whatsappAuthentication = Values::array_get($payload, 'whatsappAuthentication'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'twilioText' => $this->twilioText, + 'twilioMedia' => $this->twilioMedia, + 'twilioLocation' => $this->twilioLocation, + 'twilioListPicker' => $this->twilioListPicker, + 'twilioCallToAction' => $this->twilioCallToAction, + 'twilioQuickReply' => $this->twilioQuickReply, + 'twilioCard' => $this->twilioCard, + 'twilioCatalog' => $this->twilioCatalog, + 'whatsappCard' => $this->whatsappCard, + 'whatsappAuthentication' => $this->whatsappAuthentication + ]; + } +} + +class ContentCreateRequest implements \JsonSerializable +{ + /** + * @property string $friendlyName User defined name of the content + * @property array $variables Key value pairs of variable name to value + * @property string $language Language code for the content + * @property Types $types + */ + protected $friendlyName; + protected $variables; + protected $language; + protected $types; + public function __construct(array $payload = []) { + $this->friendlyName = Values::array_get($payload, 'friendlyName'); + $this->variables = Values::array_get($payload, 'variables'); + $this->language = Values::array_get($payload, 'language'); + $this->types = Values::array_get($payload, 'types'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'friendlyName' => $this->friendlyName, + 'variables' => $this->variables, + 'language' => $this->language, + 'types' => $this->types + ]; + } +} + diff --git a/src/Twilio/Rest/FlexApi/V1/ConfigurationContext.php b/src/Twilio/Rest/FlexApi/V1/ConfigurationContext.php index f4d2affd9e..1412b913c3 100644 --- a/src/Twilio/Rest/FlexApi/V1/ConfigurationContext.php +++ b/src/Twilio/Rest/FlexApi/V1/ConfigurationContext.php @@ -69,6 +69,26 @@ public function fetch(array $options = []): ConfigurationInstance } + /** + * Update the ConfigurationInstance + * + * @return ConfigurationInstance Updated ConfigurationInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): ConfigurationInstance + { + + $data = $body->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->update('POST', $this->uri, [], $data, $headers); + + return new ConfigurationInstance( + $this->version, + $payload + ); + } + + /** * Provide a friendly representation * diff --git a/src/Twilio/Rest/FlexApi/V1/ConfigurationInstance.php b/src/Twilio/Rest/FlexApi/V1/ConfigurationInstance.php index aeb3e27546..27b6747d90 100644 --- a/src/Twilio/Rest/FlexApi/V1/ConfigurationInstance.php +++ b/src/Twilio/Rest/FlexApi/V1/ConfigurationInstance.php @@ -174,6 +174,18 @@ public function fetch(array $options = []): ConfigurationInstance return $this->proxy()->fetch($options); } + /** + * Update the ConfigurationInstance + * + * @return ConfigurationInstance Updated ConfigurationInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): ConfigurationInstance + { + + return $this->proxy()->update(); + } + /** * Magic getter to access properties * diff --git a/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.php b/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.php index b48d0364cc..48530ff51a 100644 --- a/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.php +++ b/src/Twilio/Rest/FlexApi/V1/ConfigurationOptions.php @@ -35,6 +35,7 @@ public static function fetch( ); } + } class FetchConfigurationOptions extends Options @@ -74,3 +75,4 @@ public function __toString(): string } } + diff --git a/src/Twilio/Rest/Numbers/V1.php b/src/Twilio/Rest/Numbers/V1.php index 6e6552e77f..b7792c883f 100644 --- a/src/Twilio/Rest/Numbers/V1.php +++ b/src/Twilio/Rest/Numbers/V1.php @@ -19,14 +19,18 @@ use Twilio\Exceptions\TwilioException; use Twilio\InstanceContext; use Twilio\Rest\Numbers\V1\BulkEligibilityList; +use Twilio\Rest\Numbers\V1\EligibilityList; use Twilio\Rest\Numbers\V1\PortingBulkPortabilityList; +use Twilio\Rest\Numbers\V1\PortingPortInList; use Twilio\Rest\Numbers\V1\PortingPortInFetchList; use Twilio\Rest\Numbers\V1\PortingPortabilityList; use Twilio\Version; /** * @property BulkEligibilityList $bulkEligibilities + * @property EligibilityList $eligibilities * @property PortingBulkPortabilityList $portingBulkPortabilities + * @property PortingPortInList $portingPortIns * @property PortingPortInFetchList $portingPortInsFetch * @property PortingPortabilityList $portingPortabilities * @method \Twilio\Rest\Numbers\V1\BulkEligibilityContext bulkEligibilities(string $requestId) @@ -37,7 +41,9 @@ class V1 extends Version { protected $_bulkEligibilities; + protected $_eligibilities; protected $_portingBulkPortabilities; + protected $_portingPortIns; protected $_portingPortInsFetch; protected $_portingPortabilities; @@ -60,6 +66,14 @@ protected function getBulkEligibilities(): BulkEligibilityList return $this->_bulkEligibilities; } + protected function getEligibilities(): EligibilityList + { + if (!$this->_eligibilities) { + $this->_eligibilities = new EligibilityList($this); + } + return $this->_eligibilities; + } + protected function getPortingBulkPortabilities(): PortingBulkPortabilityList { if (!$this->_portingBulkPortabilities) { @@ -68,6 +82,14 @@ protected function getPortingBulkPortabilities(): PortingBulkPortabilityList return $this->_portingBulkPortabilities; } + protected function getPortingPortIns(): PortingPortInList + { + if (!$this->_portingPortIns) { + $this->_portingPortIns = new PortingPortInList($this); + } + return $this->_portingPortIns; + } + protected function getPortingPortInsFetch(): PortingPortInFetchList { if (!$this->_portingPortInsFetch) { diff --git a/src/Twilio/Rest/Numbers/V1/BulkEligibilityList.php b/src/Twilio/Rest/Numbers/V1/BulkEligibilityList.php index 58fa450bb2..043abde072 100644 --- a/src/Twilio/Rest/Numbers/V1/BulkEligibilityList.php +++ b/src/Twilio/Rest/Numbers/V1/BulkEligibilityList.php @@ -16,6 +16,7 @@ namespace Twilio\Rest\Numbers\V1; +use Twilio\Exceptions\TwilioException; use Twilio\ListResource; use Twilio\Version; @@ -35,8 +36,30 @@ public function __construct( // Path Solution $this->solution = [ ]; + + $this->uri = '/HostedNumber/Eligibility/Bulk'; + } + + /** + * Create the BulkEligibilityInstance + * + * @return BulkEligibilityInstance Created BulkEligibilityInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(): BulkEligibilityInstance + { + + $data = $body->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new BulkEligibilityInstance( + $this->version, + $payload + ); } + /** * Constructs a BulkEligibilityContext * diff --git a/src/Twilio/Rest/Numbers/V1/EligibilityInstance.php b/src/Twilio/Rest/Numbers/V1/EligibilityInstance.php new file mode 100644 index 0000000000..6121a620dd --- /dev/null +++ b/src/Twilio/Rest/Numbers/V1/EligibilityInstance.php @@ -0,0 +1,80 @@ +properties = [ + 'results' => Values::array_get($payload, 'results'), + ]; + + $this->solution = []; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Numbers.V1.EligibilityInstance]'; + } +} + diff --git a/src/Twilio/Rest/Numbers/V1/EligibilityList.php b/src/Twilio/Rest/Numbers/V1/EligibilityList.php new file mode 100644 index 0000000000..52bdd8ef98 --- /dev/null +++ b/src/Twilio/Rest/Numbers/V1/EligibilityList.php @@ -0,0 +1,72 @@ +solution = [ + ]; + + $this->uri = '/HostedNumber/Eligibility'; + } + + /** + * Create the EligibilityInstance + * + * @return EligibilityInstance Created EligibilityInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(): EligibilityInstance + { + + $data = $body->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new EligibilityInstance( + $this->version, + $payload + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Numbers.V1.EligibilityList]'; + } +} diff --git a/src/Twilio/Rest/Numbers/V1/EligibilityPage.php b/src/Twilio/Rest/Numbers/V1/EligibilityPage.php new file mode 100644 index 0000000000..e93779b61a --- /dev/null +++ b/src/Twilio/Rest/Numbers/V1/EligibilityPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return EligibilityInstance \Twilio\Rest\Numbers\V1\EligibilityInstance + */ + public function buildInstance(array $payload): EligibilityInstance + { + return new EligibilityInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Numbers.V1.EligibilityPage]'; + } +} diff --git a/src/Twilio/Rest/Numbers/V1/PortingPortInInstance.php b/src/Twilio/Rest/Numbers/V1/PortingPortInInstance.php new file mode 100644 index 0000000000..ba823a2631 --- /dev/null +++ b/src/Twilio/Rest/Numbers/V1/PortingPortInInstance.php @@ -0,0 +1,82 @@ +properties = [ + 'portInRequestSid' => Values::array_get($payload, 'port_in_request_sid'), + 'url' => Values::array_get($payload, 'url'), + ]; + + $this->solution = []; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Numbers.V1.PortingPortInInstance]'; + } +} + diff --git a/src/Twilio/Rest/Numbers/V1/PortingPortInList.php b/src/Twilio/Rest/Numbers/V1/PortingPortInList.php new file mode 100644 index 0000000000..4ee7379e74 --- /dev/null +++ b/src/Twilio/Rest/Numbers/V1/PortingPortInList.php @@ -0,0 +1,72 @@ +solution = [ + ]; + + $this->uri = '/Porting/PortIn'; + } + + /** + * Create the PortingPortInInstance + * + * @return PortingPortInInstance Created PortingPortInInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(): PortingPortInInstance + { + + $data = $body->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new PortingPortInInstance( + $this->version, + $payload + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Numbers.V1.PortingPortInList]'; + } +} diff --git a/src/Twilio/Rest/Numbers/V1/PortingPortInPage.php b/src/Twilio/Rest/Numbers/V1/PortingPortInPage.php new file mode 100644 index 0000000000..5ab620510e --- /dev/null +++ b/src/Twilio/Rest/Numbers/V1/PortingPortInPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return PortingPortInInstance \Twilio\Rest\Numbers\V1\PortingPortInInstance + */ + public function buildInstance(array $payload): PortingPortInInstance + { + return new PortingPortInInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Numbers.V1.PortingPortInPage]'; + } +} diff --git a/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderList.php b/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderList.php index 4b907af590..c10f6b2fcd 100644 --- a/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderList.php +++ b/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderList.php @@ -16,6 +16,7 @@ namespace Twilio\Rest\Numbers\V2; +use Twilio\Exceptions\TwilioException; use Twilio\ListResource; use Twilio\Version; @@ -35,8 +36,30 @@ public function __construct( // Path Solution $this->solution = [ ]; + + $this->uri = '/HostedNumber/Orders/Bulk'; + } + + /** + * Create the BulkHostedNumberOrderInstance + * + * @return BulkHostedNumberOrderInstance Created BulkHostedNumberOrderInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(): BulkHostedNumberOrderInstance + { + + $data = $body->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new BulkHostedNumberOrderInstance( + $this->version, + $payload + ); } + /** * Constructs a BulkHostedNumberOrderContext * diff --git a/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderOptions.php b/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderOptions.php index a4aebcaccf..9b88e31dbd 100644 --- a/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderOptions.php +++ b/src/Twilio/Rest/Numbers/V2/BulkHostedNumberOrderOptions.php @@ -20,6 +20,7 @@ abstract class BulkHostedNumberOrderOptions { + /** * @param string $orderStatus Order status can be used for filtering on Hosted Number Order status values. To see a complete list of order statuses, please check 'https://www.twilio.com/docs/phone-numbers/hosted-numbers/hosted-numbers-api/hosted-number-order-resource#status-values'. * @return FetchBulkHostedNumberOrderOptions Options builder @@ -37,6 +38,7 @@ public static function fetch( } + class FetchBulkHostedNumberOrderOptions extends Options { /** diff --git a/src/Twilio/Rest/PreviewMessaging.php b/src/Twilio/Rest/PreviewMessaging.php new file mode 100644 index 0000000000..2fd257af84 --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging.php @@ -0,0 +1,21 @@ +oauth instead. + */ + protected function getMessages(): \Twilio\Rest\PreviewMessaging\V1\MessageList { + return $this->v1->messages; + } + + /** + * @deprecated Use v1->oauth() instead. + */ + protected function getBroadcasts(): \Twilio\Rest\PreviewMessaging\V1\BroadcastList { + return $this->v1->broadcasts; + } +} diff --git a/src/Twilio/Rest/PreviewMessaging/V1.php b/src/Twilio/Rest/PreviewMessaging/V1.php new file mode 100644 index 0000000000..91878c502e --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1.php @@ -0,0 +1,105 @@ +version = 'v1'; + } + + protected function getBroadcasts(): BroadcastList + { + if (!$this->_broadcasts) { + $this->_broadcasts = new BroadcastList($this); + } + return $this->_broadcasts; + } + + protected function getMessages(): MessageList + { + if (!$this->_messages) { + $this->_messages = new MessageList($this); + } + return $this->_messages; + } + + /** + * Magic getter to lazy load root resources + * + * @param string $name Resource to return + * @return \Twilio\ListResource The requested resource + * @throws TwilioException For unknown resource + */ + public function __get(string $name) + { + $method = 'get' . \ucfirst($name); + if (\method_exists($this, $method)) { + return $this->$method(); + } + + throw new TwilioException('Unknown resource ' . $name); + } + + /** + * Magic caller to get resource contexts + * + * @param string $name Resource to return + * @param array $arguments Context parameters + * @return InstanceContext The requested resource context + * @throws TwilioException For unknown resource + */ + public function __call(string $name, array $arguments): InstanceContext + { + $property = $this->$name; + if (\method_exists($property, 'getContext')) { + return \call_user_func_array(array($property, 'getContext'), $arguments); + } + + throw new TwilioException('Resource does not have a context'); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1]'; + } +} diff --git a/src/Twilio/Rest/PreviewMessaging/V1/BroadcastInstance.php b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastInstance.php new file mode 100644 index 0000000000..9b5eeeb644 --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastInstance.php @@ -0,0 +1,91 @@ +properties = [ + 'broadcastSid' => Values::array_get($payload, 'broadcast_sid'), + 'createdDate' => Deserialize::dateTime(Values::array_get($payload, 'created_date')), + 'updatedDate' => Deserialize::dateTime(Values::array_get($payload, 'updated_date')), + 'broadcastStatus' => Values::array_get($payload, 'broadcast_status'), + 'executionDetails' => Values::array_get($payload, 'execution_details'), + 'resultsFile' => Values::array_get($payload, 'results_file'), + ]; + + $this->solution = []; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1.BroadcastInstance]'; + } +} + diff --git a/src/Twilio/Rest/PreviewMessaging/V1/BroadcastList.php b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastList.php new file mode 100644 index 0000000000..46154bd265 --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastList.php @@ -0,0 +1,77 @@ +solution = [ + ]; + + $this->uri = '/Broadcasts'; + } + + /** + * Create the BroadcastInstance + * + * @param array|Options $options Optional Arguments + * @return BroadcastInstance Created BroadcastInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(array $options = []): BroadcastInstance + { + + $options = new Values($options); + + $headers = Values::of(['X-Twilio-Request-Key' => $options['xTwilioRequestKey']]); + + $payload = $this->version->create('POST', $this->uri, [], [], $headers); + + return new BroadcastInstance( + $this->version, + $payload + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1.BroadcastList]'; + } +} diff --git a/src/Twilio/Rest/PreviewMessaging/V1/BroadcastOptions.php b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastOptions.php new file mode 100644 index 0000000000..e8ee72576a --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastOptions.php @@ -0,0 +1,76 @@ +options['xTwilioRequestKey'] = $xTwilioRequestKey; + } + + /** + * Idempotency key provided by the client + * + * @param string $xTwilioRequestKey Idempotency key provided by the client + * @return $this Fluent Builder + */ + public function setXTwilioRequestKey(string $xTwilioRequestKey): self + { + $this->options['xTwilioRequestKey'] = $xTwilioRequestKey; + return $this; + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $options = \http_build_query(Values::of($this->options), '', ' '); + return '[Twilio.PreviewMessaging.V1.CreateBroadcastOptions ' . $options . ']'; + } +} + diff --git a/src/Twilio/Rest/PreviewMessaging/V1/BroadcastPage.php b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastPage.php new file mode 100644 index 0000000000..da20fadb1d --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/BroadcastPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return BroadcastInstance \Twilio\Rest\PreviewMessaging\V1\BroadcastInstance + */ + public function buildInstance(array $payload): BroadcastInstance + { + return new BroadcastInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1.BroadcastPage]'; + } +} diff --git a/src/Twilio/Rest/PreviewMessaging/V1/MessageInstance.php b/src/Twilio/Rest/PreviewMessaging/V1/MessageInstance.php new file mode 100644 index 0000000000..aec07a58dd --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/MessageInstance.php @@ -0,0 +1,88 @@ +properties = [ + 'totalMessageCount' => Values::array_get($payload, 'total_message_count'), + 'successCount' => Values::array_get($payload, 'success_count'), + 'errorCount' => Values::array_get($payload, 'error_count'), + 'messageReceipts' => Values::array_get($payload, 'message_receipts'), + 'failedMessageReceipts' => Values::array_get($payload, 'failed_message_receipts'), + ]; + + $this->solution = []; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1.MessageInstance]'; + } +} + diff --git a/src/Twilio/Rest/PreviewMessaging/V1/MessageList.php b/src/Twilio/Rest/PreviewMessaging/V1/MessageList.php new file mode 100644 index 0000000000..829a6b6d39 --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/MessageList.php @@ -0,0 +1,73 @@ +solution = [ + ]; + + $this->uri = '/Messages'; + } + + /** + * Create the MessageInstance + * + * @param CreateMessagesRequest $createMessagesRequest + * @return MessageInstance Created MessageInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(CreateMessagesRequest $createMessagesRequest): MessageInstance + { + + $data = $createMessagesRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new MessageInstance( + $this->version, + $payload + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1.MessageList]'; + } +} diff --git a/src/Twilio/Rest/PreviewMessaging/V1/MessageModels.php b/src/Twilio/Rest/PreviewMessaging/V1/MessageModels.php new file mode 100644 index 0000000000..77fbde1f36 --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/MessageModels.php @@ -0,0 +1,174 @@ + $contentVariables Key-value pairs of variable names to substitution values. Refer to the [Twilio Content API Resources](https://www.twilio.com/docs/content-api/content-api-resources#send-a-message-with-preconfigured-content) for more details. + */ + public static function createMessagingV1Message(array $payload = []): MessagingV1Message + { + return new MessagingV1Message($payload); + } + + /** + * @property MessagingV1Message[] $messages + * @property string $from A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, an [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses) that is enabled for the type of message you want to send. Phone numbers or [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from Twilio also work here. You cannot, for example, spoof messages from a private cell phone number. If you are using `messaging_service_sid`, this parameter must be empty. + * @property string $messagingServiceSid The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services#send-a-message-with-copilot) you want to associate with the Message. Set this parameter to use the [Messaging Service Settings and Copilot Features](https://www.twilio.com/console/sms/services) you have configured and leave the `from` parameter empty. When only this parameter is set, Twilio will use your enabled Copilot Features to select the `from` phone number for delivery. + * @property string $body The text of the message you want to send. Can be up to 1,600 characters in length. + * @property string $contentSid The SID of the preconfigured [Content Template](https://www.twilio.com/docs/content-api/create-and-send-your-first-content-api-template#create-a-template) you want to associate with the Message. Must be used in conjuction with a preconfigured [Messaging Service Settings and Copilot Features](https://www.twilio.com/console/sms/services) When this parameter is set, Twilio will use your configured content template and the provided `ContentVariables`. This Twilio product is currently in Private Beta. + * @property string[] $mediaUrl The URL of the media to send with the message. The media can be of type `gif`, `png`, and `jpeg` and will be formatted correctly on the recipient's device. The media size limit is 5MB for supported file types (JPEG, PNG, GIF) and 500KB for [other types](https://www.twilio.com/docs/sms/accepted-mime-types) of accepted media. To send more than one image in the message body, provide multiple `media_url` parameters in the POST request. You can include up to 10 `media_url` parameters per message. You can send images in an SMS message in only the US and Canada. + * @property string $statusCallback The URL we should call using the \"status_callback_method\" to send status information to your application. If specified, we POST these message status changes to the URL - queued, failed, sent, delivered, or undelivered. Twilio will POST its [standard request parameters](https://www.twilio.com/docs/messaging/twiml#request-parameters) as well as some additional parameters including \"MessageSid\", \"MessageStatus\", and \"ErrorCode\". If you include this parameter with the \"messaging_service_sid\", we use this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api). URLs must contain a valid hostname and underscores are not allowed. + * @property int $validityPeriod How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds. + * @property string $sendAt The time at which Twilio will send the message. This parameter can be used to schedule a message to be sent at a particular time. Must be in ISO 8601 format. + * @property string $scheduleType This parameter indicates your intent to schedule a message. Pass the value `fixed` to schedule a message at a fixed time. This parameter works in conjuction with the `SendAt` parameter. + * @property bool $shortenUrls Determines the usage of Click Tracking. Setting it to `true` will instruct Twilio to replace all links in the Message with a shortened version based on the associated Domain Sid and track clicks on them. If this parameter is not set on an API call, we will use the value set on the Messaging Service. If this parameter is not set and the value is not configured on the Messaging Service used this will default to `false`. + * @property bool $sendAsMms If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media. + * @property string $maxPrice The maximum total price in US dollars that you will pay for the message to be delivered. Can be a decimal value that has up to 4 decimal places. All messages are queued for delivery and the message cost is checked before the message is sent. If the cost exceeds max_price, the message will fail and a status of Failed is sent to the status callback. If MaxPrice is not set, the message cost is not checked. + * @property int $attempt Total number of attempts made ( including this ) to send out the message regardless of the provider used + * @property bool $smartEncoded This parameter indicates whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be true or false. + * @property bool $forceDelivery This parameter allows Twilio to send SMS traffic to carriers without checking/caring whether the destination number is a mobile or a landline. + * @property string $applicationSid The SID of the application that should receive message status. We POST a message_sid parameter and a message_status parameter with a value of sent or failed to the application's message_status_callback. If a status_callback parameter is also passed, it will be ignored and the application's message_status_callback parameter will be used. + */ + public static function createCreateMessagesRequest(array $payload = []): CreateMessagesRequest + { + return new CreateMessagesRequest($payload); + } + +} + +class MessagingV1Message implements \JsonSerializable +{ + /** + * @property string $to The destination phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format for SMS/MMS or [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses) for other 3rd-party channels. + * @property string $body The text of the message you want to send. Can be up to 1,600 characters in length. Overrides the request-level body and content template if provided. + * @property array $contentVariables Key-value pairs of variable names to substitution values. Refer to the [Twilio Content API Resources](https://www.twilio.com/docs/content-api/content-api-resources#send-a-message-with-preconfigured-content) for more details. + */ + protected $to; + protected $body; + protected $contentVariables; + public function __construct(array $payload = []) { + $this->to = Values::array_get($payload, 'to'); + $this->body = Values::array_get($payload, 'body'); + $this->contentVariables = Values::array_get($payload, 'contentVariables'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'to' => $this->to, + 'body' => $this->body, + 'contentVariables' => $this->contentVariables + ]; + } +} + +class CreateMessagesRequest implements \JsonSerializable +{ + /** + * @property MessagingV1Message[] $messages + * @property string $from A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, an [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses) that is enabled for the type of message you want to send. Phone numbers or [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from Twilio also work here. You cannot, for example, spoof messages from a private cell phone number. If you are using `messaging_service_sid`, this parameter must be empty. + * @property string $messagingServiceSid The SID of the [Messaging Service](https://www.twilio.com/docs/sms/services#send-a-message-with-copilot) you want to associate with the Message. Set this parameter to use the [Messaging Service Settings and Copilot Features](https://www.twilio.com/console/sms/services) you have configured and leave the `from` parameter empty. When only this parameter is set, Twilio will use your enabled Copilot Features to select the `from` phone number for delivery. + * @property string $body The text of the message you want to send. Can be up to 1,600 characters in length. + * @property string $contentSid The SID of the preconfigured [Content Template](https://www.twilio.com/docs/content-api/create-and-send-your-first-content-api-template#create-a-template) you want to associate with the Message. Must be used in conjuction with a preconfigured [Messaging Service Settings and Copilot Features](https://www.twilio.com/console/sms/services) When this parameter is set, Twilio will use your configured content template and the provided `ContentVariables`. This Twilio product is currently in Private Beta. + * @property string[] $mediaUrl The URL of the media to send with the message. The media can be of type `gif`, `png`, and `jpeg` and will be formatted correctly on the recipient's device. The media size limit is 5MB for supported file types (JPEG, PNG, GIF) and 500KB for [other types](https://www.twilio.com/docs/sms/accepted-mime-types) of accepted media. To send more than one image in the message body, provide multiple `media_url` parameters in the POST request. You can include up to 10 `media_url` parameters per message. You can send images in an SMS message in only the US and Canada. + * @property string $statusCallback The URL we should call using the \"status_callback_method\" to send status information to your application. If specified, we POST these message status changes to the URL - queued, failed, sent, delivered, or undelivered. Twilio will POST its [standard request parameters](https://www.twilio.com/docs/messaging/twiml#request-parameters) as well as some additional parameters including \"MessageSid\", \"MessageStatus\", and \"ErrorCode\". If you include this parameter with the \"messaging_service_sid\", we use this URL instead of the Status Callback URL of the [Messaging Service](https://www.twilio.com/docs/messaging/services/api). URLs must contain a valid hostname and underscores are not allowed. + * @property int $validityPeriod How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds. + * @property string $sendAt The time at which Twilio will send the message. This parameter can be used to schedule a message to be sent at a particular time. Must be in ISO 8601 format. + * @property string $scheduleType This parameter indicates your intent to schedule a message. Pass the value `fixed` to schedule a message at a fixed time. This parameter works in conjuction with the `SendAt` parameter. + * @property bool $shortenUrls Determines the usage of Click Tracking. Setting it to `true` will instruct Twilio to replace all links in the Message with a shortened version based on the associated Domain Sid and track clicks on them. If this parameter is not set on an API call, we will use the value set on the Messaging Service. If this parameter is not set and the value is not configured on the Messaging Service used this will default to `false`. + * @property bool $sendAsMms If set to True, Twilio will deliver the message as a single MMS message, regardless of the presence of media. + * @property string $maxPrice The maximum total price in US dollars that you will pay for the message to be delivered. Can be a decimal value that has up to 4 decimal places. All messages are queued for delivery and the message cost is checked before the message is sent. If the cost exceeds max_price, the message will fail and a status of Failed is sent to the status callback. If MaxPrice is not set, the message cost is not checked. + * @property int $attempt Total number of attempts made ( including this ) to send out the message regardless of the provider used + * @property bool $smartEncoded This parameter indicates whether to detect Unicode characters that have a similar GSM-7 character and replace them. Can be true or false. + * @property bool $forceDelivery This parameter allows Twilio to send SMS traffic to carriers without checking/caring whether the destination number is a mobile or a landline. + * @property string $applicationSid The SID of the application that should receive message status. We POST a message_sid parameter and a message_status parameter with a value of sent or failed to the application's message_status_callback. If a status_callback parameter is also passed, it will be ignored and the application's message_status_callback parameter will be used. + */ + protected $messages; + protected $from; + protected $messagingServiceSid; + protected $body; + protected $contentSid; + protected $mediaUrl; + protected $statusCallback; + protected $validityPeriod; + protected $sendAt; + protected $scheduleType; + protected $shortenUrls; + protected $sendAsMms; + protected $maxPrice; + protected $attempt; + protected $smartEncoded; + protected $forceDelivery; + protected $applicationSid; + public function __construct(array $payload = []) { + $this->messages = Values::array_get($payload, 'messages'); + $this->from = Values::array_get($payload, 'from'); + $this->messagingServiceSid = Values::array_get($payload, 'messagingServiceSid'); + $this->body = Values::array_get($payload, 'body'); + $this->contentSid = Values::array_get($payload, 'contentSid'); + $this->mediaUrl = Values::array_get($payload, 'mediaUrl'); + $this->statusCallback = Values::array_get($payload, 'statusCallback'); + $this->validityPeriod = Values::array_get($payload, 'validityPeriod'); + $this->sendAt = Values::array_get($payload, 'sendAt'); + $this->scheduleType = Values::array_get($payload, 'scheduleType'); + $this->shortenUrls = Values::array_get($payload, 'shortenUrls'); + $this->sendAsMms = Values::array_get($payload, 'sendAsMms'); + $this->maxPrice = Values::array_get($payload, 'maxPrice'); + $this->attempt = Values::array_get($payload, 'attempt'); + $this->smartEncoded = Values::array_get($payload, 'smartEncoded'); + $this->forceDelivery = Values::array_get($payload, 'forceDelivery'); + $this->applicationSid = Values::array_get($payload, 'applicationSid'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'messages' => $this->messages, + 'from' => $this->from, + 'messagingServiceSid' => $this->messagingServiceSid, + 'body' => $this->body, + 'contentSid' => $this->contentSid, + 'mediaUrl' => $this->mediaUrl, + 'statusCallback' => $this->statusCallback, + 'validityPeriod' => $this->validityPeriod, + 'sendAt' => $this->sendAt, + 'scheduleType' => $this->scheduleType, + 'shortenUrls' => $this->shortenUrls, + 'sendAsMms' => $this->sendAsMms, + 'maxPrice' => $this->maxPrice, + 'attempt' => $this->attempt, + 'smartEncoded' => $this->smartEncoded, + 'forceDelivery' => $this->forceDelivery, + 'applicationSid' => $this->applicationSid + ]; + } +} + diff --git a/src/Twilio/Rest/PreviewMessaging/V1/MessagePage.php b/src/Twilio/Rest/PreviewMessaging/V1/MessagePage.php new file mode 100644 index 0000000000..f469bd583d --- /dev/null +++ b/src/Twilio/Rest/PreviewMessaging/V1/MessagePage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return MessageInstance \Twilio\Rest\PreviewMessaging\V1\MessageInstance + */ + public function buildInstance(array $payload): MessageInstance + { + return new MessageInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.PreviewMessaging.V1.MessagePage]'; + } +} diff --git a/src/Twilio/Rest/PreviewMessagingBase.php b/src/Twilio/Rest/PreviewMessagingBase.php new file mode 100644 index 0000000000..b584e03e4f --- /dev/null +++ b/src/Twilio/Rest/PreviewMessagingBase.php @@ -0,0 +1,88 @@ +baseUrl = 'https://preview.messaging.twilio.com'; + } + + + /** + * @return V1 Version v1 of preview.messaging + */ + protected function getV1(): V1 { + if (!$this->_v1) { + $this->_v1 = new V1($this); + } + return $this->_v1; + } + + /** + * Magic getter to lazy load version + * + * @param string $name Version to return + * @return \Twilio\Version The requested version + * @throws TwilioException For unknown versions + */ + public function __get(string $name) { + $method = 'get' . \ucfirst($name); + if (\method_exists($this, $method)) { + return $this->$method(); + } + + throw new TwilioException('Unknown version ' . $name); + } + + /** + * Magic caller to get resource contexts + * + * @param string $name Resource to return + * @param array $arguments Context parameters + * @return \Twilio\InstanceContext The requested resource context + * @throws TwilioException For unknown resource + */ + public function __call(string $name, array $arguments) { + $method = 'context' . \ucfirst($name); + if (\method_exists($this, $method)) { + return \call_user_func_array([$this, $method], $arguments); + } + + throw new TwilioException('Unknown context ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string { + return '[Twilio.PreviewMessaging]'; + } +} diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsInstance.php b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsInstance.php new file mode 100644 index 0000000000..2e48360bb0 --- /dev/null +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsInstance.php @@ -0,0 +1,89 @@ +properties = [ + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'workspaceSid' => Values::array_get($payload, 'workspace_sid'), + 'taskQueueData' => Values::array_get($payload, 'task_queue_data'), + 'taskQueueResponseCount' => Values::array_get($payload, 'task_queue_response_count'), + 'url' => Values::array_get($payload, 'url'), + ]; + + $this->solution = ['workspaceSid' => $workspaceSid, ]; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Taskrouter.V1.TaskQueueBulkRealTimeStatisticsInstance]'; + } +} + diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsList.php b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsList.php new file mode 100644 index 0000000000..4348d9156f --- /dev/null +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsList.php @@ -0,0 +1,79 @@ +solution = [ + 'workspaceSid' => + $workspaceSid, + + ]; + + $this->uri = '/Workspaces/' . \rawurlencode($workspaceSid) + .'/TaskQueues/RealTimeStatistics'; + } + + /** + * Create the TaskQueueBulkRealTimeStatisticsInstance + * + * @return TaskQueueBulkRealTimeStatisticsInstance Created TaskQueueBulkRealTimeStatisticsInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(): TaskQueueBulkRealTimeStatisticsInstance + { + + $data = $body->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new TaskQueueBulkRealTimeStatisticsInstance( + $this->version, + $payload, + $this->solution['workspaceSid'] + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Taskrouter.V1.TaskQueueBulkRealTimeStatisticsList]'; + } +} diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsPage.php b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsPage.php new file mode 100644 index 0000000000..3a9f052758 --- /dev/null +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueue/TaskQueueBulkRealTimeStatisticsPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return TaskQueueBulkRealTimeStatisticsInstance \Twilio\Rest\Taskrouter\V1\Workspace\TaskQueue\TaskQueueBulkRealTimeStatisticsInstance + */ + public function buildInstance(array $payload): TaskQueueBulkRealTimeStatisticsInstance + { + return new TaskQueueBulkRealTimeStatisticsInstance($this->version, $payload, $this->solution['workspaceSid']); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Taskrouter.V1.TaskQueueBulkRealTimeStatisticsPage]'; + } +} diff --git a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueList.php b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueList.php index 9017d87106..653228c575 100644 --- a/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueList.php +++ b/src/Twilio/Rest/Taskrouter/V1/Workspace/TaskQueueList.php @@ -23,18 +23,18 @@ use Twilio\Values; use Twilio\Version; use Twilio\InstanceContext; -use Twilio\Rest\Taskrouter\V1\Workspace\TaskQueue\TaskQueuesStatisticsList; use Twilio\Rest\Taskrouter\V1\Workspace\TaskQueue\TaskQueueBulkRealTimeStatisticsList; +use Twilio\Rest\Taskrouter\V1\Workspace\TaskQueue\TaskQueuesStatisticsList; /** - * @property TaskQueuesStatisticsList $statistics * @property TaskQueueBulkRealTimeStatisticsList $bulkRealTimeStatistics + * @property TaskQueuesStatisticsList $statistics */ class TaskQueueList extends ListResource { - protected $_statistics = null; protected $_bulkRealTimeStatistics = null; + protected $_statistics = null; /** * Construct the TaskQueueList @@ -219,31 +219,31 @@ public function getContext( } /** - * Access the statistics + * Access the bulkRealTimeStatistics */ - protected function getStatistics(): TaskQueuesStatisticsList + protected function getBulkRealTimeStatistics(): TaskQueueBulkRealTimeStatisticsList { - if (!$this->_statistics) { - $this->_statistics = new TaskQueuesStatisticsList( + if (!$this->_bulkRealTimeStatistics) { + $this->_bulkRealTimeStatistics = new TaskQueueBulkRealTimeStatisticsList( $this->version, $this->solution['workspaceSid'] ); } - return $this->_statistics; + return $this->_bulkRealTimeStatistics; } /** - * Access the bulkRealTimeStatistics + * Access the statistics */ - protected function getBulkRealTimeStatistics(): TaskQueueBulkRealTimeStatisticsList + protected function getStatistics(): TaskQueuesStatisticsList { - if (!$this->_bulkRealTimeStatistics) { - $this->_bulkRealTimeStatistics = new TaskQueueBulkRealTimeStatisticsList( + if (!$this->_statistics) { + $this->_statistics = new TaskQueuesStatisticsList( $this->version, $this->solution['workspaceSid'] ); } - return $this->_bulkRealTimeStatistics; + return $this->_statistics; } /**