Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Merge 8.0.0-rc into main #803

Merged
merged 5 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

_MAJOR version bumps will have upgrade notes posted here._

[2023-03-25] 7.x.x to 8.x.x
---------------------------
Twilio Php Helper Library’s major version 8.0.0 is now available. We ensured that you can upgrade to Php helper Library 8.0.0 version without any breaking changes of existing apis

Behind the scenes Php Helper is now auto-generated via OpenAPI with this release. This enables us to rapidly add new features and enhance consistency across versions and languages.
We're pleased to inform you that version 8.0.0 adds support for the application/json content type in the request body.

[2023-03-08] 6.x.x to 7.x.x
---------------------------
Twilio Php Helper Library’s major version 7.0.1 is now available. We ensured that you can upgrade to Php helper Library 7.0.1 version without any breaking changes.
Expand Down
54 changes: 54 additions & 0 deletions example/messaging_bulk.php
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");
}
6 changes: 5 additions & 1 deletion src/Twilio/Http/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ public function options(string $method, string $url,
[$headers, $body] = $this->buildMultipartOptions($data);
$options[CURLOPT_POSTFIELDS] = $body;
$options[CURLOPT_HTTPHEADER] = \array_merge($options[CURLOPT_HTTPHEADER], $headers);
} else {
}
elseif (array_key_exists('Content-Type', $headers)) {
$options[CURLOPT_POSTFIELDS] = json_encode($data);
}
else {
$options[CURLOPT_POSTFIELDS] = $this->buildQuery($data);
$options[CURLOPT_HTTPHEADER][] = 'Content-Type: application/x-www-form-urlencoded';
}
Expand Down
13 changes: 13 additions & 0 deletions src/Twilio/Rest/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @property Intelligence $intelligence
* @property IpMessaging $ipMessaging
* @property Lookups $lookups
* @property PreviewMessaging $previewMessaging
* @property Messaging $messaging
* @property Microvisor $microvisor
* @property Monitor $monitor
Expand Down Expand Up @@ -109,6 +110,7 @@ class Client extends BaseClient {
protected $_intelligence;
protected $_ipMessaging;
protected $_lookups;
protected $_previewMessaging;
protected $_messaging;
protected $_microvisor;
protected $_monitor;
Expand Down Expand Up @@ -274,6 +276,17 @@ protected function getLookups(): Lookups {
}
return $this->_lookups;
}
/**
* Access the PreviewMessaging Twilio Domain
*
* @return PreviewMessaging PreviewMessaging Twilio Domain
*/
protected function getPreviewMessaging(): PreviewMessaging {
if (!$this->_previewMessaging) {
$this->_previewMessaging = new PreviewMessaging($this);
}
return $this->_previewMessaging;
}
/**
* Access the Messaging Twilio Domain
*
Expand Down
91 changes: 91 additions & 0 deletions src/Twilio/Rest/Content/V1/Content/ApprovalCreateInstance.php
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]';
}
}

80 changes: 80 additions & 0 deletions src/Twilio/Rest/Content/V1/Content/ApprovalCreateList.php
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 src/Twilio/Rest/Content/V1/Content/ApprovalCreateModels.php
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
];
}
}

Loading
Loading