Skip to content

Commit

Permalink
chore: provide application/json support in request body (#799)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tiwarishubham635 authored Mar 26, 2024
1 parent f97c450 commit 3ac1dab
Show file tree
Hide file tree
Showing 16 changed files with 969 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
twilio-php Changelog
====================

[2024-03-25] Version 8.0.0-rc.0
---------------------------
- Release Candidate Preparation

[2024-03-12] Version 7.16.1
---------------------------
**Api**
Expand Down
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

_MAJOR version bumps will have upgrade notes posted here._

[2023-03-25] 7.x.x to 8.x.x-rc.x
---------------------------
Twilio Php Helper Library’s major version 8.0.0-rc.x is now available. We ensured that you can upgrade to Php helper Library 8.0.0-rc.x version without any breaking changes
Twilio Helper libraries now support nested json body while sending requests.

[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
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 @@ -38,6 +38,7 @@
* @property Notify $notify
* @property Numbers $numbers
* @property Preview $preview
* @property PreviewMessaging $previewMessaging
* @property Pricing $pricing
* @property Proxy $proxy
* @property Routes $routes
Expand Down Expand Up @@ -116,6 +117,7 @@ class Client extends BaseClient {
protected $_notify;
protected $_numbers;
protected $_preview;
protected $_previewMessaging;
protected $_pricing;
protected $_proxy;
protected $_routes;
Expand Down Expand Up @@ -351,6 +353,17 @@ protected function getPreview(): Preview {
}
return $this->_preview;
}
/**
* 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 Pricing Twilio Domain
*
Expand Down
21 changes: 21 additions & 0 deletions src/Twilio/Rest/PreviewMessaging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Twilio\Rest;

use Twilio\Rest\PreviewMessaging\V1;

class PreviewMessaging extends PreviewMessagingBase {
/**
* @deprecated Use v1->oauth instead.
*/
protected function getMessages(): \Twilio\Rest\PreviewMessaging\V1\MessageList {
return $this->v1->messages;
}

/**
* @deprecated Use v1->oauth() instead.
*/
protected function getBroadcasts(): \Twilio\Rest\PreviewMessaging\V1\BroadcastList {
return $this->v1->broadcasts;
}
}
105 changes: 105 additions & 0 deletions src/Twilio/Rest/PreviewMessaging/V1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Bulk Messaging and Broadcast
* Bulk Sending is a public Twilio REST API for 1:Many Message creation up to 100 recipients. Broadcast is a public Twilio REST API for 1:Many Message creation up to 10,000 recipients via file upload.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

namespace Twilio\Rest\PreviewMessaging;

use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\PreviewMessaging\V1\BroadcastList;
use Twilio\Rest\PreviewMessaging\V1\MessageList;
use Twilio\Version;

/**
* @property BroadcastList $broadcasts
* @property MessageList $messages
*/
class V1 extends Version
{
protected $_broadcasts;
protected $_messages;

/**
* Construct the V1 version of PreviewMessaging
*
* @param Domain $domain Domain that contains the version
*/
public function __construct(Domain $domain)
{
parent::__construct($domain);
$this->version = 'v1';
}

protected function getBroadcasts(): BroadcastList
{
if (!$this->_broadcasts) {
$this->_broadcasts = new BroadcastList($this);
}
return $this->_broadcasts;
}

protected function getMessages(): MessageList
{
if (!$this->_messages) {
$this->_messages = new MessageList($this);
}
return $this->_messages;
}

/**
* 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.PreviewMessaging.V1]';
}
}
97 changes: 97 additions & 0 deletions src/Twilio/Rest/PreviewMessaging/V1/BroadcastInstance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Bulk Messaging and Broadcast
* Bulk Sending is a public Twilio REST API for 1:Many Message creation up to 100 recipients. Broadcast is a public Twilio REST API for 1:Many Message creation up to 10,000 recipients via file upload.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/


namespace Twilio\Rest\PreviewMessaging\V1;

use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
use Twilio\Deserialize;
use Twilio\Serialize;
use Twilio\Base\PhoneNumberCapabilities;


/**
* @property string $broadcastSid
* @property \DateTime $createdDate
* @property \DateTime $updatedDate
* @property string $broadcastStatus
* @property string $executionDetails
* @property string $resultsFile
*/
class BroadcastInstance extends InstanceResource
{
/**
* Initialize the BroadcastInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload)
{
parent::__construct($version);

// Marshaled Properties
$this->properties = [
'broadcastSid' => Values::array_get($payload, 'broadcast_sid'),
'createdDate' => Deserialize::dateTime(Values::array_get($payload, 'created_date')),
'updatedDate' => Deserialize::dateTime(Values::array_get($payload, 'updated_date')),
'broadcastStatus' => Values::array_get($payload, 'broadcast_status'),
'executionDetails' => Values::array_get($payload, 'execution_details'),
'resultsFile' => Values::array_get($payload, 'results_file'),
];

$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.PreviewMessaging.V1.BroadcastInstance]';
}
}

83 changes: 83 additions & 0 deletions src/Twilio/Rest/PreviewMessaging/V1/BroadcastList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Bulk Messaging and Broadcast
* Bulk Sending is a public Twilio REST API for 1:Many Message creation up to 100 recipients. Broadcast is a public Twilio REST API for 1:Many Message creation up to 10,000 recipients via file upload.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/

namespace Twilio\Rest\PreviewMessaging\V1;

use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
use Twilio\Deserialize;
use Twilio\Serialize;
use Twilio\Base\PhoneNumberCapabilities;


class BroadcastList extends ListResource
{
/**
* Construct the BroadcastList
*
* @param Version $version Version that contains the resource
*/
public function __construct(
Version $version
) {
parent::__construct($version);

// Path Solution
$this->solution = [
];

$this->uri = '/Broadcasts';
}

/**
* Create the BroadcastInstance
*
* @param array|Options $options Optional Arguments
* @return BroadcastInstance Created BroadcastInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $options = []): BroadcastInstance
{

$options = new Values($options);

$headers = Values::of(['X-Twilio-Request-Key' => $options['xTwilioRequestKey']]);

$payload = $this->version->create('POST', $this->uri, [], [], $headers);

return new BroadcastInstance(
$this->version,
$payload
);
}


/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string
{
return '[Twilio.PreviewMessaging.V1.BroadcastList]';
}
}
Loading

0 comments on commit 3ac1dab

Please sign in to comment.