Skip to content

Commit

Permalink
chore: fix model names in json serialize and payload
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwarishubham635 committed Jan 10, 2025
1 parent 92f82cd commit 8704001
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 81 deletions.
34 changes: 14 additions & 20 deletions example/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
print($contentInstance->sid);
4 changes: 2 additions & 2 deletions src/Twilio/Rest/Assistants/V1/Assistant/FeedbackModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Twilio/Rest/Assistants/V1/Assistant/MessageModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/Twilio/Rest/Assistants/V1/AssistantModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
}
Expand Down Expand Up @@ -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
];
}
}
Expand Down Expand Up @@ -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
];
}
}
Expand Down Expand Up @@ -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
];
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Twilio/Rest/Assistants/V1/KnowledgeModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
Expand Down Expand Up @@ -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
];
}
}
Expand Down Expand Up @@ -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
];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Twilio/Rest/Assistants/V1/ToolModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
70 changes: 35 additions & 35 deletions src/Twilio/Rest/Content/V1/ContentModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
Expand Down Expand Up @@ -710,7 +710,7 @@ public function jsonSerialize(): array
'subtitle' => $this->subtitle,
'id' => $this->id,
'items' => $this->items,
'dynamicItems' => $this->dynamicItems
'dynamic_items' => $this->dynamicItems
];
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
];
Expand Down Expand Up @@ -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
];
}
Expand Down Expand Up @@ -986,7 +986,7 @@ public function jsonSerialize(): array
{
return [
'type' => $this->type,
'copyCodeText' => $this->copyCodeText
'copy_code_text' => $this->copyCodeText
];
}
}
Expand Down Expand Up @@ -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
];
}
Expand Down Expand Up @@ -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
Expand All @@ -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
];
}
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function toArray(): array
public function jsonSerialize(): array
{
return [
'referralAccountSid' => $this->referralAccountSid
'referral_account_sid' => $this->referralAccountSid
];
}
}
Expand Down

0 comments on commit 8704001

Please sign in to comment.