From 5a2e91fc61df38351d3590766742dc4235054091 Mon Sep 17 00:00:00 2001 From: Twilio Date: Wed, 18 Sep 2024 13:18:17 +0000 Subject: [PATCH] [Librarian] Regenerated @ 1b6718f23da76f150eac392860c66a26de9af713 ceb130295f80bc623f22496076e3dd57e27da2fb --- CHANGES.md | 10 + src/Twilio/Rest/Assistants.php | 5 + src/Twilio/Rest/Assistants/V1.php | 142 ++++++++++ .../V1/Assistant/FeedbackInstance.php | 100 +++++++ .../Assistants/V1/Assistant/FeedbackList.php | 175 +++++++++++++ .../V1/Assistant/FeedbackModels.php | 68 +++++ .../Assistants/V1/Assistant/FeedbackPage.php | 55 ++++ .../Rest/Assistants/V1/AssistantContext.php | 212 +++++++++++++++ .../Rest/Assistants/V1/AssistantInstance.php | 209 +++++++++++++++ .../Rest/Assistants/V1/AssistantList.php | 184 +++++++++++++ .../Rest/Assistants/V1/AssistantModels.php | 201 ++++++++++++++ .../Rest/Assistants/V1/AssistantPage.php | 55 ++++ .../Assistants/V1/Knowledge/ChunkInstance.php | 90 +++++++ .../Assistants/V1/Knowledge/ChunkList.php | 151 +++++++++++ .../Assistants/V1/Knowledge/ChunkPage.php | 55 ++++ .../Rest/Assistants/V1/KnowledgeContext.php | 194 ++++++++++++++ .../Rest/Assistants/V1/KnowledgeInstance.php | 177 +++++++++++++ .../Rest/Assistants/V1/KnowledgeList.php | 246 ++++++++++++++++++ .../Rest/Assistants/V1/KnowledgeModels.php | 180 +++++++++++++ .../Rest/Assistants/V1/KnowledgeOptions.php | 82 ++++++ .../Rest/Assistants/V1/KnowledgePage.php | 55 ++++ .../Rest/Assistants/V1/PolicyInstance.php | 97 +++++++ src/Twilio/Rest/Assistants/V1/PolicyList.php | 154 +++++++++++ .../Rest/Assistants/V1/PolicyOptions.php | 94 +++++++ src/Twilio/Rest/Assistants/V1/PolicyPage.php | 55 ++++ .../Assistants/V1/Session/MessageInstance.php | 100 +++++++ .../Assistants/V1/Session/MessageList.php | 151 +++++++++++ .../Assistants/V1/Session/MessagePage.php | 55 ++++ .../Rest/Assistants/V1/SessionContext.php | 140 ++++++++++ .../Rest/Assistants/V1/SessionInstance.php | 139 ++++++++++ src/Twilio/Rest/Assistants/V1/SessionList.php | 161 ++++++++++++ src/Twilio/Rest/Assistants/V1/SessionPage.php | 55 ++++ src/Twilio/Rest/Assistants/V1/ToolContext.php | 99 +++++++ .../Rest/Assistants/V1/ToolInstance.php | 146 +++++++++++ src/Twilio/Rest/Assistants/V1/ToolList.php | 191 ++++++++++++++ src/Twilio/Rest/Assistants/V1/ToolModels.php | 195 ++++++++++++++ src/Twilio/Rest/Assistants/V1/ToolOptions.php | 80 ++++++ src/Twilio/Rest/Assistants/V1/ToolPage.php | 55 ++++ src/Twilio/Rest/AssistantsBase.php | 88 +++++++ src/Twilio/Rest/Client.php | 13 + .../V1/Content/ApprovalFetchContext.php | 12 +- .../V1/Content/ApprovalFetchInstance.php | 8 +- .../Content/V1/Content/ApprovalFetchList.php | 10 +- .../Content/V1/Content/ApprovalFetchPage.php | 2 +- .../InstalledAddOnUsageInstance.php | 6 +- .../InstalledAddOnUsageList.php | 2 +- .../InstalledAddOnUsageModels.php | 20 +- .../V1/ModuleDataManagementContext.php | 2 + .../V1/ModuleDataManagementInstance.php | 2 + .../V1/ModuleDataManagementOptions.php | 72 +++-- .../Rest/Numbers/V2/BundleCloneOptions.php | 8 +- .../V2/RegulatoryCompliance/BundleOptions.php | 16 +- 52 files changed, 4810 insertions(+), 64 deletions(-) create mode 100644 src/Twilio/Rest/Assistants.php create mode 100644 src/Twilio/Rest/Assistants/V1.php create mode 100644 src/Twilio/Rest/Assistants/V1/Assistant/FeedbackInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/Assistant/FeedbackList.php create mode 100644 src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php create mode 100644 src/Twilio/Rest/Assistants/V1/Assistant/FeedbackPage.php create mode 100644 src/Twilio/Rest/Assistants/V1/AssistantContext.php create mode 100644 src/Twilio/Rest/Assistants/V1/AssistantInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/AssistantList.php create mode 100644 src/Twilio/Rest/Assistants/V1/AssistantModels.php create mode 100644 src/Twilio/Rest/Assistants/V1/AssistantPage.php create mode 100644 src/Twilio/Rest/Assistants/V1/Knowledge/ChunkInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/Knowledge/ChunkList.php create mode 100644 src/Twilio/Rest/Assistants/V1/Knowledge/ChunkPage.php create mode 100644 src/Twilio/Rest/Assistants/V1/KnowledgeContext.php create mode 100644 src/Twilio/Rest/Assistants/V1/KnowledgeInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/KnowledgeList.php create mode 100644 src/Twilio/Rest/Assistants/V1/KnowledgeModels.php create mode 100644 src/Twilio/Rest/Assistants/V1/KnowledgeOptions.php create mode 100644 src/Twilio/Rest/Assistants/V1/KnowledgePage.php create mode 100644 src/Twilio/Rest/Assistants/V1/PolicyInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/PolicyList.php create mode 100644 src/Twilio/Rest/Assistants/V1/PolicyOptions.php create mode 100644 src/Twilio/Rest/Assistants/V1/PolicyPage.php create mode 100644 src/Twilio/Rest/Assistants/V1/Session/MessageInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/Session/MessageList.php create mode 100644 src/Twilio/Rest/Assistants/V1/Session/MessagePage.php create mode 100644 src/Twilio/Rest/Assistants/V1/SessionContext.php create mode 100644 src/Twilio/Rest/Assistants/V1/SessionInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/SessionList.php create mode 100644 src/Twilio/Rest/Assistants/V1/SessionPage.php create mode 100644 src/Twilio/Rest/Assistants/V1/ToolContext.php create mode 100644 src/Twilio/Rest/Assistants/V1/ToolInstance.php create mode 100644 src/Twilio/Rest/Assistants/V1/ToolList.php create mode 100644 src/Twilio/Rest/Assistants/V1/ToolModels.php create mode 100644 src/Twilio/Rest/Assistants/V1/ToolOptions.php create mode 100644 src/Twilio/Rest/Assistants/V1/ToolPage.php create mode 100644 src/Twilio/Rest/AssistantsBase.php diff --git a/CHANGES.md b/CHANGES.md index e140904d2..add6832c8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,16 @@ twilio-php Changelog ==================== +[2024-09-18] Version 8.3.1 +-------------------------- +**Intelligence** +- Remove public from operator_type +- Update operator_type to include general-availablity and deprecated + +**Numbers** +- Remove beta flag for bundle clone API + + [2024-09-05] Version 8.3.0 -------------------------- **Iam** diff --git a/src/Twilio/Rest/Assistants.php b/src/Twilio/Rest/Assistants.php new file mode 100644 index 000000000..d71a782ac --- /dev/null +++ b/src/Twilio/Rest/Assistants.php @@ -0,0 +1,5 @@ +version = 'v1'; + } + + protected function getAssistants(): AssistantList + { + if (!$this->_assistants) { + $this->_assistants = new AssistantList($this); + } + return $this->_assistants; + } + + protected function getKnowledge(): KnowledgeList + { + if (!$this->_knowledge) { + $this->_knowledge = new KnowledgeList($this); + } + return $this->_knowledge; + } + + protected function getPolicies(): PolicyList + { + if (!$this->_policies) { + $this->_policies = new PolicyList($this); + } + return $this->_policies; + } + + protected function getSessions(): SessionList + { + if (!$this->_sessions) { + $this->_sessions = new SessionList($this); + } + return $this->_sessions; + } + + protected function getTools(): ToolList + { + if (!$this->_tools) { + $this->_tools = new ToolList($this); + } + return $this->_tools; + } + + /** + * 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.Assistants.V1]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackInstance.php b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackInstance.php new file mode 100644 index 000000000..d068a6666 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackInstance.php @@ -0,0 +1,100 @@ +properties = [ + 'assistantId' => Values::array_get($payload, 'assistant_id'), + 'id' => Values::array_get($payload, 'id'), + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'userSid' => Values::array_get($payload, 'user_sid'), + 'messageId' => Values::array_get($payload, 'message_id'), + 'score' => Values::array_get($payload, 'score'), + 'sessionId' => Values::array_get($payload, 'session_id'), + 'text' => Values::array_get($payload, 'text'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $this->solution = ['id' => $id, ]; + } + + /** + * 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.Assistants.V1.FeedbackInstance]'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackList.php b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackList.php new file mode 100644 index 000000000..ba267c375 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackList.php @@ -0,0 +1,175 @@ +solution = [ + 'id' => + $id, + + ]; + + $this->uri = '/Assistants/' . \rawurlencode($id) + .'/Feedbacks'; + } + + /** + * Create the FeedbackInstance + * + * @param AssistantsV1ServiceCreateFeedbackRequest $assistantsV1ServiceCreateFeedbackRequest + * @return FeedbackInstance Created FeedbackInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(AssistantsV1ServiceCreateFeedbackRequest $assistantsV1ServiceCreateFeedbackRequest): FeedbackInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceCreateFeedbackRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new FeedbackInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Reads FeedbackInstance 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 FeedbackInstance[] Array of results + */ + public function read(int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($limit, $pageSize), false); + } + + /** + * Streams FeedbackInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of FeedbackInstance 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 FeedbackPage Page of FeedbackInstance + */ + public function page( + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): FeedbackPage + { + + $params = Values::of([ + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new FeedbackPage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of FeedbackInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return FeedbackPage Page of FeedbackInstance + */ + public function getPage(string $targetUrl): FeedbackPage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new FeedbackPage($this->version, $response, $this->solution); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.FeedbackList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php new file mode 100644 index 000000000..4da9c289b --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php @@ -0,0 +1,68 @@ +messageId = Values::array_get($payload, 'messageId'); + $this->score = Values::array_get($payload, 'score'); + $this->sessionId = Values::array_get($payload, 'sessionId'); + $this->text = Values::array_get($payload, 'text'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'messageId' => $this->messageId, + 'score' => $this->score, + 'sessionId' => $this->sessionId, + 'text' => $this->text + ]; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackPage.php b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackPage.php new file mode 100644 index 000000000..41cb12655 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return FeedbackInstance \Twilio\Rest\Assistants\V1\Assistant\FeedbackInstance + */ + public function buildInstance(array $payload): FeedbackInstance + { + return new FeedbackInstance($this->version, $payload, $this->solution['id']); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.FeedbackPage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/AssistantContext.php b/src/Twilio/Rest/Assistants/V1/AssistantContext.php new file mode 100644 index 000000000..b53639da3 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/AssistantContext.php @@ -0,0 +1,212 @@ +solution = [ + 'id' => + $id, + ]; + + $this->uri = '/Assistants/' . \rawurlencode($id) + .''; + } + + /** + * Delete the AssistantInstance + * + * @return bool True if delete succeeds, false otherwise + * @throws TwilioException When an HTTP error occurs. + */ + public function delete(): bool + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + return $this->version->delete('DELETE', $this->uri, [], [], $headers); + } + + + /** + * Fetch the AssistantInstance + * + * @return AssistantInstance Fetched AssistantInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function fetch(): AssistantInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); + + return new AssistantInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Update the AssistantInstance + * + * @return AssistantInstance Updated AssistantInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): AssistantInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceUpdateAssistantRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->update('PUT', $this->uri, [], $data, $headers); + + return new AssistantInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Access the feedbacks + */ + protected function getFeedbacks(): FeedbackList + { + if (!$this->_feedbacks) { + $this->_feedbacks = new FeedbackList( + $this->version, + $this->solution['id'] + ); + } + + return $this->_feedbacks; + } + + /** + * Access the messages + */ + protected function getMessages(): MessageList + { + if (!$this->_messages) { + $this->_messages = new MessageList( + $this->version, + $this->solution['id'] + ); + } + + return $this->_messages; + } + + /** + * Access the tools + */ + protected function getTools(): ToolList + { + if (!$this->_tools) { + $this->_tools = new ToolList( + $this->version, + $this->solution['id'] + ); + } + + return $this->_tools; + } + + /** + * Magic getter to lazy load subresources + * + * @param string $name Subresource to return + * @return ListResource The requested subresource + * @throws TwilioException For unknown subresources + */ + public function __get(string $name): ListResource + { + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown subresource ' . $name); + } + + /** + * Magic caller to get resource contexts + * + * @param string $name Resource to return + * @param array $arguments Context parameters + * @return InstanceContext The requested resource context + * @throws TwilioException For unknown resource + */ + public function __call(string $name, array $arguments): InstanceContext + { + $property = $this->$name; + if (\method_exists($property, 'getContext')) { + return \call_user_func_array(array($property, 'getContext'), $arguments); + } + + throw new TwilioException('Resource does not have a context'); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.AssistantContext ' . \implode(' ', $context) . ']'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/AssistantInstance.php b/src/Twilio/Rest/Assistants/V1/AssistantInstance.php new file mode 100644 index 000000000..6e315e727 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/AssistantInstance.php @@ -0,0 +1,209 @@ +properties = [ + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'customerAi' => Values::array_get($payload, 'customer_ai'), + 'id' => Values::array_get($payload, 'id'), + 'model' => Values::array_get($payload, 'model'), + 'name' => Values::array_get($payload, 'name'), + 'owner' => Values::array_get($payload, 'owner'), + 'personalityPrompt' => Values::array_get($payload, 'personality_prompt'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'customerAi' => Values::array_get($payload, 'customer_ai'), + 'id' => Values::array_get($payload, 'id'), + 'model' => Values::array_get($payload, 'model'), + 'name' => Values::array_get($payload, 'name'), + 'owner' => Values::array_get($payload, 'owner'), + 'personalityPrompt' => Values::array_get($payload, 'personality_prompt'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + 'knowledge' => Values::array_get($payload, 'knowledge'), + 'tools' => Values::array_get($payload, 'tools'), + ]; + + $this->solution = ['id' => $id ?: $this->properties['id'], ]; + } + + /** + * Generate an instance context for the instance, the context is capable of + * performing various actions. All instance actions are proxied to the context + * + * @return AssistantContext Context for this AssistantInstance + */ + protected function proxy(): AssistantContext + { + if (!$this->context) { + $this->context = new AssistantContext( + $this->version, + $this->solution['id'] + ); + } + + return $this->context; + } + + /** + * Delete the AssistantInstance + * + * @return bool True if delete succeeds, false otherwise + * @throws TwilioException When an HTTP error occurs. + */ + public function delete(): bool + { + + return $this->proxy()->delete(); + } + + /** + * Fetch the AssistantInstance + * + * @return AssistantInstance Fetched AssistantInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function fetch(): AssistantInstance + { + + return $this->proxy()->fetch(); + } + + /** + * Update the AssistantInstance + * + * @return AssistantInstance Updated AssistantInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): AssistantInstance + { + + return $this->proxy()->update(); + } + + /** + * Access the feedbacks + */ + protected function getFeedbacks(): FeedbackList + { + return $this->proxy()->feedbacks; + } + + /** + * Access the messages + */ + protected function getMessages(): MessageList + { + return $this->proxy()->messages; + } + + /** + * Access the tools + */ + protected function getTools(): ToolList + { + return $this->proxy()->tools; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.AssistantInstance ' . \implode(' ', $context) . ']'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/AssistantList.php b/src/Twilio/Rest/Assistants/V1/AssistantList.php new file mode 100644 index 000000000..0644896e7 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/AssistantList.php @@ -0,0 +1,184 @@ +solution = [ + ]; + + $this->uri = '/Assistants'; + } + + /** + * Create the AssistantInstance + * + * @param AssistantsV1ServiceCreateAssistantRequest $assistantsV1ServiceCreateAssistantRequest + * @return AssistantInstance Created AssistantInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(AssistantsV1ServiceCreateAssistantRequest $assistantsV1ServiceCreateAssistantRequest): AssistantInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceCreateAssistantRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new AssistantInstance( + $this->version, + $payload + ); + } + + + /** + * Reads AssistantInstance 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 AssistantInstance[] Array of results + */ + public function read(int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($limit, $pageSize), false); + } + + /** + * Streams AssistantInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of AssistantInstance 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 AssistantPage Page of AssistantInstance + */ + public function page( + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): AssistantPage + { + + $params = Values::of([ + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new AssistantPage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of AssistantInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return AssistantPage Page of AssistantInstance + */ + public function getPage(string $targetUrl): AssistantPage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new AssistantPage($this->version, $response, $this->solution); + } + + + /** + * Constructs a AssistantContext + * + * @param string $id + */ + public function getContext( + string $id + + ): AssistantContext + { + return new AssistantContext( + $this->version, + $id + ); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.AssistantList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/AssistantModels.php b/src/Twilio/Rest/Assistants/V1/AssistantModels.php new file mode 100644 index 000000000..680a1808f --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/AssistantModels.php @@ -0,0 +1,201 @@ +perceptionEngineEnabled = Values::array_get($payload, 'perceptionEngineEnabled'); + $this->personalizationEngineEnabled = Values::array_get($payload, 'personalizationEngineEnabled'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'perceptionEngineEnabled' => $this->perceptionEngineEnabled, + 'personalizationEngineEnabled' => $this->personalizationEngineEnabled + ]; + } +} + +class AssistantsV1ServiceSegmentCredential implements \JsonSerializable +{ + /** + * @property string $profileApiKey The profile API key. + * @property string $spaceId The space ID. + * @property string $writeKey The write key. + */ + protected $profileApiKey; + protected $spaceId; + protected $writeKey; + public function __construct(array $payload = []) { + $this->profileApiKey = Values::array_get($payload, 'profileApiKey'); + $this->spaceId = Values::array_get($payload, 'spaceId'); + $this->writeKey = Values::array_get($payload, 'writeKey'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'profileApiKey' => $this->profileApiKey, + 'spaceId' => $this->spaceId, + 'writeKey' => $this->writeKey + ]; + } +} + +class AssistantsV1ServiceCreateAssistantRequest implements \JsonSerializable +{ + /** + * @property AssistantsV1ServiceCustomerAi $customerAi + * @property string $name The name of the assistant. + * @property string $owner The owner/company of the assistant. + * @property string $personalityPrompt The personality prompt to be used for assistant. + * @property AssistantsV1ServiceSegmentCredential $segmentCredential + */ + protected $customerAi; + protected $name; + protected $owner; + protected $personalityPrompt; + protected $segmentCredential; + public function __construct(array $payload = []) { + $this->customerAi = Values::array_get($payload, 'customerAi'); + $this->name = Values::array_get($payload, 'name'); + $this->owner = Values::array_get($payload, 'owner'); + $this->personalityPrompt = Values::array_get($payload, 'personalityPrompt'); + $this->segmentCredential = Values::array_get($payload, 'segmentCredential'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'customerAi' => $this->customerAi, + 'name' => $this->name, + 'owner' => $this->owner, + 'personalityPrompt' => $this->personalityPrompt, + 'segmentCredential' => $this->segmentCredential + ]; + } +} + +class AssistantsV1ServiceUpdateAssistantRequest implements \JsonSerializable +{ + /** + * @property AssistantsV1ServiceCustomerAi $customerAi + * @property string $name The name of the assistant. + * @property string $owner The owner/company of the assistant. + * @property string $personalityPrompt The personality prompt to be used for assistant. + * @property AssistantsV1ServiceSegmentCredential $segmentCredential + */ + protected $customerAi; + protected $name; + protected $owner; + protected $personalityPrompt; + protected $segmentCredential; + public function __construct(array $payload = []) { + $this->customerAi = Values::array_get($payload, 'customerAi'); + $this->name = Values::array_get($payload, 'name'); + $this->owner = Values::array_get($payload, 'owner'); + $this->personalityPrompt = Values::array_get($payload, 'personalityPrompt'); + $this->segmentCredential = Values::array_get($payload, 'segmentCredential'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'customerAi' => $this->customerAi, + 'name' => $this->name, + 'owner' => $this->owner, + 'personalityPrompt' => $this->personalityPrompt, + 'segmentCredential' => $this->segmentCredential + ]; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/AssistantPage.php b/src/Twilio/Rest/Assistants/V1/AssistantPage.php new file mode 100644 index 000000000..da2635c1c --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/AssistantPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return AssistantInstance \Twilio\Rest\Assistants\V1\AssistantInstance + */ + public function buildInstance(array $payload): AssistantInstance + { + return new AssistantInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.AssistantPage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkInstance.php b/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkInstance.php new file mode 100644 index 000000000..ca58110cb --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkInstance.php @@ -0,0 +1,90 @@ +properties = [ + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'content' => Values::array_get($payload, 'content'), + 'metadata' => Values::array_get($payload, 'metadata'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $this->solution = ['id' => $id, ]; + } + + /** + * 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.Assistants.V1.ChunkInstance]'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkList.php b/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkList.php new file mode 100644 index 000000000..2da05fa36 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkList.php @@ -0,0 +1,151 @@ +solution = [ + 'id' => + $id, + + ]; + + $this->uri = '/Knowledge/' . \rawurlencode($id) + .'/Chunks'; + } + + /** + * Reads ChunkInstance 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 ChunkInstance[] Array of results + */ + public function read(int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($limit, $pageSize), false); + } + + /** + * Streams ChunkInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of ChunkInstance 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 ChunkPage Page of ChunkInstance + */ + public function page( + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): ChunkPage + { + + $params = Values::of([ + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new ChunkPage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of ChunkInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return ChunkPage Page of ChunkInstance + */ + public function getPage(string $targetUrl): ChunkPage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new ChunkPage($this->version, $response, $this->solution); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.ChunkList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkPage.php b/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkPage.php new file mode 100644 index 000000000..f839d220d --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Knowledge/ChunkPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return ChunkInstance \Twilio\Rest\Assistants\V1\Knowledge\ChunkInstance + */ + public function buildInstance(array $payload): ChunkInstance + { + return new ChunkInstance($this->version, $payload, $this->solution['id']); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.ChunkPage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgeContext.php b/src/Twilio/Rest/Assistants/V1/KnowledgeContext.php new file mode 100644 index 000000000..de011a309 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/KnowledgeContext.php @@ -0,0 +1,194 @@ +solution = [ + 'id' => + $id, + ]; + + $this->uri = '/Knowledge/' . \rawurlencode($id) + .''; + } + + /** + * Delete the KnowledgeInstance + * + * @return bool True if delete succeeds, false otherwise + * @throws TwilioException When an HTTP error occurs. + */ + public function delete(): bool + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + return $this->version->delete('DELETE', $this->uri, [], [], $headers); + } + + + /** + * Fetch the KnowledgeInstance + * + * @return KnowledgeInstance Fetched KnowledgeInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function fetch(): KnowledgeInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); + + return new KnowledgeInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Update the KnowledgeInstance + * + * @return KnowledgeInstance Updated KnowledgeInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): KnowledgeInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceUpdateKnowledgeRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->update('PUT', $this->uri, [], $data, $headers); + + return new KnowledgeInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Access the chunks + */ + protected function getChunks(): ChunkList + { + if (!$this->_chunks) { + $this->_chunks = new ChunkList( + $this->version, + $this->solution['id'] + ); + } + + return $this->_chunks; + } + + /** + * Access the status + */ + protected function getStatus(): StatusList + { + if (!$this->_status) { + $this->_status = new StatusList( + $this->version, + $this->solution['id'] + ); + } + + return $this->_status; + } + + /** + * Magic getter to lazy load subresources + * + * @param string $name Subresource to return + * @return ListResource The requested subresource + * @throws TwilioException For unknown subresources + */ + public function __get(string $name): ListResource + { + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown subresource ' . $name); + } + + /** + * Magic caller to get resource contexts + * + * @param string $name Resource to return + * @param array $arguments Context parameters + * @return InstanceContext The requested resource context + * @throws TwilioException For unknown resource + */ + public function __call(string $name, array $arguments): InstanceContext + { + $property = $this->$name; + if (\method_exists($property, 'getContext')) { + return \call_user_func_array(array($property, 'getContext'), $arguments); + } + + throw new TwilioException('Resource does not have a context'); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.KnowledgeContext ' . \implode(' ', $context) . ']'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgeInstance.php b/src/Twilio/Rest/Assistants/V1/KnowledgeInstance.php new file mode 100644 index 000000000..4bbae98a9 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/KnowledgeInstance.php @@ -0,0 +1,177 @@ +properties = [ + 'description' => Values::array_get($payload, 'description'), + 'id' => Values::array_get($payload, 'id'), + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'knowledgeSourceDetails' => Values::array_get($payload, 'knowledge_source_details'), + 'name' => Values::array_get($payload, 'name'), + 'status' => Values::array_get($payload, 'status'), + 'type' => Values::array_get($payload, 'type'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $this->solution = ['id' => $id ?: $this->properties['id'], ]; + } + + /** + * Generate an instance context for the instance, the context is capable of + * performing various actions. All instance actions are proxied to the context + * + * @return KnowledgeContext Context for this KnowledgeInstance + */ + protected function proxy(): KnowledgeContext + { + if (!$this->context) { + $this->context = new KnowledgeContext( + $this->version, + $this->solution['id'] + ); + } + + return $this->context; + } + + /** + * Delete the KnowledgeInstance + * + * @return bool True if delete succeeds, false otherwise + * @throws TwilioException When an HTTP error occurs. + */ + public function delete(): bool + { + + return $this->proxy()->delete(); + } + + /** + * Fetch the KnowledgeInstance + * + * @return KnowledgeInstance Fetched KnowledgeInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function fetch(): KnowledgeInstance + { + + return $this->proxy()->fetch(); + } + + /** + * Update the KnowledgeInstance + * + * @return KnowledgeInstance Updated KnowledgeInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): KnowledgeInstance + { + + return $this->proxy()->update(); + } + + /** + * Access the chunks + */ + protected function getChunks(): ChunkList + { + return $this->proxy()->chunks; + } + + /** + * Access the status + */ + protected function getStatus(): StatusList + { + return $this->proxy()->status; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.KnowledgeInstance ' . \implode(' ', $context) . ']'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgeList.php b/src/Twilio/Rest/Assistants/V1/KnowledgeList.php new file mode 100644 index 000000000..9ae714834 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/KnowledgeList.php @@ -0,0 +1,246 @@ +solution = [ + ]; + + $this->uri = '/Knowledge'; + } + + /** + * Create the KnowledgeInstance + * + * @param AssistantsV1ServiceCreateKnowledgeRequest $assistantsV1ServiceCreateKnowledgeRequest + * @return KnowledgeInstance Created KnowledgeInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(AssistantsV1ServiceCreateKnowledgeRequest $assistantsV1ServiceCreateKnowledgeRequest): KnowledgeInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceCreateKnowledgeRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new KnowledgeInstance( + $this->version, + $payload + ); + } + + + /** + * Reads KnowledgeInstance 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 KnowledgeInstance[] Array of results + */ + public function read(array $options = [], int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($options, $limit, $pageSize), false); + } + + /** + * Streams KnowledgeInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param array|Options $options Optional Arguments + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(array $options = [], int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($options, $limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of KnowledgeInstance 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 KnowledgePage Page of KnowledgeInstance + */ + public function page( + array $options = [], + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): KnowledgePage + { + $options = new Values($options); + + $params = Values::of([ + 'AssistantId' => + $options['assistantId'], + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new KnowledgePage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of KnowledgeInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return KnowledgePage Page of KnowledgeInstance + */ + public function getPage(string $targetUrl): KnowledgePage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new KnowledgePage($this->version, $response, $this->solution); + } + + + /** + * Constructs a KnowledgeContext + * + * @param string $id the Knowledge ID. + */ + public function getContext( + string $id + + ): KnowledgeContext + { + return new KnowledgeContext( + $this->version, + $id + ); + } + + /** + * Access the search + */ + protected function getSearch(): SearchList + { + if (!$this->_search) { + $this->_search = new SearchList( + $this->version + ); + } + return $this->_search; + } + + /** + * Magic getter to lazy load subresources + * + * @param string $name Subresource to return + * @return \Twilio\ListResource The requested subresource + * @throws TwilioException For unknown subresources + */ + public function __get(string $name) + { + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown subresource ' . $name); + } + + /** + * Magic caller to get resource contexts + * + * @param string $name Resource to return + * @param array $arguments Context parameters + * @return InstanceContext The requested resource context + * @throws TwilioException For unknown resource + */ + public function __call(string $name, array $arguments): InstanceContext + { + $property = $this->$name; + if (\method_exists($property, 'getContext')) { + return \call_user_func_array(array($property, 'getContext'), $arguments); + } + + throw new TwilioException('Resource does not have a context'); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.KnowledgeList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php b/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php new file mode 100644 index 000000000..a8ef8581a --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php @@ -0,0 +1,180 @@ +description = Values::array_get($payload, 'description'); + $this->id = Values::array_get($payload, 'id'); + $this->name = Values::array_get($payload, 'name'); + $this->policyDetails = Values::array_get($payload, 'policyDetails'); + $this->type = Values::array_get($payload, 'type'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'description' => $this->description, + 'id' => $this->id, + 'name' => $this->name, + 'policyDetails' => $this->policyDetails, + 'type' => $this->type + ]; + } +} + +class AssistantsV1ServiceCreateKnowledgeRequest implements \JsonSerializable +{ + /** + * @property string $assistantId The Assistant ID. + * @property string $description The description of the knowledge source. + * @property array $knowledgeSourceDetails The details of the knowledge source based on the type. + * @property string $name The name of the tool. + * @property AssistantsV1ServiceCreatePolicyRequest $policy + * @property string $type The type of the knowledge source. + */ + protected $assistantId; + protected $description; + protected $knowledgeSourceDetails; + protected $name; + protected $policy; + protected $type; + public function __construct(array $payload = []) { + $this->assistantId = Values::array_get($payload, 'assistantId'); + $this->description = Values::array_get($payload, 'description'); + $this->knowledgeSourceDetails = Values::array_get($payload, 'knowledgeSourceDetails'); + $this->name = Values::array_get($payload, 'name'); + $this->policy = Values::array_get($payload, 'policy'); + $this->type = Values::array_get($payload, 'type'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'assistantId' => $this->assistantId, + 'description' => $this->description, + 'knowledgeSourceDetails' => $this->knowledgeSourceDetails, + 'name' => $this->name, + 'policy' => $this->policy, + 'type' => $this->type + ]; + } +} + +class AssistantsV1ServiceUpdateKnowledgeRequest implements \JsonSerializable +{ + /** + * @property string $description The description of the knowledge source. + * @property array $knowledgeSourceDetails The details of the knowledge source based on the type. + * @property string $name The name of the knowledge source. + * @property AssistantsV1ServiceCreatePolicyRequest $policy + * @property string $type The description of the knowledge source. + */ + protected $description; + protected $knowledgeSourceDetails; + protected $name; + protected $policy; + protected $type; + public function __construct(array $payload = []) { + $this->description = Values::array_get($payload, 'description'); + $this->knowledgeSourceDetails = Values::array_get($payload, 'knowledgeSourceDetails'); + $this->name = Values::array_get($payload, 'name'); + $this->policy = Values::array_get($payload, 'policy'); + $this->type = Values::array_get($payload, 'type'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'description' => $this->description, + 'knowledgeSourceDetails' => $this->knowledgeSourceDetails, + 'name' => $this->name, + 'policy' => $this->policy, + 'type' => $this->type + ]; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgeOptions.php b/src/Twilio/Rest/Assistants/V1/KnowledgeOptions.php new file mode 100644 index 000000000..744fb4420 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/KnowledgeOptions.php @@ -0,0 +1,82 @@ +options['assistantId'] = $assistantId; + } + + /** + * @param string $assistantId + * @return $this Fluent Builder + */ + public function setAssistantId(string $assistantId): self + { + $this->options['assistantId'] = $assistantId; + 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.Assistants.V1.ReadKnowledgeOptions ' . $options . ']'; + } +} + + diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgePage.php b/src/Twilio/Rest/Assistants/V1/KnowledgePage.php new file mode 100644 index 000000000..e413ea45d --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/KnowledgePage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return KnowledgeInstance \Twilio\Rest\Assistants\V1\KnowledgeInstance + */ + public function buildInstance(array $payload): KnowledgeInstance + { + return new KnowledgeInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.KnowledgePage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/PolicyInstance.php b/src/Twilio/Rest/Assistants/V1/PolicyInstance.php new file mode 100644 index 000000000..ae8996428 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/PolicyInstance.php @@ -0,0 +1,97 @@ +properties = [ + 'id' => Values::array_get($payload, 'id'), + 'name' => Values::array_get($payload, 'name'), + 'description' => Values::array_get($payload, 'description'), + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'userSid' => Values::array_get($payload, 'user_sid'), + 'type' => Values::array_get($payload, 'type'), + 'policyDetails' => Values::array_get($payload, 'policy_details'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $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.Assistants.V1.PolicyInstance]'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/PolicyList.php b/src/Twilio/Rest/Assistants/V1/PolicyList.php new file mode 100644 index 000000000..936dac35e --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/PolicyList.php @@ -0,0 +1,154 @@ +solution = [ + ]; + + $this->uri = '/Policies'; + } + + /** + * Reads PolicyInstance 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 PolicyInstance[] Array of results + */ + public function read(array $options = [], int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($options, $limit, $pageSize), false); + } + + /** + * Streams PolicyInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param array|Options $options Optional Arguments + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(array $options = [], int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($options, $limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of PolicyInstance 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 PolicyPage Page of PolicyInstance + */ + public function page( + array $options = [], + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): PolicyPage + { + $options = new Values($options); + + $params = Values::of([ + 'ToolId' => + $options['toolId'], + 'KnowledgeId' => + $options['knowledgeId'], + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new PolicyPage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of PolicyInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return PolicyPage Page of PolicyInstance + */ + public function getPage(string $targetUrl): PolicyPage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new PolicyPage($this->version, $response, $this->solution); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.PolicyList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/PolicyOptions.php b/src/Twilio/Rest/Assistants/V1/PolicyOptions.php new file mode 100644 index 000000000..a18c7affb --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/PolicyOptions.php @@ -0,0 +1,94 @@ +options['toolId'] = $toolId; + $this->options['knowledgeId'] = $knowledgeId; + } + + /** + * The tool ID. + * + * @param string $toolId The tool ID. + * @return $this Fluent Builder + */ + public function setToolId(string $toolId): self + { + $this->options['toolId'] = $toolId; + return $this; + } + + /** + * The knowledge ID. + * + * @param string $knowledgeId The knowledge ID. + * @return $this Fluent Builder + */ + public function setKnowledgeId(string $knowledgeId): self + { + $this->options['knowledgeId'] = $knowledgeId; + 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.Assistants.V1.ReadPolicyOptions ' . $options . ']'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/PolicyPage.php b/src/Twilio/Rest/Assistants/V1/PolicyPage.php new file mode 100644 index 000000000..e76600338 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/PolicyPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return PolicyInstance \Twilio\Rest\Assistants\V1\PolicyInstance + */ + public function buildInstance(array $payload): PolicyInstance + { + return new PolicyInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.PolicyPage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/Session/MessageInstance.php b/src/Twilio/Rest/Assistants/V1/Session/MessageInstance.php new file mode 100644 index 000000000..d30adbed3 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Session/MessageInstance.php @@ -0,0 +1,100 @@ +properties = [ + 'id' => Values::array_get($payload, 'id'), + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'assistantId' => Values::array_get($payload, 'assistant_id'), + 'sessionId' => Values::array_get($payload, 'session_id'), + 'identity' => Values::array_get($payload, 'identity'), + 'role' => Values::array_get($payload, 'role'), + 'content' => Values::array_get($payload, 'content'), + 'meta' => Values::array_get($payload, 'meta'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $this->solution = ['sessionId' => $sessionId, ]; + } + + /** + * 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.Assistants.V1.MessageInstance]'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/Session/MessageList.php b/src/Twilio/Rest/Assistants/V1/Session/MessageList.php new file mode 100644 index 000000000..96090fd40 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Session/MessageList.php @@ -0,0 +1,151 @@ +solution = [ + 'sessionId' => + $sessionId, + + ]; + + $this->uri = '/Sessions/' . \rawurlencode($sessionId) + .'/Messages'; + } + + /** + * 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 int $limit Upper limit for the number of records to return. read() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, read() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return MessageInstance[] Array of results + */ + public function read(int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($limit, $pageSize), false); + } + + /** + * Streams MessageInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of MessageInstance 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 MessagePage Page of MessageInstance + */ + public function page( + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): MessagePage + { + + $params = Values::of([ + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new MessagePage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of MessageInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return MessagePage Page of MessageInstance + */ + public function getPage(string $targetUrl): MessagePage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new MessagePage($this->version, $response, $this->solution); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.MessageList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/Session/MessagePage.php b/src/Twilio/Rest/Assistants/V1/Session/MessagePage.php new file mode 100644 index 000000000..dc996c75a --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/Session/MessagePage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return MessageInstance \Twilio\Rest\Assistants\V1\Session\MessageInstance + */ + public function buildInstance(array $payload): MessageInstance + { + return new MessageInstance($this->version, $payload, $this->solution['sessionId']); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.MessagePage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/SessionContext.php b/src/Twilio/Rest/Assistants/V1/SessionContext.php new file mode 100644 index 000000000..8c74b91d3 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/SessionContext.php @@ -0,0 +1,140 @@ +solution = [ + 'id' => + $id, + ]; + + $this->uri = '/Sessions/' . \rawurlencode($id) + .''; + } + + /** + * Fetch the SessionInstance + * + * @return SessionInstance Fetched SessionInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function fetch(): SessionInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $payload = $this->version->fetch('GET', $this->uri, [], [], $headers); + + return new SessionInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Access the messages + */ + protected function getMessages(): MessageList + { + if (!$this->_messages) { + $this->_messages = new MessageList( + $this->version, + $this->solution['id'] + ); + } + + return $this->_messages; + } + + /** + * Magic getter to lazy load subresources + * + * @param string $name Subresource to return + * @return ListResource The requested subresource + * @throws TwilioException For unknown subresources + */ + public function __get(string $name): ListResource + { + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown subresource ' . $name); + } + + /** + * Magic caller to get resource contexts + * + * @param string $name Resource to return + * @param array $arguments Context parameters + * @return InstanceContext The requested resource context + * @throws TwilioException For unknown resource + */ + public function __call(string $name, array $arguments): InstanceContext + { + $property = $this->$name; + if (\method_exists($property, 'getContext')) { + return \call_user_func_array(array($property, 'getContext'), $arguments); + } + + throw new TwilioException('Resource does not have a context'); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.SessionContext ' . \implode(' ', $context) . ']'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/SessionInstance.php b/src/Twilio/Rest/Assistants/V1/SessionInstance.php new file mode 100644 index 000000000..30ae4650d --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/SessionInstance.php @@ -0,0 +1,139 @@ +properties = [ + 'id' => Values::array_get($payload, 'id'), + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'assistantId' => Values::array_get($payload, 'assistant_id'), + 'verified' => Values::array_get($payload, 'verified'), + 'identity' => Values::array_get($payload, 'identity'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $this->solution = ['id' => $id ?: $this->properties['id'], ]; + } + + /** + * Generate an instance context for the instance, the context is capable of + * performing various actions. All instance actions are proxied to the context + * + * @return SessionContext Context for this SessionInstance + */ + protected function proxy(): SessionContext + { + if (!$this->context) { + $this->context = new SessionContext( + $this->version, + $this->solution['id'] + ); + } + + return $this->context; + } + + /** + * Fetch the SessionInstance + * + * @return SessionInstance Fetched SessionInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function fetch(): SessionInstance + { + + return $this->proxy()->fetch(); + } + + /** + * Access the messages + */ + protected function getMessages(): MessageList + { + return $this->proxy()->messages; + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.SessionInstance ' . \implode(' ', $context) . ']'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/SessionList.php b/src/Twilio/Rest/Assistants/V1/SessionList.php new file mode 100644 index 000000000..3f0da8a68 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/SessionList.php @@ -0,0 +1,161 @@ +solution = [ + ]; + + $this->uri = '/Sessions'; + } + + /** + * Reads SessionInstance 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 SessionInstance[] Array of results + */ + public function read(int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($limit, $pageSize), false); + } + + /** + * Streams SessionInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of SessionInstance 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 SessionPage Page of SessionInstance + */ + public function page( + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): SessionPage + { + + $params = Values::of([ + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new SessionPage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of SessionInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return SessionPage Page of SessionInstance + */ + public function getPage(string $targetUrl): SessionPage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new SessionPage($this->version, $response, $this->solution); + } + + + /** + * Constructs a SessionContext + * + * @param string $id + */ + public function getContext( + string $id + + ): SessionContext + { + return new SessionContext( + $this->version, + $id + ); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.SessionList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/SessionPage.php b/src/Twilio/Rest/Assistants/V1/SessionPage.php new file mode 100644 index 000000000..8e2f4ac34 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/SessionPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return SessionInstance \Twilio\Rest\Assistants\V1\SessionInstance + */ + public function buildInstance(array $payload): SessionInstance + { + return new SessionInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.SessionPage]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/ToolContext.php b/src/Twilio/Rest/Assistants/V1/ToolContext.php new file mode 100644 index 000000000..acb85593d --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/ToolContext.php @@ -0,0 +1,99 @@ +solution = [ + 'id' => + $id, + ]; + + $this->uri = '/Tools/' . \rawurlencode($id) + .''; + } + + /** + * Delete the ToolInstance + * + * @return bool True if delete succeeds, false otherwise + * @throws TwilioException When an HTTP error occurs. + */ + public function delete(): bool + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + return $this->version->delete('DELETE', $this->uri, [], [], $headers); + } + + + /** + * Update the ToolInstance + * + * @return ToolInstance Updated ToolInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): ToolInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceUpdateToolRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->update('PUT', $this->uri, [], $data, $headers); + + return new ToolInstance( + $this->version, + $payload, + $this->solution['id'] + ); + } + + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.ToolContext ' . \implode(' ', $context) . ']'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/ToolInstance.php b/src/Twilio/Rest/Assistants/V1/ToolInstance.php new file mode 100644 index 000000000..648411917 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/ToolInstance.php @@ -0,0 +1,146 @@ +properties = [ + 'accountSid' => Values::array_get($payload, 'account_sid'), + 'description' => Values::array_get($payload, 'description'), + 'enabled' => Values::array_get($payload, 'enabled'), + 'id' => Values::array_get($payload, 'id'), + 'meta' => Values::array_get($payload, 'meta'), + 'name' => Values::array_get($payload, 'name'), + 'requiresAuth' => Values::array_get($payload, 'requires_auth'), + 'type' => Values::array_get($payload, 'type'), + 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')), + 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')), + ]; + + $this->solution = ['id' => $id ?: $this->properties['id'], ]; + } + + /** + * Generate an instance context for the instance, the context is capable of + * performing various actions. All instance actions are proxied to the context + * + * @return ToolContext Context for this ToolInstance + */ + protected function proxy(): ToolContext + { + if (!$this->context) { + $this->context = new ToolContext( + $this->version, + $this->solution['id'] + ); + } + + return $this->context; + } + + /** + * Delete the ToolInstance + * + * @return bool True if delete succeeds, false otherwise + * @throws TwilioException When an HTTP error occurs. + */ + public function delete(): bool + { + + return $this->proxy()->delete(); + } + + /** + * Update the ToolInstance + * + * @return ToolInstance Updated ToolInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function update(): ToolInstance + { + + return $this->proxy()->update(); + } + + /** + * Magic getter to access properties + * + * @param string $name Property to access + * @return mixed The requested property + * @throws TwilioException For unknown properties + */ + public function __get(string $name) + { + if (\array_key_exists($name, $this->properties)) { + return $this->properties[$name]; + } + + if (\property_exists($this, '_' . $name)) { + $method = 'get' . \ucfirst($name); + return $this->$method(); + } + + throw new TwilioException('Unknown property: ' . $name); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + $context = []; + foreach ($this->solution as $key => $value) { + $context[] = "$key=$value"; + } + return '[Twilio.Assistants.V1.ToolInstance ' . \implode(' ', $context) . ']'; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/ToolList.php b/src/Twilio/Rest/Assistants/V1/ToolList.php new file mode 100644 index 000000000..2afce5c5e --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/ToolList.php @@ -0,0 +1,191 @@ +solution = [ + ]; + + $this->uri = '/Tools'; + } + + /** + * Create the ToolInstance + * + * @param AssistantsV1ServiceCreateToolRequest $assistantsV1ServiceCreateToolRequest + * @return ToolInstance Created ToolInstance + * @throws TwilioException When an HTTP error occurs. + */ + public function create(AssistantsV1ServiceCreateToolRequest $assistantsV1ServiceCreateToolRequest): ToolInstance + { + + $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); + $data = $assistantsV1ServiceCreateToolRequest->toArray(); + $headers['Content-Type'] = 'application/json'; + $payload = $this->version->create('POST', $this->uri, [], $data, $headers); + + return new ToolInstance( + $this->version, + $payload + ); + } + + + /** + * Reads ToolInstance 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 ToolInstance[] Array of results + */ + public function read(array $options = [], int $limit = null, $pageSize = null): array + { + return \iterator_to_array($this->stream($options, $limit, $pageSize), false); + } + + /** + * Streams ToolInstance records from the API as a generator stream. + * This operation lazily loads records as efficiently as possible until the + * limit + * is reached. + * The results are returned as a generator, so this operation is memory + * efficient. + * + * @param array|Options $options Optional Arguments + * @param int $limit Upper limit for the number of records to return. stream() + * guarantees to never return more than limit. Default is no + * limit + * @param mixed $pageSize Number of records to fetch per request, when not set + * will use the default value of 50 records. If no + * page_size is defined but a limit is defined, stream() + * will attempt to read the limit with the most + * efficient page size, i.e. min(limit, 1000) + * @return Stream stream of results + */ + public function stream(array $options = [], int $limit = null, $pageSize = null): Stream + { + $limits = $this->version->readLimits($limit, $pageSize); + + $page = $this->page($options, $limits['pageSize']); + + return $this->version->stream($page, $limits['limit'], $limits['pageLimit']); + } + + /** + * Retrieve a single page of ToolInstance 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 ToolPage Page of ToolInstance + */ + public function page( + array $options = [], + $pageSize = Values::NONE, + string $pageToken = Values::NONE, + $pageNumber = Values::NONE + ): ToolPage + { + $options = new Values($options); + + $params = Values::of([ + 'AssistantId' => + $options['assistantId'], + 'PageToken' => $pageToken, + 'Page' => $pageNumber, + 'PageSize' => $pageSize, + ]); + + $response = $this->version->page('GET', $this->uri, $params); + + return new ToolPage($this->version, $response, $this->solution); + } + + /** + * Retrieve a specific page of ToolInstance records from the API. + * Request is executed immediately + * + * @param string $targetUrl API-generated URL for the requested results page + * @return ToolPage Page of ToolInstance + */ + public function getPage(string $targetUrl): ToolPage + { + $response = $this->version->getDomain()->getClient()->request( + 'GET', + $targetUrl + ); + + return new ToolPage($this->version, $response, $this->solution); + } + + + /** + * Constructs a ToolContext + * + * @param string $id The tool ID. + */ + public function getContext( + string $id + + ): ToolContext + { + return new ToolContext( + $this->version, + $id + ); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.ToolList]'; + } +} diff --git a/src/Twilio/Rest/Assistants/V1/ToolModels.php b/src/Twilio/Rest/Assistants/V1/ToolModels.php new file mode 100644 index 000000000..3ea0bd056 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/ToolModels.php @@ -0,0 +1,195 @@ +description = Values::array_get($payload, 'description'); + $this->id = Values::array_get($payload, 'id'); + $this->name = Values::array_get($payload, 'name'); + $this->policyDetails = Values::array_get($payload, 'policyDetails'); + $this->type = Values::array_get($payload, 'type'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'description' => $this->description, + 'id' => $this->id, + 'name' => $this->name, + 'policyDetails' => $this->policyDetails, + 'type' => $this->type + ]; + } +} + +class AssistantsV1ServiceCreateToolRequest implements \JsonSerializable +{ + /** + * @property string $assistantId The Assistant ID. + * @property string $description The description of the tool. + * @property bool $enabled True if the tool is enabled. + * @property array $meta The metadata related to method, url, input_schema to used with the Tool. + * @property string $name The name of the tool. + * @property AssistantsV1ServiceCreatePolicyRequest $policy + * @property string $type The description of the tool. + */ + protected $assistantId; + protected $description; + protected $enabled; + protected $meta; + protected $name; + protected $policy; + protected $type; + public function __construct(array $payload = []) { + $this->assistantId = Values::array_get($payload, 'assistantId'); + $this->description = Values::array_get($payload, 'description'); + $this->enabled = Values::array_get($payload, 'enabled'); + $this->meta = Values::array_get($payload, 'meta'); + $this->name = Values::array_get($payload, 'name'); + $this->policy = Values::array_get($payload, 'policy'); + $this->type = Values::array_get($payload, 'type'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'assistantId' => $this->assistantId, + 'description' => $this->description, + 'enabled' => $this->enabled, + 'meta' => $this->meta, + 'name' => $this->name, + 'policy' => $this->policy, + 'type' => $this->type + ]; + } +} + +class AssistantsV1ServiceUpdateToolRequest implements \JsonSerializable +{ + /** + * @property string $assistantId The Assistant ID. + * @property string $description The description of the tool. + * @property bool $enabled True if the tool is enabled. + * @property array $meta The metadata related to method, url, input_schema to used with the Tool. + * @property string $name The name of the tool. + * @property AssistantsV1ServiceCreatePolicyRequest $policy + * @property string $type The type of the tool. + */ + protected $assistantId; + protected $description; + protected $enabled; + protected $meta; + protected $name; + protected $policy; + protected $type; + public function __construct(array $payload = []) { + $this->assistantId = Values::array_get($payload, 'assistantId'); + $this->description = Values::array_get($payload, 'description'); + $this->enabled = Values::array_get($payload, 'enabled'); + $this->meta = Values::array_get($payload, 'meta'); + $this->name = Values::array_get($payload, 'name'); + $this->policy = Values::array_get($payload, 'policy'); + $this->type = Values::array_get($payload, 'type'); + } + + public function toArray(): array + { + return $this->jsonSerialize(); + } + + public function jsonSerialize(): array + { + return [ + 'assistantId' => $this->assistantId, + 'description' => $this->description, + 'enabled' => $this->enabled, + 'meta' => $this->meta, + 'name' => $this->name, + 'policy' => $this->policy, + 'type' => $this->type + ]; + } +} + diff --git a/src/Twilio/Rest/Assistants/V1/ToolOptions.php b/src/Twilio/Rest/Assistants/V1/ToolOptions.php new file mode 100644 index 000000000..090cc7a90 --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/ToolOptions.php @@ -0,0 +1,80 @@ +options['assistantId'] = $assistantId; + } + + /** + * @param string $assistantId + * @return $this Fluent Builder + */ + public function setAssistantId(string $assistantId): self + { + $this->options['assistantId'] = $assistantId; + 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.Assistants.V1.ReadToolOptions ' . $options . ']'; + } +} + + diff --git a/src/Twilio/Rest/Assistants/V1/ToolPage.php b/src/Twilio/Rest/Assistants/V1/ToolPage.php new file mode 100644 index 000000000..7fa52006d --- /dev/null +++ b/src/Twilio/Rest/Assistants/V1/ToolPage.php @@ -0,0 +1,55 @@ +solution = $solution; + } + + /** + * @param array $payload Payload response from the API + * @return ToolInstance \Twilio\Rest\Assistants\V1\ToolInstance + */ + public function buildInstance(array $payload): ToolInstance + { + return new ToolInstance($this->version, $payload); + } + + /** + * Provide a friendly representation + * + * @return string Machine friendly representation + */ + public function __toString(): string + { + return '[Twilio.Assistants.V1.ToolPage]'; + } +} diff --git a/src/Twilio/Rest/AssistantsBase.php b/src/Twilio/Rest/AssistantsBase.php new file mode 100644 index 000000000..f634e6d9f --- /dev/null +++ b/src/Twilio/Rest/AssistantsBase.php @@ -0,0 +1,88 @@ +baseUrl = 'https://assistants.twilio.com'; + } + + + /** + * @return V1 Version v1 of assistants + */ + 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.Assistants]'; + } +} diff --git a/src/Twilio/Rest/Client.php b/src/Twilio/Rest/Client.php index df762eedc..cf187f6b1 100644 --- a/src/Twilio/Rest/Client.php +++ b/src/Twilio/Rest/Client.php @@ -20,6 +20,7 @@ * * @property Accounts $accounts * @property Api $api + * @property Assistants $assistants * @property Bulkexports $bulkexports * @property Chat $chat * @property Content $content @@ -100,6 +101,7 @@ class Client extends BaseClient { protected $_accounts; protected $_api; + protected $_assistants; protected $_bulkexports; protected $_chat; protected $_content; @@ -157,6 +159,17 @@ protected function getApi(): Api { } return $this->_api; } + /** + * Access the Assistants Twilio Domain + * + * @return Assistants Assistants Twilio Domain + */ + protected function getAssistants(): Assistants { + if (!$this->_assistants) { + $this->_assistants = new Assistants($this); + } + return $this->_assistants; + } /** * Access the Bulkexports Twilio Domain * diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php index b8828ba4e..1ff708ecd 100644 --- a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php +++ b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchContext.php @@ -29,21 +29,21 @@ class ApprovalFetchContext extends InstanceContext * Initialize the ApprovalFetchContext * * @param Version $version Version that contains the resource - * @param string $contentSid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + * @param string $sid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. */ public function __construct( Version $version, - $contentSid + $sid ) { parent::__construct($version); // Path Solution $this->solution = [ - 'contentSid' => - $contentSid, + 'sid' => + $sid, ]; - $this->uri = '/Content/' . \rawurlencode($contentSid) + $this->uri = '/Content/' . \rawurlencode($sid) .'/ApprovalRequests'; } @@ -62,7 +62,7 @@ public function fetch(): ApprovalFetchInstance return new ApprovalFetchInstance( $this->version, $payload, - $this->solution['contentSid'] + $this->solution['sid'] ); } diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchInstance.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchInstance.php index 44a96fa28..ee3d34d36 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 $contentSid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + * @param string $sid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. */ - public function __construct(Version $version, array $payload, string $contentSid) + public function __construct(Version $version, array $payload, string $sid) { parent::__construct($version); @@ -50,7 +50,7 @@ public function __construct(Version $version, array $payload, string $contentSid 'url' => Values::array_get($payload, 'url'), ]; - $this->solution = ['contentSid' => $contentSid, ]; + $this->solution = ['sid' => $sid, ]; } /** @@ -64,7 +64,7 @@ protected function proxy(): ApprovalFetchContext if (!$this->context) { $this->context = new ApprovalFetchContext( $this->version, - $this->solution['contentSid'] + $this->solution['sid'] ); } diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchList.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchList.php index 35301ef37..9bb948a71 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 $contentSid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + * @param string $sid The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. */ public function __construct( Version $version, - string $contentSid + string $sid ) { parent::__construct($version); // Path Solution $this->solution = [ - 'contentSid' => - $contentSid, + 'sid' => + $sid, ]; } @@ -51,7 +51,7 @@ public function getContext( { return new ApprovalFetchContext( $this->version, - $this->solution['contentSid'] + $this->solution['sid'] ); } diff --git a/src/Twilio/Rest/Content/V1/Content/ApprovalFetchPage.php b/src/Twilio/Rest/Content/V1/Content/ApprovalFetchPage.php index 1bc0791e7..b205cd385 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['contentSid']); + return new ApprovalFetchInstance($this->version, $payload, $this->solution['sid']); } /** diff --git a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageInstance.php b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageInstance.php index 2f27ba084..78341cf75 100644 --- a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageInstance.php +++ b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageInstance.php @@ -24,8 +24,8 @@ /** - * @property string[] $billableItems * @property string $totalSubmitted + * @property string[] $billableItems */ class InstalledAddOnUsageInstance extends InstanceResource { @@ -34,7 +34,7 @@ class InstalledAddOnUsageInstance extends InstanceResource * * @param Version $version Version that contains the resource * @param mixed[] $payload The response payload - * @param string $installedAddOnSid + * @param string $installedAddOnSid Customer Installation SID to report usage on. */ public function __construct(Version $version, array $payload, string $installedAddOnSid) { @@ -42,8 +42,8 @@ public function __construct(Version $version, array $payload, string $installedA // Marshaled Properties $this->properties = [ - 'billableItems' => Values::array_get($payload, 'billable_items'), 'totalSubmitted' => Values::array_get($payload, 'total_submitted'), + 'billableItems' => Values::array_get($payload, 'billable_items'), ]; $this->solution = ['installedAddOnSid' => $installedAddOnSid, ]; diff --git a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageList.php b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageList.php index c2588dcb7..b61c4551b 100644 --- a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageList.php +++ b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageList.php @@ -28,7 +28,7 @@ class InstalledAddOnUsageList extends ListResource * Construct the InstalledAddOnUsageList * * @param Version $version Version that contains the resource - * @param string $installedAddOnSid + * @param string $installedAddOnSid Customer Installation SID to report usage on. */ public function __construct( Version $version, diff --git a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php index 55f435d77..42e302eb3 100644 --- a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php +++ b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php @@ -19,8 +19,9 @@ abstract class InstalledAddOnUsageModels { /** - * @property string $quantity Any floating number greater than 0. + * @property string $quantity Total amount in local currency that was billed for this Billing Item. Can be any floating number greater than 0. * @property string $sid BillingSid to use for billing. + * @property bool $submitted Whether the billing event was successfully generated for this Billable Item. */ public static function createMarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems(array $payload = []): MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems { @@ -28,7 +29,8 @@ public static function createMarketplaceV1InstalledAddOnInstalledAddOnUsageBilla } /** - * @property MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems[] $billableItems + * @property string $totalSubmitted Total amount in local currency that was billed in this request. Aggregates all billable_items that were successfully submitted. + * @property string[] $billableItems */ public static function createMarketplaceV1InstalledAddOnInstalledAddOnUsage(array $payload = []): MarketplaceV1InstalledAddOnInstalledAddOnUsage { @@ -40,14 +42,17 @@ public static function createMarketplaceV1InstalledAddOnInstalledAddOnUsage(arra class MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems implements \JsonSerializable { /** - * @property string $quantity Any floating number greater than 0. + * @property string $quantity Total amount in local currency that was billed for this Billing Item. Can be any floating number greater than 0. * @property string $sid BillingSid to use for billing. + * @property bool $submitted Whether the billing event was successfully generated for this Billable Item. */ protected $quantity; protected $sid; + protected $submitted; public function __construct(array $payload = []) { $this->quantity = Values::array_get($payload, 'quantity'); $this->sid = Values::array_get($payload, 'sid'); + $this->submitted = Values::array_get($payload, 'submitted'); } public function toArray(): array @@ -59,7 +64,8 @@ public function jsonSerialize(): array { return [ 'quantity' => $this->quantity, - 'sid' => $this->sid + 'sid' => $this->sid, + 'submitted' => $this->submitted ]; } } @@ -67,10 +73,13 @@ public function jsonSerialize(): array class MarketplaceV1InstalledAddOnInstalledAddOnUsage implements \JsonSerializable { /** - * @property MarketplaceV1InstalledAddOnInstalledAddOnUsageBillableItems[] $billableItems + * @property string $totalSubmitted Total amount in local currency that was billed in this request. Aggregates all billable_items that were successfully submitted. + * @property string[] $billableItems */ + protected $totalSubmitted; protected $billableItems; public function __construct(array $payload = []) { + $this->totalSubmitted = Values::array_get($payload, 'totalSubmitted'); $this->billableItems = Values::array_get($payload, 'billableItems'); } @@ -82,6 +91,7 @@ public function toArray(): array public function jsonSerialize(): array { return [ + 'totalSubmitted' => $this->totalSubmitted, 'billableItems' => $this->billableItems ]; } diff --git a/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementContext.php b/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementContext.php index a72be09c5..0d956b561 100644 --- a/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementContext.php +++ b/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementContext.php @@ -93,6 +93,8 @@ public function update(array $options = []): ModuleDataManagementInstance $options['support'], 'Configuration' => $options['configuration'], + 'Pricing' => + $options['pricing'], ]); $headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded' ]); diff --git a/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementInstance.php b/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementInstance.php index 88610fb37..de9d02ebb 100644 --- a/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementInstance.php +++ b/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementInstance.php @@ -33,6 +33,7 @@ * @property array|null $moduleInfo * @property array|null $documentation * @property array|null $configuration + * @property array|null $pricing */ class ModuleDataManagementInstance extends InstanceResource { @@ -57,6 +58,7 @@ public function __construct(Version $version, array $payload, string $sid = null 'moduleInfo' => Values::array_get($payload, 'module_info'), 'documentation' => Values::array_get($payload, 'documentation'), 'configuration' => Values::array_get($payload, 'configuration'), + 'pricing' => Values::array_get($payload, 'pricing'), ]; $this->solution = ['sid' => $sid ?: $this->properties['sid'], ]; diff --git a/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementOptions.php b/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementOptions.php index 6c9a276ca..946c13635 100644 --- a/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementOptions.php +++ b/src/Twilio/Rest/Marketplace/V1/ModuleDataManagementOptions.php @@ -22,12 +22,13 @@ abstract class ModuleDataManagementOptions { /** - * @param string $moduleInfo - * @param string $description - * @param string $documentation - * @param string $policies - * @param string $support - * @param string $configuration + * @param string $moduleInfo A JSON object containing essential attributes that define a Listing. + * @param string $description A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + * @param string $documentation A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + * @param string $policies A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + * @param string $support A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + * @param string $configuration A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + * @param string $pricing A JSON object for providing Listing's purchase options. * @return UpdateModuleDataManagementOptions Options builder */ public static function update( @@ -37,7 +38,8 @@ public static function update( string $documentation = Values::NONE, string $policies = Values::NONE, string $support = Values::NONE, - string $configuration = Values::NONE + string $configuration = Values::NONE, + string $pricing = Values::NONE ): UpdateModuleDataManagementOptions { @@ -47,7 +49,8 @@ public static function update( $documentation, $policies, $support, - $configuration + $configuration, + $pricing ); } @@ -57,12 +60,13 @@ public static function update( class UpdateModuleDataManagementOptions extends Options { /** - * @param string $moduleInfo - * @param string $description - * @param string $documentation - * @param string $policies - * @param string $support - * @param string $configuration + * @param string $moduleInfo A JSON object containing essential attributes that define a Listing. + * @param string $description A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. + * @param string $documentation A JSON object for providing comprehensive information, instructions, and resources related to the Listing. + * @param string $policies A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. + * @param string $support A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. + * @param string $configuration A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. + * @param string $pricing A JSON object for providing Listing's purchase options. */ public function __construct( @@ -71,7 +75,8 @@ public function __construct( string $documentation = Values::NONE, string $policies = Values::NONE, string $support = Values::NONE, - string $configuration = Values::NONE + string $configuration = Values::NONE, + string $pricing = Values::NONE ) { $this->options['moduleInfo'] = $moduleInfo; @@ -80,12 +85,13 @@ public function __construct( $this->options['policies'] = $policies; $this->options['support'] = $support; $this->options['configuration'] = $configuration; + $this->options['pricing'] = $pricing; } /** - * + * A JSON object containing essential attributes that define a Listing. * - * @param string $moduleInfo + * @param string $moduleInfo A JSON object containing essential attributes that define a Listing. * @return $this Fluent Builder */ public function setModuleInfo(string $moduleInfo): self @@ -95,9 +101,9 @@ public function setModuleInfo(string $moduleInfo): self } /** - * + * A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. * - * @param string $description + * @param string $description A JSON object describing the Listing. You can define the main body of the description, highlight key features or aspects of the Listing, and provide code samples for developers if applicable. * @return $this Fluent Builder */ public function setDescription(string $description): self @@ -107,9 +113,9 @@ public function setDescription(string $description): self } /** - * + * A JSON object for providing comprehensive information, instructions, and resources related to the Listing. * - * @param string $documentation + * @param string $documentation A JSON object for providing comprehensive information, instructions, and resources related to the Listing. * @return $this Fluent Builder */ public function setDocumentation(string $documentation): self @@ -119,9 +125,9 @@ public function setDocumentation(string $documentation): self } /** - * + * A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. * - * @param string $policies + * @param string $policies A JSON object describing the Listing's privacy and legal policies. The maximum file size for Policies is 5MB. * @return $this Fluent Builder */ public function setPolicies(string $policies): self @@ -131,9 +137,9 @@ public function setPolicies(string $policies): self } /** - * + * A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. * - * @param string $support + * @param string $support A JSON object containing information on how Marketplace users can obtain support for the Listing. Use this parameter to provide details such as contact information and support description. * @return $this Fluent Builder */ public function setSupport(string $support): self @@ -143,9 +149,9 @@ public function setSupport(string $support): self } /** - * + * A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. * - * @param string $configuration + * @param string $configuration A JSON object for providing Listing-specific configuration. Contains button setup, notification URL, and more. * @return $this Fluent Builder */ public function setConfiguration(string $configuration): self @@ -154,6 +160,18 @@ public function setConfiguration(string $configuration): self return $this; } + /** + * A JSON object for providing Listing's purchase options. + * + * @param string $pricing A JSON object for providing Listing's purchase options. + * @return $this Fluent Builder + */ + public function setPricing(string $pricing): self + { + $this->options['pricing'] = $pricing; + return $this; + } + /** * Provide a friendly representation * diff --git a/src/Twilio/Rest/Numbers/V2/BundleCloneOptions.php b/src/Twilio/Rest/Numbers/V2/BundleCloneOptions.php index 04eec37c2..31b0cf9df 100644 --- a/src/Twilio/Rest/Numbers/V2/BundleCloneOptions.php +++ b/src/Twilio/Rest/Numbers/V2/BundleCloneOptions.php @@ -21,7 +21,7 @@ abstract class BundleCloneOptions { /** - * @param bool $moveToDraft This is to determine whether the cloned bundle needs to be in draft state or not. + * @param bool $moveToDraft If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved * @param string $friendlyName The string that you assigned to describe the cloned bundle. * @return CreateBundleCloneOptions Options builder */ @@ -43,7 +43,7 @@ public static function create( class CreateBundleCloneOptions extends Options { /** - * @param bool $moveToDraft This is to determine whether the cloned bundle needs to be in draft state or not. + * @param bool $moveToDraft If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved * @param string $friendlyName The string that you assigned to describe the cloned bundle. */ public function __construct( @@ -57,9 +57,9 @@ public function __construct( } /** - * This is to determine whether the cloned bundle needs to be in draft state or not. + * If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved * - * @param bool $moveToDraft This is to determine whether the cloned bundle needs to be in draft state or not. + * @param bool $moveToDraft If set to true, the cloned bundle will be in the DRAFT state, else it will be twilio-approved * @return $this Fluent Builder */ public function setMoveToDraft(bool $moveToDraft): self diff --git a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.php b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.php index 2a5385cb5..da20b87f3 100644 --- a/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.php +++ b/src/Twilio/Rest/Numbers/V2/RegulatoryCompliance/BundleOptions.php @@ -25,7 +25,7 @@ abstract class BundleOptions * @param string $regulationSid The unique string of a regulation that is associated to the Bundle resource. * @param string $isoCountry The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. * @param string $endUserType - * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * @param bool $isTest Indicates that Bundle is a Test Bundle and will be Auto-Rejected * @return CreateBundleOptions Options builder */ @@ -57,7 +57,7 @@ public static function create( * @param string $friendlyName The string that you assigned to describe the resource. The column can contain 255 variable characters. * @param string $regulationSid The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. * @param string $isoCountry The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * @param bool $hasValidUntilDate Indicates that the Bundle is a valid Bundle until a specified expiration date. * @param string $sortBy Can be `valid-until` or `date-updated`. Defaults to `date-created`. * @param string $sortDirection Default is `DESC`. Can be `ASC` or `DESC`. @@ -130,7 +130,7 @@ class CreateBundleOptions extends Options * @param string $regulationSid The unique string of a regulation that is associated to the Bundle resource. * @param string $isoCountry The [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. * @param string $endUserType - * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * @param bool $isTest Indicates that Bundle is a Test Bundle and will be Auto-Rejected */ public function __construct( @@ -198,9 +198,9 @@ public function setEndUserType(string $endUserType): self } /** - * The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + * The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * - * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll free`. + * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * @return $this Fluent Builder */ public function setNumberType(string $numberType): self @@ -242,7 +242,7 @@ class ReadBundleOptions extends Options * @param string $friendlyName The string that you assigned to describe the resource. The column can contain 255 variable characters. * @param string $regulationSid The unique string of a [Regulation resource](https://www.twilio.com/docs/phone-numbers/regulatory/api/regulations) that is associated to the Bundle resource. * @param string $isoCountry The 2-digit [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the Bundle's phone number country ownership request. - * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * @param bool $hasValidUntilDate Indicates that the Bundle is a valid Bundle until a specified expiration date. * @param string $sortBy Can be `valid-until` or `date-updated`. Defaults to `date-created`. * @param string $sortDirection Default is `DESC`. Can be `ASC` or `DESC`. @@ -327,9 +327,9 @@ public function setIsoCountry(string $isoCountry): self } /** - * The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + * The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * - * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `tollfree`. + * @param string $numberType The type of phone number of the Bundle's ownership request. Can be `local`, `mobile`, `national`, or `toll-free`. * @return $this Fluent Builder */ public function setNumberType(string $numberType): self