-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Merge 8.0.0-rc into main (#803)
* chore: provide application/json support in request body (#799) * fix: added support for json content type * chore: added static files for preview messaging * chore: corrected name casing * chore: upgrade guide and changelog updated * chore: updated rc in VersionInfo.php * chore: updated rc version * feat!: MVR preparation (#802) * docs: added messaging bulk example * docs: corrected text message * feat!: MVR preparation --------- Co-authored-by: Twilio <[email protected]>
- Loading branch information
1 parent
02ad214
commit c8b4e6c
Showing
44 changed files
with
2,923 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
require(__DIR__.'/../src/Twilio/autoload.php'); | ||
|
||
use Twilio\Rest\Client; | ||
use Twilio\Rest\PreviewMessaging\V1\MessageModels; | ||
|
||
$sid = getenv('TWILIO_ACCOUNT_SID'); | ||
$token = getenv('TWILIO_AUTH_TOKEN'); | ||
$client = 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 | ||
$phoneNumber1 = "+XXXXXXXXXX"; | ||
$phoneNumber2 = "+XXXXXXXXXX"; | ||
|
||
// Create message object for the recipients | ||
$message1 = MessageModels::createMessagingV1Message( | ||
[ | ||
'to' => $phoneNumber1, | ||
] | ||
); | ||
$message2 = MessageModels::createMessagingV1Message( | ||
[ | ||
'to' => $phoneNumber2, | ||
] | ||
); | ||
|
||
// Create list of the message objects | ||
$messages = [$message1, $message2]; | ||
|
||
// This must be a Twilio phone number that you own, formatted with a '+' and country code | ||
$twilioPurchasedNumber = "+XXXXXXXXXX"; | ||
// Specify the message to be sent - JSON string supported | ||
$messageBody = "Hello from twilio-php!"; | ||
|
||
// Create Message Request object | ||
$createMessagesRequest = MessageModels::createCreateMessagesRequest( | ||
[ | ||
'messages' => $messages, | ||
'from' => $twilioPurchasedNumber, | ||
'body' => $messageBody, | ||
] | ||
); | ||
|
||
// Send a Bulk Message | ||
$message = $client->previewMessaging->v1->messages->create($createMessagesRequest); | ||
|
||
// Print how many messages were successful | ||
print($message->successCount . " messages sent successfully!" . "\n\n"); | ||
|
||
// Print the message details | ||
foreach ($message->messageReceipts as $msg) { | ||
print("ID:: " . $msg["sid"] . " | " . "TO:: " . $msg["to"] . "\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
src/Twilio/Rest/Content/V1/Content/ApprovalCreateInstance.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
/** | ||
* This code was generated by | ||
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ | ||
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | ||
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ | ||
* | ||
* Twilio - Content | ||
* This is the public Twilio REST API. | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator. | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
namespace Twilio\Rest\Content\V1\Content; | ||
|
||
use Twilio\Exceptions\TwilioException; | ||
use Twilio\InstanceResource; | ||
use Twilio\Values; | ||
use Twilio\Version; | ||
|
||
|
||
/** | ||
* @property string|null $name | ||
* @property string|null $category | ||
* @property string|null $contentType | ||
* @property string|null $status | ||
* @property string|null $rejectionReason | ||
* @property bool|null $allowCategoryChange | ||
*/ | ||
class ApprovalCreateInstance extends InstanceResource | ||
{ | ||
/** | ||
* Initialize the ApprovalCreateInstance | ||
* | ||
* @param Version $version Version that contains the resource | ||
* @param mixed[] $payload The response payload | ||
* @param string $contentSid | ||
*/ | ||
public function __construct(Version $version, array $payload, string $contentSid) | ||
{ | ||
parent::__construct($version); | ||
|
||
// Marshaled Properties | ||
$this->properties = [ | ||
'name' => Values::array_get($payload, 'name'), | ||
'category' => Values::array_get($payload, 'category'), | ||
'contentType' => Values::array_get($payload, 'content_type'), | ||
'status' => Values::array_get($payload, 'status'), | ||
'rejectionReason' => Values::array_get($payload, 'rejection_reason'), | ||
'allowCategoryChange' => Values::array_get($payload, 'allow_category_change'), | ||
]; | ||
|
||
$this->solution = ['contentSid' => $contentSid, ]; | ||
} | ||
|
||
/** | ||
* Magic getter to access properties | ||
* | ||
* @param string $name Property to access | ||
* @return mixed The requested property | ||
* @throws TwilioException For unknown properties | ||
*/ | ||
public function __get(string $name) | ||
{ | ||
if (\array_key_exists($name, $this->properties)) { | ||
return $this->properties[$name]; | ||
} | ||
|
||
if (\property_exists($this, '_' . $name)) { | ||
$method = 'get' . \ucfirst($name); | ||
return $this->$method(); | ||
} | ||
|
||
throw new TwilioException('Unknown property: ' . $name); | ||
} | ||
|
||
/** | ||
* Provide a friendly representation | ||
* | ||
* @return string Machine friendly representation | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return '[Twilio.Content.V1.ApprovalCreateInstance]'; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/** | ||
* This code was generated by | ||
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ | ||
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | ||
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ | ||
* | ||
* Twilio - Content | ||
* This is the public Twilio REST API. | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator. | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
namespace Twilio\Rest\Content\V1\Content; | ||
|
||
use Twilio\Exceptions\TwilioException; | ||
use Twilio\ListResource; | ||
use Twilio\Version; | ||
|
||
|
||
class ApprovalCreateList extends ListResource | ||
{ | ||
/** | ||
* Construct the ApprovalCreateList | ||
* | ||
* @param Version $version Version that contains the resource | ||
* @param string $contentSid | ||
*/ | ||
public function __construct( | ||
Version $version, | ||
string $contentSid | ||
) { | ||
parent::__construct($version); | ||
|
||
// Path Solution | ||
$this->solution = [ | ||
'contentSid' => | ||
$contentSid, | ||
|
||
]; | ||
|
||
$this->uri = '/Content/' . \rawurlencode($contentSid) | ||
.'/ApprovalRequests/whatsapp'; | ||
} | ||
|
||
/** | ||
* Create the ApprovalCreateInstance | ||
* | ||
* @param ContentApprovalRequest $contentApprovalRequest | ||
* @return ApprovalCreateInstance Created ApprovalCreateInstance | ||
* @throws TwilioException When an HTTP error occurs. | ||
*/ | ||
public function create(ContentApprovalRequest $contentApprovalRequest): ApprovalCreateInstance | ||
{ | ||
|
||
$data = $contentApprovalRequest->toArray(); | ||
$headers['Content-Type'] = 'application/json'; | ||
$payload = $this->version->create('POST', $this->uri, [], $data, $headers); | ||
|
||
return new ApprovalCreateInstance( | ||
$this->version, | ||
$payload, | ||
$this->solution['contentSid'] | ||
); | ||
} | ||
|
||
|
||
/** | ||
* Provide a friendly representation | ||
* | ||
* @return string Machine friendly representation | ||
*/ | ||
public function __toString(): string | ||
{ | ||
return '[Twilio.Content.V1.ApprovalCreateList]'; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/Twilio/Rest/Content/V1/Content/ApprovalCreateModels.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* This code was generated by | ||
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ | ||
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ | ||
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ | ||
* | ||
* Twilio - Content | ||
* This is the public Twilio REST API. | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator. | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
namespace Twilio\Rest\Content\V1\Content; | ||
|
||
use Twilio\Values; | ||
abstract class ApprovalCreateModels | ||
{ | ||
/** | ||
* @property string $name Name of the template. | ||
* @property string $category A WhatsApp recognized template category. | ||
*/ | ||
public static function createContentApprovalRequest(array $payload = []): ContentApprovalRequest | ||
{ | ||
return new ContentApprovalRequest($payload); | ||
} | ||
|
||
} | ||
|
||
class ContentApprovalRequest implements \JsonSerializable | ||
{ | ||
/** | ||
* @property string $name Name of the template. | ||
* @property string $category A WhatsApp recognized template category. | ||
*/ | ||
protected $name; | ||
protected $category; | ||
public function __construct(array $payload = []) { | ||
$this->name = Values::array_get($payload, 'name'); | ||
$this->category = Values::array_get($payload, 'category'); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return $this->jsonSerialize(); | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return [ | ||
'name' => $this->name, | ||
'category' => $this->category | ||
]; | ||
} | ||
} | ||
|
Oops, something went wrong.