From 87040016b76575d1b0303891825ad84ed8a4e013 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Fri, 10 Jan 2025 13:59:52 +0530 Subject: [PATCH] chore: fix model names in json serialize and payload --- example/message.php | 34 ++++----- .../V1/Assistant/FeedbackModels.php | 4 +- .../Assistants/V1/Assistant/MessageModels.php | 2 +- .../Rest/Assistants/V1/AssistantModels.php | 22 +++--- .../Rest/Assistants/V1/KnowledgeModels.php | 12 ++-- src/Twilio/Rest/Assistants/V1/ToolModels.php | 6 +- src/Twilio/Rest/Content/V1/ContentModels.php | 70 +++++++++---------- .../InstalledAddOnUsageModels.php | 4 +- .../V1/ReferralConversionModels.php | 2 +- 9 files changed, 75 insertions(+), 81 deletions(-) diff --git a/example/message.php b/example/message.php index 0c0cdbf702..2a85d7cf18 100644 --- a/example/message.php +++ b/example/message.php @@ -2,30 +2,24 @@ require(__DIR__.'/../src/Twilio/autoload.php'); use Twilio\Rest\Client; +use \Twilio\Rest\Content\V1\ContentModels; $sid = getenv('TWILIO_ACCOUNT_SID'); $token = getenv('TWILIO_AUTH_TOKEN'); -$client = new Client($sid, $token); +$twilio = new Client($sid, $token); -// Specify the phone numbers in [E.164 format](https://www.twilio.com/docs/glossary/what-e164) (e.g., +16175551212) -// This parameter determines the destination phone number for your SMS message. Format this number with a '+' and a country code -$phoneNumber = "+XXXXXXXXXX"; - -// This must be a Twilio phone number that you own, formatted with a '+' and country code -$twilioPurchasedNumber = "+XXXXXXXXXX"; - -// Send a text message -$message = $client->messages->create( - $phoneNumber, - [ - 'from' => $twilioPurchasedNumber, - 'body' => "Hey Jenny! Good luck on the bar exam!" +$contentCreateRequest = ContentModels::createContentCreateRequest([ + 'friendly_name' => 'my_template_friendly_name', + 'language' => 'en', + 'types' => [ + 'twilio/text' => [ + 'body' => 'this is a example body', + ], ] +]); + +$contentInstance = $twilio->content->v1->contents->create( + $contentCreateRequest ); -print("Message sent successfully with sid = " . $message->sid ."\n\n"); -// Print the last 10 messages -$messageList = $client->messages->read([],10); -foreach ($messageList as $msg) { - print("ID:: ". $msg->sid . " | " . "From:: " . $msg->from . " | " . "TO:: " . $msg->to . " | " . " Status:: " . $msg->status . " | " . " Body:: ". $msg->body ."\n"); -} \ No newline at end of file +print($contentInstance->sid); diff --git a/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php index 75afd229de..0cef875989 100644 --- a/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php +++ b/src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php @@ -58,9 +58,9 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'messageId' => $this->messageId, + 'message_id' => $this->messageId, 'score' => $this->score, - 'sessionId' => $this->sessionId, + 'session_id' => $this->sessionId, 'text' => $this->text ]; } diff --git a/src/Twilio/Rest/Assistants/V1/Assistant/MessageModels.php b/src/Twilio/Rest/Assistants/V1/Assistant/MessageModels.php index bfcffdb69b..06e040d67e 100644 --- a/src/Twilio/Rest/Assistants/V1/Assistant/MessageModels.php +++ b/src/Twilio/Rest/Assistants/V1/Assistant/MessageModels.php @@ -63,7 +63,7 @@ public function jsonSerialize(): array { return [ 'identity' => $this->identity, - 'sessionId' => $this->sessionId, + 'session_id' => $this->sessionId, 'body' => $this->body, 'webhook' => $this->webhook, 'mode' => $this->mode diff --git a/src/Twilio/Rest/Assistants/V1/AssistantModels.php b/src/Twilio/Rest/Assistants/V1/AssistantModels.php index 40e34b0344..c562988c1e 100644 --- a/src/Twilio/Rest/Assistants/V1/AssistantModels.php +++ b/src/Twilio/Rest/Assistants/V1/AssistantModels.php @@ -84,8 +84,8 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'perceptionEngineEnabled' => $this->perceptionEngineEnabled, - 'personalizationEngineEnabled' => $this->personalizationEngineEnabled + 'perception_engine_enabled' => $this->perceptionEngineEnabled, + 'personalization_engine_enabled' => $this->personalizationEngineEnabled ]; } } @@ -114,9 +114,9 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'profileApiKey' => $this->profileApiKey, - 'spaceId' => $this->spaceId, - 'writeKey' => $this->writeKey + 'profile_api_key' => $this->profileApiKey, + 'space_id' => $this->spaceId, + 'write_key' => $this->writeKey ]; } } @@ -151,11 +151,11 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'customerAi' => $this->customerAi, + 'customer_ai' => $this->customerAi, 'name' => $this->name, 'owner' => $this->owner, - 'personalityPrompt' => $this->personalityPrompt, - 'segmentCredential' => $this->segmentCredential + 'personality_prompt' => $this->personalityPrompt, + 'segment_credential' => $this->segmentCredential ]; } } @@ -190,11 +190,11 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'customerAi' => $this->customerAi, + 'customer_ai' => $this->customerAi, 'name' => $this->name, 'owner' => $this->owner, - 'personalityPrompt' => $this->personalityPrompt, - 'segmentCredential' => $this->segmentCredential + 'personality_prompt' => $this->personalityPrompt, + 'segment_credential' => $this->segmentCredential ]; } } diff --git a/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php b/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php index a15958c553..e4ec4e2cba 100644 --- a/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php +++ b/src/Twilio/Rest/Assistants/V1/KnowledgeModels.php @@ -92,7 +92,7 @@ public function jsonSerialize(): array 'description' => $this->description, 'id' => $this->id, 'name' => $this->name, - 'policyDetails' => $this->policyDetails, + 'policy_details' => $this->policyDetails, 'type' => $this->type ]; } @@ -134,13 +134,13 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'assistantId' => $this->assistantId, + 'assistant_id' => $this->assistantId, 'description' => $this->description, - 'knowledgeSourceDetails' => $this->knowledgeSourceDetails, + 'knowledge_source_details' => $this->knowledgeSourceDetails, 'name' => $this->name, 'policy' => $this->policy, 'type' => $this->type, - 'embeddingModel' => $this->embeddingModel + 'embedding_model' => $this->embeddingModel ]; } } @@ -179,11 +179,11 @@ public function jsonSerialize(): array { return [ 'description' => $this->description, - 'knowledgeSourceDetails' => $this->knowledgeSourceDetails, + 'knowledge_source_details' => $this->knowledgeSourceDetails, 'name' => $this->name, 'policy' => $this->policy, 'type' => $this->type, - 'embeddingModel' => $this->embeddingModel + 'embedding_model' => $this->embeddingModel ]; } } diff --git a/src/Twilio/Rest/Assistants/V1/ToolModels.php b/src/Twilio/Rest/Assistants/V1/ToolModels.php index 7fb3e1aba4..58e27f2277 100644 --- a/src/Twilio/Rest/Assistants/V1/ToolModels.php +++ b/src/Twilio/Rest/Assistants/V1/ToolModels.php @@ -93,7 +93,7 @@ public function jsonSerialize(): array 'description' => $this->description, 'id' => $this->id, 'name' => $this->name, - 'policyDetails' => $this->policyDetails, + 'policy_details' => $this->policyDetails, 'type' => $this->type ]; } @@ -135,7 +135,7 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'assistantId' => $this->assistantId, + 'assistant_id' => $this->assistantId, 'description' => $this->description, 'enabled' => $this->enabled, 'meta' => $this->meta, @@ -182,7 +182,7 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'assistantId' => $this->assistantId, + 'assistant_id' => $this->assistantId, 'description' => $this->description, 'enabled' => $this->enabled, 'meta' => $this->meta, diff --git a/src/Twilio/Rest/Content/V1/ContentModels.php b/src/Twilio/Rest/Content/V1/ContentModels.php index 5801df2d52..31994ba6b4 100644 --- a/src/Twilio/Rest/Content/V1/ContentModels.php +++ b/src/Twilio/Rest/Content/V1/ContentModels.php @@ -663,9 +663,9 @@ public function jsonSerialize(): array { return [ 'id' => $this->id, - 'sectionTitle' => $this->sectionTitle, + 'section_title' => $this->sectionTitle, 'name' => $this->name, - 'mediaUrl' => $this->mediaUrl, + 'media_url' => $this->mediaUrl, 'price' => $this->price, 'description' => $this->description ]; @@ -710,7 +710,7 @@ public function jsonSerialize(): array 'subtitle' => $this->subtitle, 'id' => $this->id, 'items' => $this->items, - 'dynamicItems' => $this->dynamicItems + 'dynamic_items' => $this->dynamicItems ]; } } @@ -874,7 +874,7 @@ public function jsonSerialize(): array { return [ 'id' => $this->id, - 'nextPageId' => $this->nextPageId, + 'next_page_id' => $this->nextPageId, 'title' => $this->title, 'subtitle' => $this->subtitle, 'layout' => $this->layout @@ -916,9 +916,9 @@ public function jsonSerialize(): array { return [ 'body' => $this->body, - 'buttonText' => $this->buttonText, + 'button_text' => $this->buttonText, 'subtitle' => $this->subtitle, - 'mediaUrl' => $this->mediaUrl, + 'media_url' => $this->mediaUrl, 'pages' => $this->pages, 'type' => $this->type ]; @@ -958,7 +958,7 @@ public function jsonSerialize(): array 'body' => $this->body, 'footer' => $this->footer, 'media' => $this->media, - 'headerText' => $this->headerText, + 'header_text' => $this->headerText, 'actions' => $this->actions ]; } @@ -986,7 +986,7 @@ public function jsonSerialize(): array { return [ 'type' => $this->type, - 'copyCodeText' => $this->copyCodeText + 'copy_code_text' => $this->copyCodeText ]; } } @@ -1015,8 +1015,8 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'addSecurityRecommendation' => $this->addSecurityRecommendation, - 'codeExpirationMinutes' => $this->codeExpirationMinutes, + 'add_security_recommendation' => $this->addSecurityRecommendation, + 'code_expiration_minutes' => $this->codeExpirationMinutes, 'actions' => $this->actions ]; } @@ -1051,18 +1051,18 @@ class Types implements \JsonSerializable protected $whatsappCard; protected $whatsappAuthentication; public function __construct(array $payload = []) { - $this->twilioText = Values::array_get($payload, 'twilio_text'); - $this->twilioMedia = Values::array_get($payload, 'twilio_media'); - $this->twilioLocation = Values::array_get($payload, 'twilio_location'); - $this->twilioListPicker = Values::array_get($payload, 'twilio_list_picker'); - $this->twilioCallToAction = Values::array_get($payload, 'twilio_call_to_action'); - $this->twilioQuickReply = Values::array_get($payload, 'twilio_quick_reply'); - $this->twilioCard = Values::array_get($payload, 'twilio_card'); - $this->twilioCatalog = Values::array_get($payload, 'twilio_catalog'); - $this->twilioCarousel = Values::array_get($payload, 'twilio_carousel'); - $this->twilioFlows = Values::array_get($payload, 'twilio_flows'); - $this->whatsappCard = Values::array_get($payload, 'whatsapp_card'); - $this->whatsappAuthentication = Values::array_get($payload, 'whatsapp_authentication'); + $this->twilioText = Values::array_get($payload, 'twilio/text'); + $this->twilioMedia = Values::array_get($payload, 'twilio/media'); + $this->twilioLocation = Values::array_get($payload, 'twilio/location'); + $this->twilioListPicker = Values::array_get($payload, 'twilio/list-picker'); + $this->twilioCallToAction = Values::array_get($payload, 'twilio/call-to-action'); + $this->twilioQuickReply = Values::array_get($payload, 'twilio/quick-reply'); + $this->twilioCard = Values::array_get($payload, 'twilio/card'); + $this->twilioCatalog = Values::array_get($payload, 'twilio/catalog'); + $this->twilioCarousel = Values::array_get($payload, 'twilio/carousel'); + $this->twilioFlows = Values::array_get($payload, 'twilio/flows'); + $this->whatsappCard = Values::array_get($payload, 'whatsapp/card'); + $this->whatsappAuthentication = Values::array_get($payload, 'whatsapp/authentication'); } public function toArray(): array @@ -1073,18 +1073,18 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'twilioText' => $this->twilioText, - 'twilioMedia' => $this->twilioMedia, - 'twilioLocation' => $this->twilioLocation, - 'twilioListPicker' => $this->twilioListPicker, - 'twilioCallToAction' => $this->twilioCallToAction, - 'twilioQuickReply' => $this->twilioQuickReply, - 'twilioCard' => $this->twilioCard, - 'twilioCatalog' => $this->twilioCatalog, - 'twilioCarousel' => $this->twilioCarousel, - 'twilioFlows' => $this->twilioFlows, - 'whatsappCard' => $this->whatsappCard, - 'whatsappAuthentication' => $this->whatsappAuthentication + 'twilio/text' => $this->twilioText, + 'twilio/media' => $this->twilioMedia, + 'twilio/location' => $this->twilioLocation, + 'twilio/list-picker' => $this->twilioListPicker, + 'twilio/call-to-action' => $this->twilioCallToAction, + 'twilio/quick-reply' => $this->twilioQuickReply, + 'twilio/card' => $this->twilioCard, + 'twilio/catalog' => $this->twilioCatalog, + 'twilio/carousel' => $this->twilioCarousel, + 'twilio/flows' => $this->twilioFlows, + 'whatsapp/card' => $this->whatsappCard, + 'whatsapp/authentication' => $this->whatsappAuthentication ]; } } @@ -1116,7 +1116,7 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'friendlyName' => $this->friendlyName, + 'friendly_name' => $this->friendlyName, 'variables' => $this->variables, 'language' => $this->language, 'types' => $this->types diff --git a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php index 7209a53139..fdb026ad1b 100644 --- a/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php +++ b/src/Twilio/Rest/Marketplace/V1/InstalledAddOn/InstalledAddOnUsageModels.php @@ -91,8 +91,8 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'totalSubmitted' => $this->totalSubmitted, - 'billableItems' => $this->billableItems + 'total_submitted' => $this->totalSubmitted, + 'billable_items' => $this->billableItems ]; } } diff --git a/src/Twilio/Rest/Marketplace/V1/ReferralConversionModels.php b/src/Twilio/Rest/Marketplace/V1/ReferralConversionModels.php index 73cdda0120..cabac010c8 100644 --- a/src/Twilio/Rest/Marketplace/V1/ReferralConversionModels.php +++ b/src/Twilio/Rest/Marketplace/V1/ReferralConversionModels.php @@ -46,7 +46,7 @@ public function toArray(): array public function jsonSerialize(): array { return [ - 'referralAccountSid' => $this->referralAccountSid + 'referral_account_sid' => $this->referralAccountSid ]; } }