Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions example/test_metadata_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@ function readMessage(Client $client, string $to)
//print "------------------------------------------------------------------------------------------------------\n";
//streamMessageWithMetadata($client, $to);

//readMessage($client, $to);
//print "------------------------------------------------------------------------------------------------------\n";
//readMessageWithMetadata($client, $to);
readMessage($client, $to);
print "------------------------------------------------------------------------------------------------------\n";
readMessageWithMetadata($client, $to);
42 changes: 37 additions & 5 deletions src/Twilio/Rest/Accounts/V1/AuthTokenPromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use Twilio\Values;
use Twilio\Version;
use Twilio\InstanceContext;
use Twilio\Http\Response;
use Twilio\Metadata\ResourceMetadata;


class AuthTokenPromotionContext extends InstanceContext
Expand All @@ -42,6 +44,18 @@ public function __construct(
$this->uri = '/AuthTokens/Promote';
}

/**
* Helper function for Update
*
* @return Response Updated Response
* @throws TwilioException When an HTTP error occurs.
*/
private function _update(): Response
{
$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
return $this->version->handleRequest('POST', $this->uri, [], [], $headers, "update");
}

/**
* Update the AuthTokenPromotionInstance
*
Expand All @@ -50,13 +64,31 @@ public function __construct(
*/
public function update(): AuthTokenPromotionInstance
{

$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->update('POST', $this->uri, [], [], $headers);

$response = $this->_update();
return new AuthTokenPromotionInstance(
$this->version,
$payload
$response->getContent()
);

}

/**
* Update the AuthTokenPromotionInstance with Metadata
*
* @return ResourceMetadata The Updated Resource with Metadata
* @throws TwilioException When an HTTP error occurs.
*/
public function updateWithMetadata(): ResourceMetadata
{
$response = $this->_update();
$resource = new AuthTokenPromotionInstance(
$this->version,
$response->getContent()
);
return new ResourceMetadata(
$resource,
$response->getStatusCode(),
$response->getHeaders()
);
}

Expand Down
46 changes: 40 additions & 6 deletions src/Twilio/Rest/Accounts/V1/BulkConsentsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Twilio\ListResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Http\Response;
use Twilio\Metadata\ResourceMetadata;
use Twilio\Serialize;


Expand All @@ -43,26 +45,58 @@ public function __construct(
}

/**
* Create the BulkConsentsInstance
* Helper function for Create
*
* @param array[] $items This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty.
* @return BulkConsentsInstance Created BulkConsentsInstance
* @return Response Created Response
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $items): BulkConsentsInstance
private function _create(array $items): Response
{

$data = Values::of([
'Items' =>
Serialize::map($items,function ($e) { return Serialize::jsonObject($e); }),
]);

$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
}

/**
* Create the BulkConsentsInstance
*
* @param array[] $items This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty.
* @return BulkConsentsInstance Created BulkConsentsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $items): BulkConsentsInstance
{
$response = $this->_create($items);
return new BulkConsentsInstance(
$this->version,
$payload
$response->getContent()
);

}

/**
* Create the BulkConsentsInstance with Metadata
*
* @param array[] $items This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty.
* @return ResourceMetadata The Created Resource with Metadata
* @throws TwilioException When an HTTP error occurs.
*/
public function createWithMetadata(array $items): ResourceMetadata
{
$response = $this->_create($items);
$resource = new BulkConsentsInstance(
$this->version,
$response->getContent()
);
return new ResourceMetadata(
$resource,
$response->getStatusCode(),
$response->getHeaders()
);
}

Expand Down
46 changes: 40 additions & 6 deletions src/Twilio/Rest/Accounts/V1/BulkContactsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Twilio\ListResource;
use Twilio\Values;
use Twilio\Version;
use Twilio\Http\Response;
use Twilio\Metadata\ResourceMetadata;
use Twilio\Serialize;


Expand All @@ -43,26 +45,58 @@ public function __construct(
}

/**
* Create the BulkContactsInstance
* Helper function for Create
*
* @param array[] $items A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code.
* @return BulkContactsInstance Created BulkContactsInstance
* @return Response Created Response
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $items): BulkContactsInstance
private function _create(array $items): Response
{

$data = Values::of([
'Items' =>
Serialize::map($items,function ($e) { return Serialize::jsonObject($e); }),
]);

$headers = Values::of(['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json' ]);
$payload = $this->version->create('POST', $this->uri, [], $data, $headers);
return $this->version->handleRequest('POST', $this->uri, [], $data, $headers, "create");
}

/**
* Create the BulkContactsInstance
*
* @param array[] $items A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code.
* @return BulkContactsInstance Created BulkContactsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $items): BulkContactsInstance
{
$response = $this->_create($items);
return new BulkContactsInstance(
$this->version,
$payload
$response->getContent()
);

}

/**
* Create the BulkContactsInstance with Metadata
*
* @param array[] $items A list of objects where each object represents a contact's details. Each object includes the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID that maps the response to the original request; `country_iso_code`, a string representing the country using the ISO format (e.g., US for the United States); and `zip_code`, a string representing the postal code.
* @return ResourceMetadata The Created Resource with Metadata
* @throws TwilioException When an HTTP error occurs.
*/
public function createWithMetadata(array $items): ResourceMetadata
{
$response = $this->_create($items);
$resource = new BulkContactsInstance(
$this->version,
$response->getContent()
);
return new ResourceMetadata(
$resource,
$response->getStatusCode(),
$response->getHeaders()
);
}

Expand Down
Loading
Loading