Subiendo proyecto completo sin restricciones de git ignore

This commit is contained in:
Jose Sanchez
2023-08-17 11:44:02 -04:00
parent a0d4f5ba3b
commit 20f1c60600
19921 changed files with 2509159 additions and 45 deletions

View File

@@ -0,0 +1,10 @@
contact_links:
- name: Twilio Support
url: https://twilio.com/help/contact
about: Get Support
- name: Stack Overflow
url: https://stackoverflow.com/questions/tagged/twilio-php+or+twilio+php
about: Ask questions on Stack Overflow
- name: Documentation
url: https://www.twilio.com/docs/libraries/reference/twilio-php
about: View Reference Documentation

View File

@@ -0,0 +1,21 @@
name: Lint PR
on:
pull_request_target:
types: [ opened, edited, synchronize, reopened ]
jobs:
validate:
name: Validate title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
with:
types: |
chore
docs
fix
feat
misc
test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,113 @@
name: Test and Deploy
on:
push:
branches: [ '*' ]
tags: [ '*' ]
pull_request:
branches: [ main ]
schedule:
# Run automatically at 8AM PST Monday-Friday
- cron: '0 15 * * 1-5'
workflow_dispatch:
jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
php: [ 7.2, 7.3, 7.4, 8.0, 8.1 ]
dependencies:
- "lowest"
- "highest"
steps:
- name: Checkout twilio-php
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup PHP Action
uses: shivammathur/setup-php@2.15.0
with:
php-version: ${{ matrix.php }}
coverage: xdebug
id: php
- name: Composer webhook config
run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
- name: Update Dependencies
if: matrix.dependencies == 'lowest'
run: composer update --prefer-lowest --prefer-stable -n
- name: Run Tests
run: make install test
- name: Fix code coverage paths
run: |
if [ -f "coverage.xml" ]; then
sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
fi
- name: Install SonarCloud scanner and run analysis
uses: SonarSource/sonarcloud-github-action@master
if: (github.event_name == 'pull_request' || github.ref_type == 'branch') && !github.event.pull_request.head.repo.fork && matrix.php == '8.1' && matrix.dependencies == 'highest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
deploy:
name: Deploy
if: success() && github.ref_type == 'tag'
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout twilio-php
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
run: composer install
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTH_TOKEN }}
# The expression strips off the shortest match from the front of the string to yield just the tag name as the output
- name: Get tagged version
run: echo "GITHUB_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Create GitHub Release
uses: sendgrid/dx-automator/actions/release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build & Push docker image
run: make docker-build docker-push
- name: Submit metric to Datadog
uses: sendgrid/dx-automator/actions/datadog-release-metric@main
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
notify-on-failure:
name: Slack notify on failure
if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
needs: [ test, deploy ]
runs-on: ubuntu-latest
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: failure
SLACK_ICON_EMOJI: ':github:'
SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
SLACK_TITLE: Action Failure - ${{ github.repository }}
SLACK_USERNAME: GitHub Actions
SLACK_MSG_AUTHOR: twilio-dx
SLACK_FOOTER: Posted automatically using GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: true

73
vendor/twilio/sdk/CODE_OF_CONDUCT.md vendored Normal file
View File

@@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at open-source@twilio.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

14
vendor/twilio/sdk/Dockerfile vendored Normal file
View File

@@ -0,0 +1,14 @@
FROM php:7.4
RUN apt-get update -y && apt-get install -y zip
RUN mkdir /twilio
WORKDIR /twilio
ENV PATH="vendor/bin:$PATH"
COPY src src
COPY tests tests
COPY composer* ./
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
RUN composer install --prefer-dist

16
vendor/twilio/sdk/Dockerfile-dev vendored Normal file
View File

@@ -0,0 +1,16 @@
ARG version
FROM php:$version
RUN curl --silent --show-error https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get dist-upgrade -y && \
apt-get -y autoremove && \
apt-get clean
RUN apt-get install -y zip unzip git
ENV COMPOSER_ALLOW_SUPERUSER=1
WORKDIR /twilio

View File

@@ -0,0 +1,31 @@
<!--
We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below.
Please format the PR title appropriately based on the type of change:
<type>[!]: <description>
Where <type> is one of: docs, chore, feat, fix, test, misc.
Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature).
**All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.**
Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged!
e.g.
Fixes #1
Closes #2
-->
# Fixes #
A short description of what this PR does.
### Checklist
- [x] I acknowledge that all my contributions will be made under the project's license
- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
- [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-php/blob/main/CONTRIBUTING.md) and my PR follows them
- [ ] I have titled the PR appropriately
- [ ] I have updated my branch with the main branch
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added the necessary documentation about the functionality in the appropriate .md file
- [ ] I have added inline documentation to the code I modified
If you have questions, please file a [support ticket](https://twilio.com/help/contact), or create a GitHub Issue in this repository.

37
vendor/twilio/sdk/composer.json vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "twilio/sdk",
"type": "library",
"description": "A PHP wrapper for Twilio's API",
"keywords": ["twilio", "sms", "api"],
"homepage": "https://github.com/twilio/twilio-php",
"license": "MIT",
"authors": [
{
"name": "Twilio API Team",
"email": "api@twilio.com"
}
],
"require": {
"php": ">=7.1.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.3 || ^7.0",
"phpunit/phpunit": ">=7.0 < 10"
},
"suggest": {
"guzzlehttp/guzzle": "An HTTP client to execute the API requests"
},
"autoload": {
"psr-4": {
"Twilio\\": "src/Twilio/"
}
},
"autoload-dev": {
"psr-4": {
"Twilio\\Tests\\": "tests/Twilio/"
}
},
"config": {
"lock": false
}
}

11
vendor/twilio/sdk/phpdox.xml vendored Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://xml.phpdox.net/config">
<project name="twilio-php" source="${basedir}/src" workdir="${basedir}/docs/xml">
<collector backend="parser"/>
<generator output="${basedir}/docs">
<build engine="html" output="api">
<file extension="html"/>
</build>
</generator>
</project>
</phpdox>

View File

@@ -0,0 +1,11 @@
sonar.projectKey=twilio_twilio-php
sonar.projectName=twilio-php
sonar.organization=twilio
sonar.sources=src/
sonar.exclusions=src/Twilio/Rest/**/*, src/Twilio/TwiML/*/*, src/Twilio/TwiML/*Response.php
sonar.tests=tests/
sonar.test.exclusions=tests/Twilio/Integration/**/*
# For Code Coverage analysis
sonar.php.coverage.reportPaths=coverage.xml

View File

@@ -0,0 +1,25 @@
<?php
namespace Twilio;
class Deserialize {
/**
* Deserialize a string date into a DateTime object
*
* @param string $s A date or date and time, can be iso8601, rfc2822,
* YYYY-MM-DD format.
* @return \DateTime|string DateTime corresponding to the input string, in UTC time.
*/
public static function dateTime(?string $s) {
try {
if ($s) {
return new \DateTime($s, new \DateTimeZone('UTC'));
}
} catch (\Exception $e) {
// no-op
}
return $s;
}
}

82
vendor/twilio/sdk/src/Twilio/Domain.php vendored Normal file
View File

@@ -0,0 +1,82 @@
<?php
namespace Twilio;
use Twilio\Http\Response;
use Twilio\Rest\Client;
/**
* Class Domain
* Abstracts a Twilio sub domain
* @package Twilio
*/
abstract class Domain {
/**
* @var Client Twilio Client
*/
protected $client;
/**
* @var string Base URL for this domain
*/
protected $baseUrl;
/**
* Construct a new Domain
* @param Client $client used to communicate with Twilio
*/
public function __construct(Client $client) {
$this->client = $client;
$this->baseUrl = '';
}
/**
* Translate version relative URIs into absolute URLs
*
* @param string $uri Version relative URI
* @return string Absolute URL for this domain
*/
public function absoluteUrl(string $uri): string {
return \implode('/', [\trim($this->baseUrl, '/'), \trim($uri, '/')]);
}
/**
* Make an HTTP request to the domain
*
* @param string $method HTTP Method to make the request with
* @param string $uri Relative uri to make a request to
* @param array $params Query string arguments
* @param array $data Post form data
* @param array $headers HTTP headers to send with the request
* @param string $user User to authenticate as
* @param string $password Password
* @param int $timeout Request timeout
* @return Response the response for the request
*/
public function request(string $method, string $uri,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
$url = $this->absoluteUrl($uri);
return $this->client->request(
$method,
$url,
$params,
$data,
$headers,
$user,
$password,
$timeout
);
}
public function getClient(): Client {
return $this->client;
}
public function __toString(): string {
return '[Domain]';
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class ConfigurationException extends TwilioException {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class DeserializeException extends TwilioException {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class EnvironmentException extends TwilioException {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class HttpException extends TwilioException {
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Twilio\Exceptions;
class RestException extends TwilioException {
protected $statusCode;
protected $details;
protected $moreInfo;
/**
* Construct the exception. Note: The message is NOT binary safe.
* @link http://php.net/manual/en/exception.construct.php
* @param string $message [optional] The Exception message to throw.
* @param int $code [optional] The Exception code.
* @param int $statusCode [optional] The HTTP Status code.
* @param string $moreInfo [optional] More information about the error.
* @param array $details [optional] Additional details about the error.
* @since 5.1.0
*/
public function __construct(string $message, int $code, int $statusCode, string $moreInfo = '', array $details = []) {
$this->statusCode = $statusCode;
$this->moreInfo = $moreInfo;
$this->details = $details;
parent::__construct($message, $code);
}
/**
* Get the HTTP Status Code of the RestException
* @return int HTTP Status Code
*/
public function getStatusCode(): int {
return $this->statusCode;
}
/**
* Get more information of the RestException
* @return string More error information
*/
public function getMoreInfo(): string {
return $this->moreInfo;
}
/**
* Get the details of the RestException
* @return exception details
*/
public function getDetails(): array {
return $this->details;
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class TwilioException extends \Exception {
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Twilio\Exceptions;
class TwimlException extends TwilioException {
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Twilio\Http;
interface Client {
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response;
}

View File

@@ -0,0 +1,238 @@
<?php
namespace Twilio\Http;
use Twilio\Exceptions\ConfigurationException;
use Twilio\Exceptions\EnvironmentException;
class CurlClient implements Client {
public const DEFAULT_TIMEOUT = 60;
protected $curlOptions = [];
public $lastRequest;
public $lastResponse;
public function __construct(array $options = []) {
$this->curlOptions = $options;
}
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
$options = $this->options($method, $url, $params, $data, $headers,
$user, $password, $timeout);
$this->lastRequest = $options;
$this->lastResponse = null;
try {
if (!$curl = \curl_init()) {
throw new EnvironmentException('Unable to initialize cURL');
}
if (!\curl_setopt_array($curl, $options)) {
throw new EnvironmentException(\curl_error($curl));
}
if (!$response = \curl_exec($curl)) {
throw new EnvironmentException(\curl_error($curl));
}
$parts = \explode("\r\n\r\n", $response, 3);
list($head, $body) = (
\preg_match('/\AHTTP\/1.\d 100 Continue\Z/', $parts[0])
|| \preg_match('/\AHTTP\/1.\d 200 Connection established\Z/', $parts[0])
|| \preg_match('/\AHTTP\/1.\d 200 Tunnel established\Z/', $parts[0])
)
? array($parts[1], $parts[2])
: array($parts[0], $parts[1]);
$statusCode = \curl_getinfo($curl, CURLINFO_HTTP_CODE);
$responseHeaders = [];
$headerLines = \explode("\r\n", $head);
\array_shift($headerLines);
foreach ($headerLines as $line) {
list($key, $value) = \explode(':', $line, 2);
$responseHeaders[$key] = $value;
}
\curl_close($curl);
if (isset($options[CURLOPT_INFILE]) && \is_resource($options[CURLOPT_INFILE])) {
\fclose($options[CURLOPT_INFILE]);
}
$this->lastResponse = new Response($statusCode, $body, $responseHeaders);
return $this->lastResponse;
} catch (\ErrorException $e) {
if (isset($curl) && \is_resource($curl)) {
\curl_close($curl);
}
if (isset($options[CURLOPT_INFILE]) && \is_resource($options[CURLOPT_INFILE])) {
\fclose($options[CURLOPT_INFILE]);
}
throw $e;
}
}
public function options(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): array {
$timeout = $timeout ?? self::DEFAULT_TIMEOUT;
$options = $this->curlOptions + [
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_INFILESIZE => Null,
CURLOPT_HTTPHEADER => [],
CURLOPT_TIMEOUT => $timeout,
];
foreach ($headers as $key => $value) {
$options[CURLOPT_HTTPHEADER][] = "$key: $value";
}
if ($user && $password) {
$options[CURLOPT_HTTPHEADER][] = 'Authorization: Basic ' . \base64_encode("$user:$password");
}
$query = $this->buildQuery($params);
if ($query) {
$options[CURLOPT_URL] .= '?' . $query;
}
switch (\strtolower(\trim($method))) {
case 'get':
$options[CURLOPT_HTTPGET] = true;
break;
case 'post':
$options[CURLOPT_POST] = true;
if ($this->hasFile($data)) {
[$headers, $body] = $this->buildMultipartOptions($data);
$options[CURLOPT_POSTFIELDS] = $body;
$options[CURLOPT_HTTPHEADER] = \array_merge($options[CURLOPT_HTTPHEADER], $headers);
} else {
$options[CURLOPT_POSTFIELDS] = $this->buildQuery($data);
$options[CURLOPT_HTTPHEADER][] = 'Content-Type: application/x-www-form-urlencoded';
}
break;
case 'put':
// TODO: PUT doesn't used anywhere and it has strange implementation. Must investigate later
$options[CURLOPT_PUT] = true;
if ($data) {
if ($buffer = \fopen('php://memory', 'w+')) {
$dataString = $this->buildQuery($data);
\fwrite($buffer, $dataString);
\fseek($buffer, 0);
$options[CURLOPT_INFILE] = $buffer;
$options[CURLOPT_INFILESIZE] = \strlen($dataString);
} else {
throw new EnvironmentException('Unable to open a temporary file');
}
}
break;
case 'head':
$options[CURLOPT_NOBODY] = true;
break;
default:
$options[CURLOPT_CUSTOMREQUEST] = \strtoupper($method);
}
return $options;
}
public function buildQuery(?array $params): string {
$parts = [];
$params = $params ?: [];
foreach ($params as $key => $value) {
if (\is_array($value)) {
foreach ($value as $item) {
$parts[] = \urlencode((string)$key) . '=' . \urlencode((string)$item);
}
} else {
$parts[] = \urlencode((string)$key) . '=' . \urlencode((string)$value);
}
}
return \implode('&', $parts);
}
private function hasFile(array $data): bool {
foreach ($data as $value) {
if ($value instanceof File) {
return true;
}
}
return false;
}
private function buildMultipartOptions(array $data): array {
$boundary = \uniqid('', true);
$delimiter = "-------------{$boundary}";
$body = '';
foreach ($data as $key => $value) {
if ($value instanceof File) {
$contents = $value->getContents();
if ($contents === null) {
$chunk = \file_get_contents($value->getFileName());
$filename = \basename($value->getFileName());
} elseif (\is_resource($contents)) {
$chunk = '';
while (!\feof($contents)) {
$chunk .= \fread($contents, 8096);
}
$filename = $value->getFileName();
} elseif (\is_string($contents)) {
$chunk = $contents;
$filename = $value->getFileName();
} else {
throw new \InvalidArgumentException('Unsupported content type');
}
$headers = '';
$contentType = $value->getContentType();
if ($contentType !== null) {
$headers .= "Content-Type: {$contentType}\r\n";
}
$body .= \vsprintf("--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n%s\r\n%s\r\n", [
$delimiter,
$key,
$filename,
$headers,
$chunk,
]);
} else {
$body .= \vsprintf("--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", [
$delimiter,
$key,
$value,
]);
}
}
$body .= "--{$delimiter}--\r\n";
return [
[
"Content-Type: multipart/form-data; boundary={$delimiter}",
'Content-Length: ' . \strlen($body),
],
$body,
];
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Twilio\Http;
final class File {
/**
* @var string
*/
private $fileName;
/**
* @var resource|string|mixed|null
*/
private $contents;
/**
* @var string|null
*/
private $contentType;
/**
* @param string $fileName full file path or file name for passed $contents
* @param string|resource|mixed|null $contents
* @param string $contentType
*/
public function __construct(string $fileName, $contents = null, string $contentType = null) {
$this->fileName = $fileName;
$this->contents = $contents;
$this->contentType = $contentType;
}
/**
* @return resource|string|mixed|null
*/
public function getContents() {
return $this->contents;
}
public function getFileName(): string {
return $this->fileName;
}
public function getContentType(): ?string {
return $this->contentType;
}
}

View File

@@ -0,0 +1,99 @@
<?php
namespace Twilio\Http;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\Psr7\Query;
use GuzzleHttp\Psr7\Request;
use Twilio\Exceptions\HttpException;
final class GuzzleClient implements Client {
/**
* @var ClientInterface
*/
private $client;
public function __construct(ClientInterface $client) {
$this->client = $client;
}
public function request(string $method, string $url,
array $params = [], array $data = [], array $headers = [],
string $user = null, string $password = null,
int $timeout = null): Response {
try {
$options = [
'timeout' => $timeout,
'auth' => [$user, $password],
'allow_redirects' => false,
];
if ($params) {
$options['query'] = $params;
}
if ($method === 'POST') {
if ($this->hasFile($data)) {
$options['multipart'] = $this->buildMultipartParam($data);
} else {
$options['body'] = Query::build($data, PHP_QUERY_RFC1738);
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
}
$response = $this->client->send(new Request($method, $url, $headers), $options);
} catch (BadResponseException $exception) {
$response = $exception->getResponse();
} catch (\Exception $exception) {
throw new HttpException('Unable to complete the HTTP request', 0, $exception);
}
// Casting the body (stream) to a string performs a rewind, ensuring we return the entire response.
// See https://stackoverflow.com/a/30549372/86696
return new Response($response->getStatusCode(), (string)$response->getBody(), $response->getHeaders());
}
private function hasFile(array $data): bool {
foreach ($data as $value) {
if ($value instanceof File) {
return true;
}
}
return false;
}
private function buildMultipartParam(array $data): array {
$multipart = [];
foreach ($data as $key => $value) {
if ($value instanceof File) {
$contents = $value->getContents();
if ($contents === null) {
$contents = fopen($value->getFileName(), 'rb');
}
$chunk = [
'name' => $key,
'contents' => $contents,
'filename' => $value->getFileName(),
];
if ($value->getContentType() !== null) {
$chunk['headers']['Content-Type'] = $value->getContentType();
}
} else {
$chunk = [
'name' => $key,
'contents' => $value,
];
}
$multipart[] = $chunk;
}
return $multipart;
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Twilio\Http;
class Response {
protected $headers;
protected $content;
protected $statusCode;
public function __construct(int $statusCode, ?string $content, ?array $headers = []) {
$this->statusCode = $statusCode;
$this->content = $content;
$this->headers = $headers;
}
/**
* @return mixed
*/
public function getContent() {
return \json_decode($this->content, true);
}
public function getStatusCode(): int {
return $this->statusCode;
}
public function getHeaders(): array {
return $this->headers;
}
public function ok(): bool {
return $this->getStatusCode() < 400;
}
public function __toString(): string {
return '[Response] HTTP ' . $this->getStatusCode() . ' ' . $this->content;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Twilio;
class InstanceContext {
protected $version;
protected $solution = [];
protected $uri;
public function __construct(Version $version) {
$this->version = $version;
}
public function __toString(): string {
return '[InstanceContext]';
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Twilio;
class InstanceResource {
protected $version;
protected $context;
protected $properties = [];
protected $solution = [];
public function __construct(Version $version) {
$this->version = $version;
}
public function toArray(): array {
return $this->properties;
}
public function __toString(): string {
return '[InstanceResource]';
}
public function __isset($name): bool {
return \array_key_exists($name, $this->properties);
}
}

View File

@@ -0,0 +1,169 @@
<?php
namespace Twilio\Jwt;
use Twilio\Jwt\Grants\Grant;
class AccessToken {
private $signingKeySid;
private $accountSid;
private $secret;
private $ttl;
private $identity;
private $nbf;
private $region;
/** @var Grant[] $grants */
private $grants;
/** @var string[] $customClaims */
private $customClaims;
public function __construct(string $accountSid, string $signingKeySid, string $secret, int $ttl = 3600, string $identity = null, string $region = null) {
$this->signingKeySid = $signingKeySid;
$this->accountSid = $accountSid;
$this->secret = $secret;
$this->ttl = $ttl;
$this->region = $region;
if ($identity !== null) {
$this->identity = $identity;
}
$this->grants = [];
$this->customClaims = [];
}
/**
* Set the identity of this access token
*
* @param string $identity identity of the grant
*
* @return $this updated access token
*/
public function setIdentity(string $identity): self {
$this->identity = $identity;
return $this;
}
/**
* Returns the identity of the grant
*
* @return string the identity
*/
public function getIdentity(): string {
return $this->identity;
}
/**
* Set the nbf of this access token
*
* @param int $nbf nbf in epoch seconds of the grant
*
* @return $this updated access token
*/
public function setNbf(int $nbf): self {
$this->nbf = $nbf;
return $this;
}
/**
* Returns the nbf of the grant
*
* @return int the nbf in epoch seconds
*/
public function getNbf(): int {
return $this->nbf;
}
/**
* Set the region of this access token
*
* @param string $region Home region of the account sid in this access token
*
* @return $this updated access token
*/
public function setRegion(string $region): self {
$this->region = $region;
return $this;
}
/**
* Returns the region of this access token
*
* @return string Home region of the account sid in this access token
*/
public function getRegion(): string {
return $this->region;
}
/**
* Add a grant to the access token
*
* @param Grant $grant to be added
*
* @return $this the updated access token
*/
public function addGrant(Grant $grant): self {
$this->grants[] = $grant;
return $this;
}
/**
* Allows to set custom claims, which then will be encoded into JWT payload.
*
* @param string $name
* @param string $value
*/
public function addClaim(string $name, string $value): void {
$this->customClaims[$name] = $value;
}
public function toJWT(string $algorithm = 'HS256'): string {
$header = [
'cty' => 'twilio-fpa;v=1',
'typ' => 'JWT'
];
if ($this->region) {
$header['twr'] = $this->region;
}
$now = \time();
$grants = [];
if ($this->identity) {
$grants['identity'] = $this->identity;
}
foreach ($this->grants as $grant) {
$payload = $grant->getPayload();
if (empty($payload)) {
$payload = \json_decode('{}');
}
$grants[$grant->getGrantKey()] = $payload;
}
if (empty($grants)) {
$grants = \json_decode('{}');
}
$payload = \array_merge($this->customClaims, [
'jti' => $this->signingKeySid . '-' . $now,
'iss' => $this->signingKeySid,
'sub' => $this->accountSid,
'exp' => $now + $this->ttl,
'grants' => $grants
]);
if ($this->nbf !== null) {
$payload['nbf'] = $this->nbf;
}
return JWT::encode($payload, $this->secret, $algorithm, $header);
}
public function __toString(): string {
return $this->toJWT();
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Twilio\Jwt\Client;
/**
* Scope URI implementation
*
* Simple way to represent configurable privileges in an OAuth
* friendly way. For our case, they look like this:
*
* scope:<service>:<privilege>?<params>
*
* For example:
* scope:client:incoming?name=jonas
*/
class ScopeURI {
public $service;
public $privilege;
public $params;
public function __construct(string $service, string $privilege, array $params = []) {
$this->service = $service;
$this->privilege = $privilege;
$this->params = $params;
}
public function toString(): string {
$uri = "scope:{$this->service}:{$this->privilege}";
if (\count($this->params)) {
$uri .= '?' . \http_build_query($this->params, '', '&');
}
return $uri;
}
/**
* Parse a scope URI into a ScopeURI object
*
* @param string $uri The scope URI
* @return ScopeURI The parsed scope uri
* @throws \UnexpectedValueException
*/
public static function parse(string $uri): ScopeURI {
if (\strpos($uri, 'scope:') !== 0) {
throw new \UnexpectedValueException(
'Not a scope URI according to scheme');
}
$parts = \explode('?', $uri, 1);
$params = null;
if (\count($parts) > 1) {
\parse_str($parts[1], $params);
}
$parts = \explode(':', $parts[0], 2);
if (\count($parts) !== 3) {
throw new \UnexpectedValueException(
'Not enough parts for scope URI');
}
[$scheme, $service, $privilege] = $parts;
return new ScopeURI($service, $privilege, $params);
}
}

View File

@@ -0,0 +1,128 @@
<?php
namespace Twilio\Jwt;
use Twilio\Jwt\Client\ScopeURI;
/**
* Twilio Capability Token generator
*/
class ClientToken {
public $accountSid;
public $authToken;
/** @var ScopeURI[] $scopes */
public $scopes;
public $clientName;
/** @var string[] $customClaims */
private $customClaims;
/**
* Create a new TwilioCapability with zero permissions. Next steps are to
* grant access to resources by configuring this token through the
* functions allowXXXX.
*
* @param string $accountSid the account sid to which this token is granted
* access
* @param string $authToken the secret key used to sign the token. Note,
* this auth token is not visible to the user of the token.
*/
public function __construct(string $accountSid, string $authToken) {
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->scopes = [];
$this->clientName = false;
$this->customClaims = [];
}
/**
* If the user of this token should be allowed to accept incoming
* connections then configure the TwilioCapability through this method and
* specify the client name.
*
* @param string $clientName
* @throws \InvalidArgumentException
*/
public function allowClientIncoming(string $clientName): void {
// clientName must be a non-zero length alphanumeric string
if (\preg_match('/\W/', $clientName)) {
throw new \InvalidArgumentException(
'Only alphanumeric characters allowed in client name.');
}
if ($clientName === '') {
throw new \InvalidArgumentException(
'Client name must not be a zero length string.');
}
$this->clientName = $clientName;
$this->allow('client', 'incoming', ['clientName' => $clientName]);
}
/**
* Allow the user of this token to make outgoing connections.
*
* @param string $appSid the application to which this token grants access
* @param mixed[] $appParams signed parameters that the user of this token
* cannot overwrite.
*/
public function allowClientOutgoing(string $appSid, array $appParams = []): void {
$this->allow('client', 'outgoing', [
'appSid' => $appSid,
'appParams' => \http_build_query($appParams, '', '&')
]);
}
/**
* Allow the user of this token to access their event stream.
*
* @param mixed[] $filters key/value filters to apply to the event stream
*/
public function allowEventStream(array $filters = []): void {
$this->allow('stream', 'subscribe', [
'path' => '/2010-04-01/Events',
'params' => \http_build_query($filters, '', '&'),
]);
}
/**
* Allows to set custom claims, which then will be encoded into JWT payload.
*
* @param string $name
* @param string $value
*/
public function addClaim(string $name, string $value): void {
$this->customClaims[$name] = $value;
}
/**
* Generates a new token based on the credentials and permissions that
* previously has been granted to this token.
*
* @param int $ttl the expiration time of the token (in seconds). Default
* value is 3600 (1hr)
* @return string the newly generated token that is valid for $ttl seconds
*/
public function generateToken(int $ttl = 3600): string {
$payload = \array_merge($this->customClaims, [
'scope' => [],
'iss' => $this->accountSid,
'exp' => \time() + $ttl,
]);
$scopeStrings = [];
foreach ($this->scopes as $scope) {
if ($scope->privilege === 'outgoing' && $this->clientName) {
$scope->params['clientName'] = $this->clientName;
}
$scopeStrings[] = $scope->toString();
}
$payload['scope'] = \implode(' ', $scopeStrings);
return JWT::encode($payload, $this->authToken, 'HS256');
}
protected function allow(string $service, string $privilege, array $params): void {
$this->scopes[] = new ScopeURI($service, $privilege, $params);
}
}

View File

@@ -0,0 +1,128 @@
<?php
namespace Twilio\Jwt\Grants;
class ChatGrant implements Grant {
private $serviceSid;
private $endpointId;
private $deploymentRoleSid;
private $pushCredentialSid;
/**
* Returns the service sid
*
* @return string the service sid
*/
public function getServiceSid(): string {
return $this->serviceSid;
}
/**
* Set the service sid of this grant
*
* @param string $serviceSid service sid of the grant
*
* @return $this updated grant
*/
public function setServiceSid(string $serviceSid): self {
$this->serviceSid = $serviceSid;
return $this;
}
/**
* Returns the endpoint id of the grant
*
* @return string the endpoint id
*/
public function getEndpointId(): string {
return $this->endpointId;
}
/**
* Set the endpoint id of the grant
*
* @param string $endpointId endpoint id of the grant
*
* @return $this updated grant
*/
public function setEndpointId(string $endpointId): self {
$this->endpointId = $endpointId;
return $this;
}
/**
* Returns the deployment role sid of the grant
*
* @return string the deployment role sid
*/
public function getDeploymentRoleSid(): string {
return $this->deploymentRoleSid;
}
/**
* Set the role sid of the grant
*
* @param string $deploymentRoleSid role sid of the grant
*
* @return $this updated grant
*/
public function setDeploymentRoleSid(string $deploymentRoleSid): self {
$this->deploymentRoleSid = $deploymentRoleSid;
return $this;
}
/**
* Returns the push credential sid of the grant
*
* @return string the push credential sid
*/
public function getPushCredentialSid(): string {
return $this->pushCredentialSid;
}
/**
* Set the credential sid of the grant
*
* @param string $pushCredentialSid push credential sid of the grant
*
* @return $this updated grant
*/
public function setPushCredentialSid(string $pushCredentialSid): self {
$this->pushCredentialSid = $pushCredentialSid;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'chat';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->serviceSid) {
$payload['service_sid'] = $this->serviceSid;
}
if ($this->endpointId) {
$payload['endpoint_id'] = $this->endpointId;
}
if ($this->deploymentRoleSid) {
$payload['deployment_role_sid'] = $this->deploymentRoleSid;
}
if ($this->pushCredentialSid) {
$payload['push_credential_sid'] = $this->pushCredentialSid;
}
return $payload;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Twilio\Jwt\Grants;
interface Grant {
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string;
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array;
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Twilio\Jwt\Grants;
class PlaybackGrant implements Grant {
private $grant;
/**
* Returns the grant
*
* @return array playback grant from the Twilio API
*/
public function getGrant(): array {
return $this->grant;
}
/**
* Set the playback grant that will allow access to a stream
*
* @param array $grant playback grant from Twilio API
* @return $this updated grant
*/
public function setGrant(array $grant): self {
$this->grant = $grant;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'player';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->grant) {
$payload = $this->grant;
}
return $payload;
}
}

View File

@@ -0,0 +1,126 @@
<?php
namespace Twilio\Jwt\Grants;
class SyncGrant implements Grant {
private $serviceSid;
private $endpointId;
private $deploymentRoleSid;
private $pushCredentialSid;
/**
* Returns the service sid
*
* @return string the service sid
*/
public function getServiceSid(): string {
return $this->serviceSid;
}
/**
* Set the service sid of this grant
*
* @param string $serviceSid service sid of the grant
*
* @return $this updated grant
*/
public function setServiceSid(string $serviceSid): self {
$this->serviceSid = $serviceSid;
return $this;
}
/**
* Returns the endpoint id of the grant
*
* @return string the endpoint id
*/
public function getEndpointId(): string {
return $this->endpointId;
}
/**
* Set the endpoint id of the grant
*
* @param string $endpointId endpoint id of the grant
*
* @return $this updated grant
*/
public function setEndpointId(string $endpointId): self {
$this->endpointId = $endpointId;
return $this;
}
/**
* Returns the deployment role sid of the grant
*
* @return string the deployment role sid
*/
public function getDeploymentRoleSid(): string {
return $this->deploymentRoleSid;
}
/**
* Set the role sid of the grant
*
* @param string $deploymentRoleSid role sid of the grant
*
* @return $this updated grant
*/
public function setDeploymentRoleSid(string $deploymentRoleSid): self {
$this->deploymentRoleSid = $deploymentRoleSid;
return $this;
}
/**
* Returns the push credential sid of the grant
*
* @return string the push credential sid
*/
public function getPushCredentialSid(): string {
return $this->pushCredentialSid;
}
/**
* Set the credential sid of the grant
*
* @param string $pushCredentialSid push credential sid of the grant
*
* @return $this updated grant
*/
public function setPushCredentialSid(string $pushCredentialSid): self {
$this->pushCredentialSid = $pushCredentialSid;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'data_sync';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->serviceSid) {
$payload['service_sid'] = $this->serviceSid;
}
if ($this->endpointId) {
$payload['endpoint_id'] = $this->endpointId;
}
if ($this->deploymentRoleSid) {
$payload['deployment_role_sid'] = $this->deploymentRoleSid;
}
if ($this->pushCredentialSid) {
$payload['push_credential_sid'] = $this->pushCredentialSid;
}
return $payload;
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace Twilio\Jwt\Grants;
class TaskRouterGrant implements Grant {
private $workspaceSid;
private $workerSid;
private $role;
/**
* Returns the workspace sid
*
* @return string the workspace sid
*/
public function getWorkspaceSid(): string {
return $this->workspaceSid;
}
/**
* Set the workspace sid of this grant
*
* @param string $workspaceSid workspace sid of the grant
*
* @return $this updated grant
*/
public function setWorkspaceSid(string $workspaceSid): self {
$this->workspaceSid = $workspaceSid;
return $this;
}
/**
* Returns the worker sid
*
* @return string the worker sid
*/
public function getWorkerSid(): string {
return $this->workerSid;
}
/**
* Set the worker sid of this grant
*
* @param string $workerSid worker sid of the grant
*
* @return $this updated grant
*/
public function setWorkerSid(string $workerSid): self {
$this->workerSid = $workerSid;
return $this;
}
/**
* Returns the role
*
* @return string the role
*/
public function getRole(): string {
return $this->role;
}
/**
* Set the role of this grant
*
* @param string $role role of the grant
*
* @return $this updated grant
*/
public function setRole(string $role): self {
$this->role = $role;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'task_router';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->workspaceSid) {
$payload['workspace_sid'] = $this->workspaceSid;
}
if ($this->workerSid) {
$payload['worker_sid'] = $this->workerSid;
}
if ($this->role) {
$payload['role'] = $this->role;
}
return $payload;
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Twilio\Jwt\Grants;
class VideoGrant implements Grant {
private $room;
/**
* Returns the room
*
* @return string room name or sid set in this grant
*/
public function getRoom(): string {
return $this->room;
}
/**
* Set the room to allow access to in the grant
*
* @param string $roomSidOrName room sid or name
* @return $this updated grant
*/
public function setRoom(string $roomSidOrName): self {
$this->room = $roomSidOrName;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'video';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->room) {
$payload['room'] = $this->room;
}
return $payload;
}
}

View File

@@ -0,0 +1,165 @@
<?php
namespace Twilio\Jwt\Grants;
class VoiceGrant implements Grant {
private $incomingAllow;
private $outgoingApplicationSid;
private $outgoingApplicationParams;
private $pushCredentialSid;
private $endpointId;
/**
* Returns whether incoming is allowed
*
* @return bool whether incoming is allowed
*/
public function getIncomingAllow(): bool {
return $this->incomingAllow;
}
/**
* Set whether incoming is allowed
*
* @param bool $incomingAllow whether incoming is allowed
*
* @return $this updated grant
*/
public function setIncomingAllow(bool $incomingAllow): self {
$this->incomingAllow = $incomingAllow;
return $this;
}
/**
* Returns the outgoing application sid
*
* @return string the outgoing application sid
*/
public function getOutgoingApplicationSid(): string {
return $this->outgoingApplicationSid;
}
/**
* Set the outgoing application sid of the grant
*
* @param string $outgoingApplicationSid outgoing application sid of grant
*
* @return $this updated grant
*/
public function setOutgoingApplicationSid(string $outgoingApplicationSid): self {
$this->outgoingApplicationSid = $outgoingApplicationSid;
return $this;
}
/**
* Returns the outgoing application params
*
* @return array the outgoing application params
*/
public function getOutgoingApplicationParams(): array {
return $this->outgoingApplicationParams;
}
/**
* Set the outgoing application of the the grant
*
* @param string $sid outgoing application sid of the grant
* @param array $params params to pass the the application
*
* @return $this updated grant
*/
public function setOutgoingApplication(string $sid, array $params): self {
$this->outgoingApplicationSid = $sid;
$this->outgoingApplicationParams = $params;
return $this;
}
/**
* Returns the push credential sid
*
* @return string the push credential sid
*/
public function getPushCredentialSid(): string {
return $this->pushCredentialSid;
}
/**
* Set the push credential sid
*
* @param string $pushCredentialSid
*
* @return $this updated grant
*/
public function setPushCredentialSid(string $pushCredentialSid): self {
$this->pushCredentialSid = $pushCredentialSid;
return $this;
}
/**
* Returns the endpoint id
*
* @return string the endpoint id
*/
public function getEndpointId(): string {
return $this->endpointId;
}
/**
* Set the endpoint id
*
* @param string $endpointId endpoint id
*
* @return $this updated grant
*/
public function setEndpointId(string $endpointId): self {
$this->endpointId = $endpointId;
return $this;
}
/**
* Returns the grant type
*
* @return string type of the grant
*/
public function getGrantKey(): string {
return 'voice';
}
/**
* Returns the grant data
*
* @return array data of the grant
*/
public function getPayload(): array {
$payload = [];
if ($this->incomingAllow === true) {
$incoming = [];
$incoming['allow'] = true;
$payload['incoming'] = $incoming;
}
if ($this->outgoingApplicationSid) {
$outgoing = [];
$outgoing['application_sid'] = $this->outgoingApplicationSid;
if ($this->outgoingApplicationParams) {
$outgoing['params'] = $this->outgoingApplicationParams;
}
$payload['outgoing'] = $outgoing;
}
if ($this->pushCredentialSid) {
$payload['push_credential_sid'] = $this->pushCredentialSid;
}
if ($this->endpointId) {
$payload['endpoint_id'] = $this->endpointId;
}
return $payload;
}
}

172
vendor/twilio/sdk/src/Twilio/Jwt/JWT.php vendored Normal file
View File

@@ -0,0 +1,172 @@
<?php
namespace Twilio\Jwt;
/**
* JSON Web Token implementation
*
* Minimum implementation used by Realtime auth, based on this spec:
* http://self-issued.info/docs/draft-jones-json-web-token-01.html.
*
* @author Neuman Vong <neuman@twilio.com>
*/
class JWT {
/**
* @param string $jwt The JWT
* @param string|null $key The secret key
* @param bool $verify Don't skip verification process
* @return object The JWT's payload as a PHP object
* @throws \DomainException
* @throws \UnexpectedValueException
*/
public static function decode(string $jwt, string $key = null, bool $verify = true) {
$tks = \explode('.', $jwt);
if (\count($tks) !== 3) {
throw new \UnexpectedValueException('Wrong number of segments');
}
list($headb64, $payloadb64, $cryptob64) = $tks;
if (null === ($header = self::jsonDecode(self::urlsafeB64Decode($headb64)))
) {
throw new \UnexpectedValueException('Invalid segment encoding');
}
if (null === $payload = self::jsonDecode(self::urlsafeB64Decode($payloadb64))
) {
throw new \UnexpectedValueException('Invalid segment encoding');
}
$sig = self::urlsafeB64Decode($cryptob64);
if ($verify) {
if (empty($header->alg)) {
throw new \DomainException('Empty algorithm');
}
if (!hash_equals($sig, self::sign("$headb64.$payloadb64", $key, $header->alg))) {
throw new \UnexpectedValueException('Signature verification failed');
}
}
return $payload;
}
/**
* @param string $jwt The JWT
* @return object The JWT's header as a PHP object
* @throws \UnexpectedValueException
*/
public static function getHeader(string $jwt) {
$tks = \explode('.', $jwt);
if (\count($tks) !== 3) {
throw new \UnexpectedValueException('Wrong number of segments');
}
list($headb64) = $tks;
if (null === ($header = self::jsonDecode(self::urlsafeB64Decode($headb64)))
) {
throw new \UnexpectedValueException('Invalid segment encoding');
}
return $header;
}
/**
* @param object|array $payload PHP object or array
* @param string $key The secret key
* @param string $algo The signing algorithm
* @param array $additionalHeaders Additional keys/values to add to the header
*
* @return string A JWT
*/
public static function encode($payload, string $key, string $algo = 'HS256', array $additionalHeaders = []): string {
$header = ['typ' => 'JWT', 'alg' => $algo];
$header += $additionalHeaders;
$segments = [];
$segments[] = self::urlsafeB64Encode(self::jsonEncode($header));
$segments[] = self::urlsafeB64Encode(self::jsonEncode($payload));
$signing_input = \implode('.', $segments);
$signature = self::sign($signing_input, $key, $algo);
$segments[] = self::urlsafeB64Encode($signature);
return \implode('.', $segments);
}
/**
* @param string $msg The message to sign
* @param string $key The secret key
* @param string $method The signing algorithm
* @return string An encrypted message
* @throws \DomainException
*/
public static function sign(string $msg, string $key, string $method = 'HS256'): string {
$methods = [
'HS256' => 'sha256',
'HS384' => 'sha384',
'HS512' => 'sha512',
];
if (empty($methods[$method])) {
throw new \DomainException('Algorithm not supported');
}
return \hash_hmac($methods[$method], $msg, $key, true);
}
/**
* @param string $input JSON string
* @return object Object representation of JSON string
* @throws \DomainException
*/
public static function jsonDecode(string $input) {
$obj = \json_decode($input);
if (\function_exists('json_last_error') && $errno = \json_last_error()) {
self::handleJsonError($errno);
} else if ($obj === null && $input !== 'null') {
throw new \DomainException('Null result with non-null input');
}
return $obj;
}
/**
* @param object|array $input A PHP object or array
* @return string JSON representation of the PHP object or array
* @throws \DomainException
*/
public static function jsonEncode($input): string {
$json = \json_encode($input);
if (\function_exists('json_last_error') && $errno = \json_last_error()) {
self::handleJsonError($errno);
} else if ($json === 'null' && $input !== null) {
throw new \DomainException('Null result with non-null input');
}
return $json;
}
/**
* @param string $input A base64 encoded string
*
* @return string A decoded string
*/
public static function urlsafeB64Decode(string $input): string {
$padLen = 4 - \strlen($input) % 4;
$input .= \str_repeat('=', $padLen);
return \base64_decode(\strtr($input, '-_', '+/'));
}
/**
* @param string $input Anything really
*
* @return string The base64 encode of what you passed in
*/
public static function urlsafeB64Encode(string $input): string {
return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
}
/**
* @param int $errno An error number from json_last_error()
*
* @throws \DomainException
*/
private static function handleJsonError(int $errno): void {
$messages = [
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON'
];
throw new \DomainException($messages[$errno] ?? 'Unknown JSON error: ' . $errno);
}
}

View File

@@ -0,0 +1,161 @@
<?php
namespace Twilio\Jwt\TaskRouter;
use Twilio\Jwt\JWT;
/**
* Twilio TaskRouter Capability assigner
*
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class CapabilityToken {
protected $accountSid;
protected $authToken;
private $friendlyName;
/** @var Policy[] $policies */
private $policies;
protected $baseUrl = 'https://taskrouter.twilio.com/v1';
protected $baseWsUrl = 'https://event-bridge.twilio.com/v1/wschannels';
protected $version = 'v1';
protected $workspaceSid;
protected $channelId;
protected $resourceUrl;
protected $required = ['required' => true];
protected $optional = ['required' => false];
public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $channelId,
string $resourceUrl = null, string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
$this->accountSid = $accountSid;
$this->authToken = $authToken;
$this->friendlyName = $channelId;
$this->policies = [];
$this->workspaceSid = $workspaceSid;
$this->channelId = $channelId;
if (isset($overrideBaseUrl)) {
$this->baseUrl = $overrideBaseUrl;
}
if (isset($overrideBaseWSUrl)) {
$this->baseWsUrl = $overrideBaseWSUrl;
}
$this->baseUrl .= '/Workspaces/' . $workspaceSid;
$this->validateJWT();
if (!isset($resourceUrl)) {
$this->setupResource();
}
//add permissions to GET and POST to the event-bridge channel
$this->allow($this->baseWsUrl . '/' . $this->accountSid . '/' . $this->channelId, 'GET', null, null);
$this->allow($this->baseWsUrl . '/' . $this->accountSid . '/' . $this->channelId, 'POST', null, null);
//add permissions to fetch the instance resource
$this->allow($this->resourceUrl, 'GET', null, null);
}
protected function setupResource(): void {
}
public function addPolicyDeconstructed(string $url, string $method, ?array $queryFilter = [], ?array $postFilter = [], bool $allow = true): Policy {
$policy = new Policy($url, $method, $queryFilter, $postFilter, $allow);
$this->policies[] = $policy;
return $policy;
}
public function allow(string $url, string $method, ?array $queryFilter = [], ?array $postFilter = []): void {
$this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, true);
}
public function deny(string $url, string $method, array $queryFilter = [], array $postFilter = []): void {
$this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, false);
}
private function validateJWT(): void {
if (!isset($this->accountSid) || \strpos($this->accountSid, 'AC') !== 0) {
throw new \Exception('Invalid AccountSid provided: ' . $this->accountSid);
}
if (!isset($this->workspaceSid) || \strpos($this->workspaceSid, 'WS') !== 0) {
throw new \Exception('Invalid WorkspaceSid provided: ' . $this->workspaceSid);
}
if (!isset($this->channelId)) {
throw new \Exception('ChannelId not provided');
}
$prefix = \substr($this->channelId, 0, 2);
if ($prefix !== 'WS' && $prefix !== 'WK' && $prefix !== 'WQ') {
throw new \Exception("Invalid ChannelId provided: " . $this->channelId);
}
}
public function allowFetchSubresources(): void {
$method = 'GET';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
}
public function allowUpdates(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
}
public function allowUpdatesSubresources(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
}
public function allowDelete(): void {
$method = 'DELETE';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
}
public function allowDeleteSubresources(): void {
$method = 'DELETE';
$queryFilter = [];
$postFilter = [];
$this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter);
}
public function generateToken(int $ttl = 3600, array $extraAttributes = []): string {
$payload = [
'version' => $this->version,
'friendly_name' => $this->friendlyName,
'iss' => $this->accountSid,
'exp' => \time() + $ttl,
'account_sid' => $this->accountSid,
'channel' => $this->channelId,
'workspace_sid' => $this->workspaceSid
];
if (\strpos($this->channelId, 'WK') === 0) {
$payload['worker_sid'] = $this->channelId;
} else if (\strpos($this->channelId, 'WQ') === 0) {
$payload['taskqueue_sid'] = $this->channelId;
}
foreach ($extraAttributes as $key => $value) {
$payload[$key] = $value;
}
$policyStrings = [];
foreach ($this->policies as $policy) {
$policyStrings[] = $policy->toArray();
}
$payload['policies'] = $policyStrings;
return JWT::encode($payload, $this->authToken, 'HS256');
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Twilio\Jwt\TaskRouter;
/**
* Twilio API Policy constructor
*
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class Policy {
private $url;
private $method;
private $queryFilter;
private $postFilter;
private $allow;
public function __construct(string $url, string $method, ?array $queryFilter = [], ?array $postFilter = [], bool $allow = true) {
$this->url = $url;
$this->method = $method;
$this->queryFilter = $queryFilter;
$this->postFilter = $postFilter;
$this->allow = $allow;
}
public function addQueryFilter($queryFilter): void {
$this->queryFilter[] = $queryFilter;
}
public function addPostFilter($postFilter): void {
$this->postFilter[] = $postFilter;
}
public function toArray(): array {
$policy_array = ['url' => $this->url, 'method' => $this->method, 'allow' => $this->allow];
if ($this->queryFilter !== null) {
if (\count($this->queryFilter) > 0) {
$policy_array['query_filter'] = $this->queryFilter;
} else {
$policy_array['query_filter'] = new \stdClass();
}
}
if ($this->postFilter !== null) {
if (\count($this->postFilter) > 0) {
$policy_array['post_filter'] = $this->postFilter;
} else {
$policy_array['post_filter'] = new \stdClass();
}
}
return $policy_array;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Twilio\Jwt\TaskRouter;
/**
* Twilio TaskRouter TaskQueue Capability assigner
*
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class TaskQueueCapability extends CapabilityToken {
public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $taskQueueSid,
string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
}
protected function setupResource(): void {
$this->resourceUrl = $this->baseUrl . '/TaskQueues/' . $this->channelId;
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace Twilio\Jwt\TaskRouter;
/**
* Twilio TaskRouter Worker Capability assigner
*
* @author Justin Witz <justin.witz@twilio.com>
* @license http://creativecommons.org/licenses/MIT/ MIT
*/
class WorkerCapability extends CapabilityToken {
private $tasksUrl;
private $workerReservationsUrl;
private $activityUrl;
public function __construct(string $accountSid, string $authToken, string $workspaceSid, string $workerSid,
string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $workerSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
$this->tasksUrl = $this->baseUrl . '/Tasks/**';
$this->activityUrl = $this->baseUrl . '/Activities';
$this->workerReservationsUrl = $this->resourceUrl . '/Reservations/**';
//add permissions to fetch the list of activities, tasks, and worker reservations
$this->allow($this->activityUrl, 'GET', null, null);
$this->allow($this->tasksUrl, 'GET', null, null);
$this->allow($this->workerReservationsUrl, 'GET', null, null);
}
protected function setupResource(): void {
$this->resourceUrl = $this->baseUrl . '/Workers/' . $this->channelId;
}
public function allowActivityUpdates(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = ['ActivitySid' => $this->required];
$this->allow($this->resourceUrl, $method, $queryFilter, $postFilter);
}
public function allowReservationUpdates(): void {
$method = 'POST';
$queryFilter = [];
$postFilter = [];
$this->allow($this->tasksUrl, $method, $queryFilter, $postFilter);
$this->allow($this->workerReservationsUrl, $method, $queryFilter, $postFilter);
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Twilio\Jwt\TaskRouter;
class WorkspaceCapability extends CapabilityToken {
public function __construct(string $accountSid, string $authToken, string $workspaceSid,
string $overrideBaseUrl = null, string $overrideBaseWSUrl = null) {
parent::__construct($accountSid, $authToken, $workspaceSid, $workspaceSid, null, $overrideBaseUrl, $overrideBaseWSUrl);
}
protected function setupResource(): void {
$this->resourceUrl = $this->baseUrl;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Twilio;
class ListResource {
protected $version;
protected $solution = [];
protected $uri;
public function __construct(Version $version) {
$this->version = $version;
}
public function __toString(): string {
return '[ListResource]';
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Twilio;
abstract class Options implements \IteratorAggregate {
protected $options = [];
public function getIterator(): \Traversable {
return new \ArrayIterator($this->options);
}
}

195
vendor/twilio/sdk/src/Twilio/Page.php vendored Normal file
View File

@@ -0,0 +1,195 @@
<?php
namespace Twilio;
use Twilio\Exceptions\DeserializeException;
use Twilio\Exceptions\RestException;
use Twilio\Http\Response;
abstract class Page implements \Iterator {
protected static $metaKeys = [
'end',
'first_page_uri',
'next_page_uri',
'last_page_uri',
'page',
'page_size',
'previous_page_uri',
'total',
'num_pages',
'start',
'uri',
];
protected $version;
protected $payload;
protected $solution;
protected $records;
abstract public function buildInstance(array $payload);
public function __construct(Version $version, Response $response) {
$payload = $this->processResponse($response);
$this->version = $version;
$this->payload = $payload;
$this->solution = [];
$this->records = new \ArrayIterator($this->loadPage());
}
protected function processResponse(Response $response) {
if ($response->getStatusCode() !== 200 && !$this->isPagingEol($response->getContent())) {
$message = '[HTTP ' . $response->getStatusCode() . '] Unable to fetch page';
$code = $response->getStatusCode();
$content = $response->getContent();
$details = [];
$moreInfo = '';
if (\is_array($content)) {
$message .= isset($content['message']) ? ': ' . $content['message'] : '';
$code = $content['code'] ?? $code;
$moreInfo = $content['more_info'] ?? '';
$details = $content['details'] ?? [] ;
}
throw new RestException($message, $code, $response->getStatusCode(), $moreInfo, $details);
}
return $response->getContent();
}
protected function isPagingEol(?array $content): bool {
return $content !== null && \array_key_exists('code', $content) && $content['code'] === 20006;
}
protected function hasMeta(string $key): bool {
return \array_key_exists('meta', $this->payload) && \array_key_exists($key, $this->payload['meta']);
}
protected function getMeta(string $key, string $default = null): ?string {
return $this->hasMeta($key) ? $this->payload['meta'][$key] : $default;
}
protected function loadPage(): array {
$key = $this->getMeta('key');
if ($key) {
return $this->payload[$key];
}
$keys = \array_keys($this->payload);
$key = \array_diff($keys, self::$metaKeys);
$key = \array_values($key);
if (\count($key) === 1) {
return $this->payload[$key[0]];
}
// handle end of results error code
if ($this->isPagingEol($this->payload)) {
return [];
}
throw new DeserializeException('Page Records can not be deserialized');
}
public function getPreviousPageUrl(): ?string {
if ($this->hasMeta('previous_page_url')) {
return $this->getMeta('previous_page_url');
} else if (\array_key_exists('previous_page_uri', $this->payload) && $this->payload['previous_page_uri']) {
return $this->getVersion()->getDomain()->absoluteUrl($this->payload['previous_page_uri']);
}
return null;
}
public function getNextPageUrl(): ?string {
if ($this->hasMeta('next_page_url')) {
return $this->getMeta('next_page_url');
} else if (\array_key_exists('next_page_uri', $this->payload) && $this->payload['next_page_uri']) {
return $this->getVersion()->getDomain()->absoluteUrl($this->payload['next_page_uri']);
}
return null;
}
public function nextPage(): ?Page {
if (!$this->getNextPageUrl()) {
return null;
}
$response = $this->getVersion()->getDomain()->getClient()->request('GET', $this->getNextPageUrl());
return new static($this->getVersion(), $response, $this->solution);
}
public function previousPage(): ?Page {
if (!$this->getPreviousPageUrl()) {
return null;
}
$response = $this->getVersion()->getDomain()->getClient()->request('GET', $this->getPreviousPageUrl());
return new static($this->getVersion(), $response, $this->solution);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
*/
#[\ReturnTypeWillChange]
public function current() {
return $this->buildInstance($this->records->current());
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
*/
public function next(): void {
$this->records->next();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
#[\ReturnTypeWillChange]
public function key() {
return $this->records->key();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return bool The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
public function valid(): bool {
return $this->records->valid();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
public function rewind(): void {
$this->records->rewind();
}
public function getVersion(): Version {
return $this->version;
}
public function __toString(): string {
return '[Page]';
}
}

View File

@@ -0,0 +1,109 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\Rest\Accounts\V1;
/**
* @property \Twilio\Rest\Accounts\V1 $v1
* @property \Twilio\Rest\Accounts\V1\AuthTokenPromotionList $authTokenPromotion
* @property \Twilio\Rest\Accounts\V1\CredentialList $credentials
* @property \Twilio\Rest\Accounts\V1\SecondaryAuthTokenList $secondaryAuthToken
* @method \Twilio\Rest\Accounts\V1\AuthTokenPromotionContext authTokenPromotion()
* @method \Twilio\Rest\Accounts\V1\SecondaryAuthTokenContext secondaryAuthToken()
*/
class Accounts extends Domain {
protected $_v1;
/**
* Construct the Accounts Domain
*
* @param Client $client Client to communicate with Twilio
*/
public function __construct(Client $client) {
parent::__construct($client);
$this->baseUrl = 'https://accounts.twilio.com';
}
/**
* @return V1 Version v1 of accounts
*/
protected function getV1(): V1 {
if (!$this->_v1) {
$this->_v1 = new V1($this);
}
return $this->_v1;
}
/**
* Magic getter to lazy load version
*
* @param string $name Version to return
* @return \Twilio\Version The requested version
* @throws TwilioException For unknown versions
*/
public function __get(string $name) {
$method = 'get' . \ucfirst($name);
if (\method_exists($this, $method)) {
return $this->$method();
}
throw new TwilioException('Unknown version ' . $name);
}
/**
* Magic caller to get resource contexts
*
* @param string $name Resource to return
* @param array $arguments Context parameters
* @return \Twilio\InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments) {
$method = 'context' . \ucfirst($name);
if (\method_exists($this, $method)) {
return \call_user_func_array([$this, $method], $arguments);
}
throw new TwilioException('Unknown context ' . $name);
}
protected function getAuthTokenPromotion(): \Twilio\Rest\Accounts\V1\AuthTokenPromotionList {
return $this->v1->authTokenPromotion;
}
protected function contextAuthTokenPromotion(): \Twilio\Rest\Accounts\V1\AuthTokenPromotionContext {
return $this->v1->authTokenPromotion();
}
protected function getCredentials(): \Twilio\Rest\Accounts\V1\CredentialList {
return $this->v1->credentials;
}
protected function getSecondaryAuthToken(): \Twilio\Rest\Accounts\V1\SecondaryAuthTokenList {
return $this->v1->secondaryAuthToken;
}
protected function contextSecondaryAuthToken(): \Twilio\Rest\Accounts\V1\SecondaryAuthTokenContext {
return $this->v1->secondaryAuthToken();
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts]';
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\Accounts\V1\AuthTokenPromotionList;
use Twilio\Rest\Accounts\V1\CredentialList;
use Twilio\Rest\Accounts\V1\SecondaryAuthTokenList;
use Twilio\Version;
/**
* @property AuthTokenPromotionList $authTokenPromotion
* @property CredentialList $credentials
* @property SecondaryAuthTokenList $secondaryAuthToken
*/
class V1 extends Version {
protected $_authTokenPromotion;
protected $_credentials;
protected $_secondaryAuthToken;
/**
* Construct the V1 version of Accounts
*
* @param Domain $domain Domain that contains the version
*/
public function __construct(Domain $domain) {
parent::__construct($domain);
$this->version = 'v1';
}
protected function getAuthTokenPromotion(): AuthTokenPromotionList {
if (!$this->_authTokenPromotion) {
$this->_authTokenPromotion = new AuthTokenPromotionList($this);
}
return $this->_authTokenPromotion;
}
protected function getCredentials(): CredentialList {
if (!$this->_credentials) {
$this->_credentials = new CredentialList($this);
}
return $this->_credentials;
}
protected function getSecondaryAuthToken(): SecondaryAuthTokenList {
if (!$this->_secondaryAuthToken) {
$this->_secondaryAuthToken = new SecondaryAuthTokenList($this);
}
return $this->_secondaryAuthToken;
}
/**
* 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.Accounts.V1]';
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Values;
use Twilio\Version;
class AuthTokenPromotionContext extends InstanceContext {
/**
* Initialize the AuthTokenPromotionContext
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
$this->uri = '/AuthTokens/Promote';
}
/**
* Update the AuthTokenPromotionInstance
*
* @return AuthTokenPromotionInstance Updated AuthTokenPromotionInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(): AuthTokenPromotionInstance {
$payload = $this->version->update('POST', $this->uri);
return new AuthTokenPromotionInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AuthTokenPromotionContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,103 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $accountSid
* @property string $authToken
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $url
*/
class AuthTokenPromotionInstance extends InstanceResource {
/**
* Initialize the AuthTokenPromotionInstance
*
* @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 = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'authToken' => Values::array_get($payload, 'auth_token'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'url' => Values::array_get($payload, 'url'),
];
$this->solution = [];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return AuthTokenPromotionContext Context for this AuthTokenPromotionInstance
*/
protected function proxy(): AuthTokenPromotionContext {
if (!$this->context) {
$this->context = new AuthTokenPromotionContext($this->version);
}
return $this->context;
}
/**
* Update the AuthTokenPromotionInstance
*
* @return AuthTokenPromotionInstance Updated AuthTokenPromotionInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(): AuthTokenPromotionInstance {
return $this->proxy()->update();
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AuthTokenPromotionInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\ListResource;
use Twilio\Version;
class AuthTokenPromotionList extends ListResource {
/**
* Construct the AuthTokenPromotionList
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
}
/**
* Constructs a AuthTokenPromotionContext
*/
public function getContext(): AuthTokenPromotionContext {
return new AuthTokenPromotionContext($this->version);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.AuthTokenPromotionList]';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class AuthTokenPromotionPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return AuthTokenPromotionInstance \Twilio\Rest\Accounts\V1\AuthTokenPromotionInstance
*/
public function buildInstance(array $payload): AuthTokenPromotionInstance {
return new AuthTokenPromotionInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.AuthTokenPromotionPage]';
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
class AwsContext extends InstanceContext {
/**
* Initialize the AwsContext
*
* @param Version $version Version that contains the resource
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, $sid) {
parent::__construct($version);
// Path Solution
$this->solution = ['sid' => $sid, ];
$this->uri = '/Credentials/AWS/' . \rawurlencode($sid) . '';
}
/**
* Fetch the AwsInstance
*
* @return AwsInstance Fetched AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AwsInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new AwsInstance($this->version, $payload, $this->solution['sid']);
}
/**
* Update the AwsInstance
*
* @param array|Options $options Optional Arguments
* @return AwsInstance Updated AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AwsInstance {
$options = new Values($options);
$data = Values::of(['FriendlyName' => $options['friendlyName'], ]);
$payload = $this->version->update('POST', $this->uri, [], $data);
return new AwsInstance($this->version, $payload, $this->solution['sid']);
}
/**
* Delete the AwsInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->version->delete('DELETE', $this->uri);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AwsContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $sid
* @property string $accountSid
* @property string $friendlyName
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $url
*/
class AwsInstance extends InstanceResource {
/**
* Initialize the AwsInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, array $payload, string $sid = null) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'accountSid' => Values::array_get($payload, 'account_sid'),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'url' => Values::array_get($payload, 'url'),
];
$this->solution = ['sid' => $sid ?: $this->properties['sid'], ];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return AwsContext Context for this AwsInstance
*/
protected function proxy(): AwsContext {
if (!$this->context) {
$this->context = new AwsContext($this->version, $this->solution['sid']);
}
return $this->context;
}
/**
* Fetch the AwsInstance
*
* @return AwsInstance Fetched AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AwsInstance {
return $this->proxy()->fetch();
}
/**
* Update the AwsInstance
*
* @param array|Options $options Optional Arguments
* @return AwsInstance Updated AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AwsInstance {
return $this->proxy()->update($options);
}
/**
* Delete the AwsInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->proxy()->delete();
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.AwsInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,153 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class AwsList extends ListResource {
/**
* Construct the AwsList
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
$this->uri = '/Credentials/AWS';
}
/**
* Streams AwsInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads AwsInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return AwsInstance[] Array of results
*/
public function read(int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Retrieve a single page of AwsInstance records from the API.
* Request is executed immediately
*
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return AwsPage Page of AwsInstance
*/
public function page($pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): AwsPage {
$params = Values::of(['PageToken' => $pageToken, 'Page' => $pageNumber, 'PageSize' => $pageSize, ]);
$response = $this->version->page('GET', $this->uri, $params);
return new AwsPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of AwsInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return AwsPage Page of AwsInstance
*/
public function getPage(string $targetUrl): AwsPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new AwsPage($this->version, $response, $this->solution);
}
/**
* Create the AwsInstance
*
* @param string $credentials A string that contains the AWS access credentials
* in the format
* <AWS_ACCESS_KEY_ID>:<AWS_SECRET_ACCESS_KEY>
* @param array|Options $options Optional Arguments
* @return AwsInstance Created AwsInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $credentials, array $options = []): AwsInstance {
$options = new Values($options);
$data = Values::of([
'Credentials' => $credentials,
'FriendlyName' => $options['friendlyName'],
'AccountSid' => $options['accountSid'],
]);
$payload = $this->version->create('POST', $this->uri, [], $data);
return new AwsInstance($this->version, $payload);
}
/**
* Constructs a AwsContext
*
* @param string $sid The unique string that identifies the resource
*/
public function getContext(string $sid): AwsContext {
return new AwsContext($this->version, $sid);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.AwsList]';
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Options;
use Twilio\Values;
abstract class AwsOptions {
/**
* @param string $friendlyName A string to describe the resource
* @param string $accountSid The Subaccount this Credential should be
* associated with.
* @return CreateAwsOptions Options builder
*/
public static function create(string $friendlyName = Values::NONE, string $accountSid = Values::NONE): CreateAwsOptions {
return new CreateAwsOptions($friendlyName, $accountSid);
}
/**
* @param string $friendlyName A string to describe the resource
* @return UpdateAwsOptions Options builder
*/
public static function update(string $friendlyName = Values::NONE): UpdateAwsOptions {
return new UpdateAwsOptions($friendlyName);
}
}
class CreateAwsOptions extends Options {
/**
* @param string $friendlyName A string to describe the resource
* @param string $accountSid The Subaccount this Credential should be
* associated with.
*/
public function __construct(string $friendlyName = Values::NONE, string $accountSid = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
$this->options['accountSid'] = $accountSid;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request.
*
* @param string $accountSid The Subaccount this Credential should be
* associated with.
* @return $this Fluent Builder
*/
public function setAccountSid(string $accountSid): self {
$this->options['accountSid'] = $accountSid;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.CreateAwsOptions ' . $options . ']';
}
}
class UpdateAwsOptions extends Options {
/**
* @param string $friendlyName A string to describe the resource
*/
public function __construct(string $friendlyName = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.UpdateAwsOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class AwsPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return AwsInstance \Twilio\Rest\Accounts\V1\Credential\AwsInstance
*/
public function buildInstance(array $payload): AwsInstance {
return new AwsInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.AwsPage]';
}
}

View File

@@ -0,0 +1,85 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
class PublicKeyContext extends InstanceContext {
/**
* Initialize the PublicKeyContext
*
* @param Version $version Version that contains the resource
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, $sid) {
parent::__construct($version);
// Path Solution
$this->solution = ['sid' => $sid, ];
$this->uri = '/Credentials/PublicKeys/' . \rawurlencode($sid) . '';
}
/**
* Fetch the PublicKeyInstance
*
* @return PublicKeyInstance Fetched PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): PublicKeyInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new PublicKeyInstance($this->version, $payload, $this->solution['sid']);
}
/**
* Update the PublicKeyInstance
*
* @param array|Options $options Optional Arguments
* @return PublicKeyInstance Updated PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): PublicKeyInstance {
$options = new Values($options);
$data = Values::of(['FriendlyName' => $options['friendlyName'], ]);
$payload = $this->version->update('POST', $this->uri, [], $data);
return new PublicKeyInstance($this->version, $payload, $this->solution['sid']);
}
/**
* Delete the PublicKeyInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->version->delete('DELETE', $this->uri);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.PublicKeyContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $sid
* @property string $accountSid
* @property string $friendlyName
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $url
*/
class PublicKeyInstance extends InstanceResource {
/**
* Initialize the PublicKeyInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, array $payload, string $sid = null) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'accountSid' => Values::array_get($payload, 'account_sid'),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'url' => Values::array_get($payload, 'url'),
];
$this->solution = ['sid' => $sid ?: $this->properties['sid'], ];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return PublicKeyContext Context for this PublicKeyInstance
*/
protected function proxy(): PublicKeyContext {
if (!$this->context) {
$this->context = new PublicKeyContext($this->version, $this->solution['sid']);
}
return $this->context;
}
/**
* Fetch the PublicKeyInstance
*
* @return PublicKeyInstance Fetched PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): PublicKeyInstance {
return $this->proxy()->fetch();
}
/**
* Update the PublicKeyInstance
*
* @param array|Options $options Optional Arguments
* @return PublicKeyInstance Updated PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): PublicKeyInstance {
return $this->proxy()->update($options);
}
/**
* Delete the PublicKeyInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->proxy()->delete();
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.PublicKeyInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,151 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class PublicKeyList extends ListResource {
/**
* Construct the PublicKeyList
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
$this->uri = '/Credentials/PublicKeys';
}
/**
* Streams PublicKeyInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads PublicKeyInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return PublicKeyInstance[] Array of results
*/
public function read(int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Retrieve a single page of PublicKeyInstance records from the API.
* Request is executed immediately
*
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return PublicKeyPage Page of PublicKeyInstance
*/
public function page($pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): PublicKeyPage {
$params = Values::of(['PageToken' => $pageToken, 'Page' => $pageNumber, 'PageSize' => $pageSize, ]);
$response = $this->version->page('GET', $this->uri, $params);
return new PublicKeyPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of PublicKeyInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return PublicKeyPage Page of PublicKeyInstance
*/
public function getPage(string $targetUrl): PublicKeyPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new PublicKeyPage($this->version, $response, $this->solution);
}
/**
* Create the PublicKeyInstance
*
* @param string $publicKey A URL encoded representation of the public key
* @param array|Options $options Optional Arguments
* @return PublicKeyInstance Created PublicKeyInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $publicKey, array $options = []): PublicKeyInstance {
$options = new Values($options);
$data = Values::of([
'PublicKey' => $publicKey,
'FriendlyName' => $options['friendlyName'],
'AccountSid' => $options['accountSid'],
]);
$payload = $this->version->create('POST', $this->uri, [], $data);
return new PublicKeyInstance($this->version, $payload);
}
/**
* Constructs a PublicKeyContext
*
* @param string $sid The unique string that identifies the resource
*/
public function getContext(string $sid): PublicKeyContext {
return new PublicKeyContext($this->version, $sid);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.PublicKeyList]';
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Options;
use Twilio\Values;
abstract class PublicKeyOptions {
/**
* @param string $friendlyName A string to describe the resource
* @param string $accountSid The Subaccount this Credential should be
* associated with.
* @return CreatePublicKeyOptions Options builder
*/
public static function create(string $friendlyName = Values::NONE, string $accountSid = Values::NONE): CreatePublicKeyOptions {
return new CreatePublicKeyOptions($friendlyName, $accountSid);
}
/**
* @param string $friendlyName A string to describe the resource
* @return UpdatePublicKeyOptions Options builder
*/
public static function update(string $friendlyName = Values::NONE): UpdatePublicKeyOptions {
return new UpdatePublicKeyOptions($friendlyName);
}
}
class CreatePublicKeyOptions extends Options {
/**
* @param string $friendlyName A string to describe the resource
* @param string $accountSid The Subaccount this Credential should be
* associated with.
*/
public function __construct(string $friendlyName = Values::NONE, string $accountSid = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
$this->options['accountSid'] = $accountSid;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The SID of the Subaccount that this Credential should be associated with. Must be a valid Subaccount of the account issuing the request
*
* @param string $accountSid The Subaccount this Credential should be
* associated with.
* @return $this Fluent Builder
*/
public function setAccountSid(string $accountSid): self {
$this->options['accountSid'] = $accountSid;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.CreatePublicKeyOptions ' . $options . ']';
}
}
class UpdatePublicKeyOptions extends Options {
/**
* @param string $friendlyName A string to describe the resource
*/
public function __construct(string $friendlyName = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Accounts.V1.UpdatePublicKeyOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1\Credential;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class PublicKeyPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return PublicKeyInstance \Twilio\Rest\Accounts\V1\Credential\PublicKeyInstance
*/
public function buildInstance(array $payload): PublicKeyInstance {
return new PublicKeyInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.PublicKeyPage]';
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
class CredentialInstance extends InstanceResource {
/**
* Initialize the CredentialInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
*/
public function __construct(Version $version, array $payload) {
parent::__construct($version);
$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.Accounts.V1.CredentialInstance]';
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\ListResource;
use Twilio\Rest\Accounts\V1\Credential\AwsList;
use Twilio\Rest\Accounts\V1\Credential\PublicKeyList;
use Twilio\Version;
/**
* @property PublicKeyList $publicKey
* @property AwsList $aws
* @method \Twilio\Rest\Accounts\V1\Credential\PublicKeyContext publicKey(string $sid)
* @method \Twilio\Rest\Accounts\V1\Credential\AwsContext aws(string $sid)
*/
class CredentialList extends ListResource {
protected $_publicKey = null;
protected $_aws = null;
/**
* Construct the CredentialList
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
}
/**
* Access the publicKey
*/
protected function getPublicKey(): PublicKeyList {
if (!$this->_publicKey) {
$this->_publicKey = new PublicKeyList($this->version);
}
return $this->_publicKey;
}
/**
* Access the aws
*/
protected function getAws(): AwsList {
if (!$this->_aws) {
$this->_aws = new AwsList($this->version);
}
return $this->_aws;
}
/**
* Magic getter to lazy load subresources
*
* @param string $name Subresource to return
* @return \Twilio\ListResource The requested subresource
* @throws TwilioException For unknown subresources
*/
public function __get(string $name) {
if (\property_exists($this, '_' . $name)) {
$method = 'get' . \ucfirst($name);
return $this->$method();
}
throw new TwilioException('Unknown subresource ' . $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.Accounts.V1.CredentialList]';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class CredentialPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return CredentialInstance \Twilio\Rest\Accounts\V1\CredentialInstance
*/
public function buildInstance(array $payload): CredentialInstance {
return new CredentialInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.CredentialPage]';
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Values;
use Twilio\Version;
class SecondaryAuthTokenContext extends InstanceContext {
/**
* Initialize the SecondaryAuthTokenContext
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
$this->uri = '/AuthTokens/Secondary';
}
/**
* Create the SecondaryAuthTokenInstance
*
* @return SecondaryAuthTokenInstance Created SecondaryAuthTokenInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(): SecondaryAuthTokenInstance {
$payload = $this->version->create('POST', $this->uri);
return new SecondaryAuthTokenInstance($this->version, $payload);
}
/**
* Delete the SecondaryAuthTokenInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->version->delete('DELETE', $this->uri);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.SecondaryAuthTokenContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $accountSid
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $secondaryAuthToken
* @property string $url
*/
class SecondaryAuthTokenInstance extends InstanceResource {
/**
* Initialize the SecondaryAuthTokenInstance
*
* @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 = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'secondaryAuthToken' => Values::array_get($payload, 'secondary_auth_token'),
'url' => Values::array_get($payload, 'url'),
];
$this->solution = [];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return SecondaryAuthTokenContext Context for this SecondaryAuthTokenInstance
*/
protected function proxy(): SecondaryAuthTokenContext {
if (!$this->context) {
$this->context = new SecondaryAuthTokenContext($this->version);
}
return $this->context;
}
/**
* Create the SecondaryAuthTokenInstance
*
* @return SecondaryAuthTokenInstance Created SecondaryAuthTokenInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(): SecondaryAuthTokenInstance {
return $this->proxy()->create();
}
/**
* Delete the SecondaryAuthTokenInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->proxy()->delete();
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Accounts.V1.SecondaryAuthTokenInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\ListResource;
use Twilio\Version;
class SecondaryAuthTokenList extends ListResource {
/**
* Construct the SecondaryAuthTokenList
*
* @param Version $version Version that contains the resource
*/
public function __construct(Version $version) {
parent::__construct($version);
// Path Solution
$this->solution = [];
}
/**
* Constructs a SecondaryAuthTokenContext
*/
public function getContext(): SecondaryAuthTokenContext {
return new SecondaryAuthTokenContext($this->version);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.SecondaryAuthTokenList]';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Accounts\V1;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class SecondaryAuthTokenPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return SecondaryAuthTokenInstance \Twilio\Rest\Accounts\V1\SecondaryAuthTokenInstance
*/
public function buildInstance(array $payload): SecondaryAuthTokenInstance {
return new SecondaryAuthTokenInstance($this->version, $payload);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Accounts.V1.SecondaryAuthTokenPage]';
}
}

View File

@@ -0,0 +1,363 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\Rest\Api\V2010;
/**
* @property \Twilio\Rest\Api\V2010 $v2010
* @property \Twilio\Rest\Api\V2010\AccountList $accounts
* @property \Twilio\Rest\Api\V2010\AccountContext $account
* @property \Twilio\Rest\Api\V2010\Account\AddressList $addresses
* @property \Twilio\Rest\Api\V2010\Account\ApplicationList $applications
* @property \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList $authorizedConnectApps
* @property \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList $availablePhoneNumbers
* @property \Twilio\Rest\Api\V2010\Account\BalanceList $balance
* @property \Twilio\Rest\Api\V2010\Account\CallList $calls
* @property \Twilio\Rest\Api\V2010\Account\ConferenceList $conferences
* @property \Twilio\Rest\Api\V2010\Account\ConnectAppList $connectApps
* @property \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList $incomingPhoneNumbers
* @property \Twilio\Rest\Api\V2010\Account\KeyList $keys
* @property \Twilio\Rest\Api\V2010\Account\MessageList $messages
* @property \Twilio\Rest\Api\V2010\Account\NewKeyList $newKeys
* @property \Twilio\Rest\Api\V2010\Account\NewSigningKeyList $newSigningKeys
* @property \Twilio\Rest\Api\V2010\Account\NotificationList $notifications
* @property \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList $outgoingCallerIds
* @property \Twilio\Rest\Api\V2010\Account\QueueList $queues
* @property \Twilio\Rest\Api\V2010\Account\RecordingList $recordings
* @property \Twilio\Rest\Api\V2010\Account\SigningKeyList $signingKeys
* @property \Twilio\Rest\Api\V2010\Account\SipList $sip
* @property \Twilio\Rest\Api\V2010\Account\ShortCodeList $shortCodes
* @property \Twilio\Rest\Api\V2010\Account\TokenList $tokens
* @property \Twilio\Rest\Api\V2010\Account\TranscriptionList $transcriptions
* @property \Twilio\Rest\Api\V2010\Account\UsageList $usage
* @property \Twilio\Rest\Api\V2010\Account\ValidationRequestList $validationRequests
* @method \Twilio\Rest\Api\V2010\Account\AddressContext addresses(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ApplicationContext applications(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext authorizedConnectApps(string $connectAppSid)
* @method \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext availablePhoneNumbers(string $countryCode)
* @method \Twilio\Rest\Api\V2010\Account\CallContext calls(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ConferenceContext conferences(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ConnectAppContext connectApps(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext incomingPhoneNumbers(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\KeyContext keys(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\MessageContext messages(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\NotificationContext notifications(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext outgoingCallerIds(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\QueueContext queues(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\RecordingContext recordings(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\SigningKeyContext signingKeys(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ShortCodeContext shortCodes(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\TranscriptionContext transcriptions(string $sid)
* @method \Twilio\Rest\Api\V2010\AccountContext accounts(string $sid)
*/
class Api extends Domain {
protected $_v2010;
/**
* Construct the Api Domain
*
* @param Client $client Client to communicate with Twilio
*/
public function __construct(Client $client) {
parent::__construct($client);
$this->baseUrl = 'https://api.twilio.com';
}
/**
* @return V2010 Version v2010 of api
*/
protected function getV2010(): V2010 {
if (!$this->_v2010) {
$this->_v2010 = new V2010($this);
}
return $this->_v2010;
}
/**
* Magic getter to lazy load version
*
* @param string $name Version to return
* @return \Twilio\Version The requested version
* @throws TwilioException For unknown versions
*/
public function __get(string $name) {
$method = 'get' . \ucfirst($name);
if (\method_exists($this, $method)) {
return $this->$method();
}
throw new TwilioException('Unknown version ' . $name);
}
/**
* Magic caller to get resource contexts
*
* @param string $name Resource to return
* @param array $arguments Context parameters
* @return \Twilio\InstanceContext The requested resource context
* @throws TwilioException For unknown resource
*/
public function __call(string $name, array $arguments) {
$method = 'context' . \ucfirst($name);
if (\method_exists($this, $method)) {
return \call_user_func_array([$this, $method], $arguments);
}
throw new TwilioException('Unknown context ' . $name);
}
/**
* @return \Twilio\Rest\Api\V2010\AccountContext Account provided as the
* authenticating account
*/
protected function getAccount(): \Twilio\Rest\Api\V2010\AccountContext {
return $this->v2010->account;
}
protected function getAccounts(): \Twilio\Rest\Api\V2010\AccountList {
return $this->v2010->accounts;
}
/**
* @param string $sid Fetch by unique Account Sid
*/
protected function contextAccounts(string $sid): \Twilio\Rest\Api\V2010\AccountContext {
return $this->v2010->accounts($sid);
}
protected function getAddresses(): \Twilio\Rest\Api\V2010\Account\AddressList {
return $this->v2010->account->addresses;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextAddresses(string $sid): \Twilio\Rest\Api\V2010\Account\AddressContext {
return $this->v2010->account->addresses($sid);
}
protected function getApplications(): \Twilio\Rest\Api\V2010\Account\ApplicationList {
return $this->v2010->account->applications;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextApplications(string $sid): \Twilio\Rest\Api\V2010\Account\ApplicationContext {
return $this->v2010->account->applications($sid);
}
protected function getAuthorizedConnectApps(): \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList {
return $this->v2010->account->authorizedConnectApps;
}
/**
* @param string $connectAppSid The SID of the Connect App to fetch
*/
protected function contextAuthorizedConnectApps(string $connectAppSid): \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext {
return $this->v2010->account->authorizedConnectApps($connectAppSid);
}
protected function getAvailablePhoneNumbers(): \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList {
return $this->v2010->account->availablePhoneNumbers;
}
/**
* @param string $countryCode The ISO country code of the country to fetch
* available phone number information about
*/
protected function contextAvailablePhoneNumbers(string $countryCode): \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext {
return $this->v2010->account->availablePhoneNumbers($countryCode);
}
protected function getBalance(): \Twilio\Rest\Api\V2010\Account\BalanceList {
return $this->v2010->account->balance;
}
protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList {
return $this->v2010->account->calls;
}
/**
* @param string $sid The SID of the Call resource to fetch
*/
protected function contextCalls(string $sid): \Twilio\Rest\Api\V2010\Account\CallContext {
return $this->v2010->account->calls($sid);
}
protected function getConferences(): \Twilio\Rest\Api\V2010\Account\ConferenceList {
return $this->v2010->account->conferences;
}
/**
* @param string $sid The unique string that identifies this resource
*/
protected function contextConferences(string $sid): \Twilio\Rest\Api\V2010\Account\ConferenceContext {
return $this->v2010->account->conferences($sid);
}
protected function getConnectApps(): \Twilio\Rest\Api\V2010\Account\ConnectAppList {
return $this->v2010->account->connectApps;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextConnectApps(string $sid): \Twilio\Rest\Api\V2010\Account\ConnectAppContext {
return $this->v2010->account->connectApps($sid);
}
protected function getIncomingPhoneNumbers(): \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList {
return $this->v2010->account->incomingPhoneNumbers;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextIncomingPhoneNumbers(string $sid): \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext {
return $this->v2010->account->incomingPhoneNumbers($sid);
}
protected function getKeys(): \Twilio\Rest\Api\V2010\Account\KeyList {
return $this->v2010->account->keys;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextKeys(string $sid): \Twilio\Rest\Api\V2010\Account\KeyContext {
return $this->v2010->account->keys($sid);
}
protected function getMessages(): \Twilio\Rest\Api\V2010\Account\MessageList {
return $this->v2010->account->messages;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextMessages(string $sid): \Twilio\Rest\Api\V2010\Account\MessageContext {
return $this->v2010->account->messages($sid);
}
protected function getNewKeys(): \Twilio\Rest\Api\V2010\Account\NewKeyList {
return $this->v2010->account->newKeys;
}
protected function getNewSigningKeys(): \Twilio\Rest\Api\V2010\Account\NewSigningKeyList {
return $this->v2010->account->newSigningKeys;
}
protected function getNotifications(): \Twilio\Rest\Api\V2010\Account\NotificationList {
return $this->v2010->account->notifications;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextNotifications(string $sid): \Twilio\Rest\Api\V2010\Account\NotificationContext {
return $this->v2010->account->notifications($sid);
}
protected function getOutgoingCallerIds(): \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList {
return $this->v2010->account->outgoingCallerIds;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextOutgoingCallerIds(string $sid): \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext {
return $this->v2010->account->outgoingCallerIds($sid);
}
protected function getQueues(): \Twilio\Rest\Api\V2010\Account\QueueList {
return $this->v2010->account->queues;
}
/**
* @param string $sid The unique string that identifies this resource
*/
protected function contextQueues(string $sid): \Twilio\Rest\Api\V2010\Account\QueueContext {
return $this->v2010->account->queues($sid);
}
protected function getRecordings(): \Twilio\Rest\Api\V2010\Account\RecordingList {
return $this->v2010->account->recordings;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextRecordings(string $sid): \Twilio\Rest\Api\V2010\Account\RecordingContext {
return $this->v2010->account->recordings($sid);
}
protected function getSigningKeys(): \Twilio\Rest\Api\V2010\Account\SigningKeyList {
return $this->v2010->account->signingKeys;
}
/**
* @param string $sid The sid
*/
protected function contextSigningKeys(string $sid): \Twilio\Rest\Api\V2010\Account\SigningKeyContext {
return $this->v2010->account->signingKeys($sid);
}
protected function getSip(): \Twilio\Rest\Api\V2010\Account\SipList {
return $this->v2010->account->sip;
}
protected function getShortCodes(): \Twilio\Rest\Api\V2010\Account\ShortCodeList {
return $this->v2010->account->shortCodes;
}
/**
* @param string $sid The unique string that identifies this resource
*/
protected function contextShortCodes(string $sid): \Twilio\Rest\Api\V2010\Account\ShortCodeContext {
return $this->v2010->account->shortCodes($sid);
}
protected function getTokens(): \Twilio\Rest\Api\V2010\Account\TokenList {
return $this->v2010->account->tokens;
}
protected function getTranscriptions(): \Twilio\Rest\Api\V2010\Account\TranscriptionList {
return $this->v2010->account->transcriptions;
}
/**
* @param string $sid The unique string that identifies the resource
*/
protected function contextTranscriptions(string $sid): \Twilio\Rest\Api\V2010\Account\TranscriptionContext {
return $this->v2010->account->transcriptions($sid);
}
protected function getUsage(): \Twilio\Rest\Api\V2010\Account\UsageList {
return $this->v2010->account->usage;
}
protected function getValidationRequests(): \Twilio\Rest\Api\V2010\Account\ValidationRequestList {
return $this->v2010->account->validationRequests;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api]';
}
}

View File

@@ -0,0 +1,271 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api;
use Twilio\Domain;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Rest\Api\V2010\AccountContext;
use Twilio\Rest\Api\V2010\AccountInstance;
use Twilio\Rest\Api\V2010\AccountList;
use Twilio\Version;
/**
* @property AccountList $accounts
* @method \Twilio\Rest\Api\V2010\AccountContext accounts(string $sid)
* @property AccountContext $account
* @property \Twilio\Rest\Api\V2010\Account\AddressList $addresses
* @property \Twilio\Rest\Api\V2010\Account\ApplicationList $applications
* @property \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList $authorizedConnectApps
* @property \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList $availablePhoneNumbers
* @property \Twilio\Rest\Api\V2010\Account\BalanceList $balance
* @property \Twilio\Rest\Api\V2010\Account\CallList $calls
* @property \Twilio\Rest\Api\V2010\Account\ConferenceList $conferences
* @property \Twilio\Rest\Api\V2010\Account\ConnectAppList $connectApps
* @property \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList $incomingPhoneNumbers
* @property \Twilio\Rest\Api\V2010\Account\KeyList $keys
* @property \Twilio\Rest\Api\V2010\Account\MessageList $messages
* @property \Twilio\Rest\Api\V2010\Account\NewKeyList $newKeys
* @property \Twilio\Rest\Api\V2010\Account\NewSigningKeyList $newSigningKeys
* @property \Twilio\Rest\Api\V2010\Account\NotificationList $notifications
* @property \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList $outgoingCallerIds
* @property \Twilio\Rest\Api\V2010\Account\QueueList $queues
* @property \Twilio\Rest\Api\V2010\Account\RecordingList $recordings
* @property \Twilio\Rest\Api\V2010\Account\SigningKeyList $signingKeys
* @property \Twilio\Rest\Api\V2010\Account\SipList $sip
* @property \Twilio\Rest\Api\V2010\Account\ShortCodeList $shortCodes
* @property \Twilio\Rest\Api\V2010\Account\TokenList $tokens
* @property \Twilio\Rest\Api\V2010\Account\TranscriptionList $transcriptions
* @property \Twilio\Rest\Api\V2010\Account\UsageList $usage
* @property \Twilio\Rest\Api\V2010\Account\ValidationRequestList $validationRequests
* @method \Twilio\Rest\Api\V2010\Account\AddressContext addresses(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ApplicationContext applications(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppContext authorizedConnectApps(string $connectAppSid)
* @method \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryContext availablePhoneNumbers(string $countryCode)
* @method \Twilio\Rest\Api\V2010\Account\CallContext calls(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ConferenceContext conferences(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ConnectAppContext connectApps(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberContext incomingPhoneNumbers(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\KeyContext keys(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\MessageContext messages(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\NotificationContext notifications(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdContext outgoingCallerIds(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\QueueContext queues(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\RecordingContext recordings(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\SigningKeyContext signingKeys(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\ShortCodeContext shortCodes(string $sid)
* @method \Twilio\Rest\Api\V2010\Account\TranscriptionContext transcriptions(string $sid)
*/
class V2010 extends Version {
protected $_accounts;
protected $_account = null;
protected $_addresses = null;
protected $_applications = null;
protected $_authorizedConnectApps = null;
protected $_availablePhoneNumbers = null;
protected $_balance = null;
protected $_calls = null;
protected $_conferences = null;
protected $_connectApps = null;
protected $_incomingPhoneNumbers = null;
protected $_keys = null;
protected $_messages = null;
protected $_newKeys = null;
protected $_newSigningKeys = null;
protected $_notifications = null;
protected $_outgoingCallerIds = null;
protected $_queues = null;
protected $_recordings = null;
protected $_signingKeys = null;
protected $_sip = null;
protected $_shortCodes = null;
protected $_tokens = null;
protected $_transcriptions = null;
protected $_usage = null;
protected $_validationRequests = null;
/**
* Construct the V2010 version of Api
*
* @param Domain $domain Domain that contains the version
*/
public function __construct(Domain $domain) {
parent::__construct($domain);
$this->version = '2010-04-01';
}
protected function getAccounts(): AccountList {
if (!$this->_accounts) {
$this->_accounts = new AccountList($this);
}
return $this->_accounts;
}
/**
* @return AccountContext Account provided as the authenticating account
*/
protected function getAccount(): AccountContext {
if (!$this->_account) {
$this->_account = new AccountContext(
$this,
$this->domain->getClient()->getAccountSid()
);
}
return $this->_account;
}
/**
* Setter to override the primary account
*
* @param AccountContext|AccountInstance $account account to use as the primary
* account
*/
public function setAccount($account): void {
$this->_account = $account;
}
protected function getAddresses(): \Twilio\Rest\Api\V2010\Account\AddressList {
return $this->account->addresses;
}
protected function getApplications(): \Twilio\Rest\Api\V2010\Account\ApplicationList {
return $this->account->applications;
}
protected function getAuthorizedConnectApps(): \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppList {
return $this->account->authorizedConnectApps;
}
protected function getAvailablePhoneNumbers(): \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountryList {
return $this->account->availablePhoneNumbers;
}
protected function getBalance(): \Twilio\Rest\Api\V2010\Account\BalanceList {
return $this->account->balance;
}
protected function getCalls(): \Twilio\Rest\Api\V2010\Account\CallList {
return $this->account->calls;
}
protected function getConferences(): \Twilio\Rest\Api\V2010\Account\ConferenceList {
return $this->account->conferences;
}
protected function getConnectApps(): \Twilio\Rest\Api\V2010\Account\ConnectAppList {
return $this->account->connectApps;
}
protected function getIncomingPhoneNumbers(): \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberList {
return $this->account->incomingPhoneNumbers;
}
protected function getKeys(): \Twilio\Rest\Api\V2010\Account\KeyList {
return $this->account->keys;
}
protected function getMessages(): \Twilio\Rest\Api\V2010\Account\MessageList {
return $this->account->messages;
}
protected function getNewKeys(): \Twilio\Rest\Api\V2010\Account\NewKeyList {
return $this->account->newKeys;
}
protected function getNewSigningKeys(): \Twilio\Rest\Api\V2010\Account\NewSigningKeyList {
return $this->account->newSigningKeys;
}
protected function getNotifications(): \Twilio\Rest\Api\V2010\Account\NotificationList {
return $this->account->notifications;
}
protected function getOutgoingCallerIds(): \Twilio\Rest\Api\V2010\Account\OutgoingCallerIdList {
return $this->account->outgoingCallerIds;
}
protected function getQueues(): \Twilio\Rest\Api\V2010\Account\QueueList {
return $this->account->queues;
}
protected function getRecordings(): \Twilio\Rest\Api\V2010\Account\RecordingList {
return $this->account->recordings;
}
protected function getSigningKeys(): \Twilio\Rest\Api\V2010\Account\SigningKeyList {
return $this->account->signingKeys;
}
protected function getSip(): \Twilio\Rest\Api\V2010\Account\SipList {
return $this->account->sip;
}
protected function getShortCodes(): \Twilio\Rest\Api\V2010\Account\ShortCodeList {
return $this->account->shortCodes;
}
protected function getTokens(): \Twilio\Rest\Api\V2010\Account\TokenList {
return $this->account->tokens;
}
protected function getTranscriptions(): \Twilio\Rest\Api\V2010\Account\TranscriptionList {
return $this->account->transcriptions;
}
protected function getUsage(): \Twilio\Rest\Api\V2010\Account\UsageList {
return $this->account->usage;
}
protected function getValidationRequests(): \Twilio\Rest\Api\V2010\Account\ValidationRequestList {
return $this->account->validationRequests;
}
/**
* 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.Api.V2010]';
}
}

View File

@@ -0,0 +1,119 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\Address;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $sid
* @property string $accountSid
* @property string $friendlyName
* @property string $phoneNumber
* @property string $voiceUrl
* @property string $voiceMethod
* @property string $voiceFallbackMethod
* @property string $voiceFallbackUrl
* @property bool $voiceCallerIdLookup
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $smsFallbackMethod
* @property string $smsFallbackUrl
* @property string $smsMethod
* @property string $smsUrl
* @property string $addressRequirements
* @property array $capabilities
* @property string $statusCallback
* @property string $statusCallbackMethod
* @property string $apiVersion
* @property string $smsApplicationSid
* @property string $voiceApplicationSid
* @property string $trunkSid
* @property string $emergencyStatus
* @property string $emergencyAddressSid
* @property string $uri
*/
class DependentPhoneNumberInstance extends InstanceResource {
/**
* Initialize the DependentPhoneNumberInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The SID of the Account that created the resource
* @param string $addressSid The unique string that identifies the resource
*/
public function __construct(Version $version, array $payload, string $accountSid, string $addressSid) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'sid' => Values::array_get($payload, 'sid'),
'accountSid' => Values::array_get($payload, 'account_sid'),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
'voiceUrl' => Values::array_get($payload, 'voice_url'),
'voiceMethod' => Values::array_get($payload, 'voice_method'),
'voiceFallbackMethod' => Values::array_get($payload, 'voice_fallback_method'),
'voiceFallbackUrl' => Values::array_get($payload, 'voice_fallback_url'),
'voiceCallerIdLookup' => Values::array_get($payload, 'voice_caller_id_lookup'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'smsFallbackMethod' => Values::array_get($payload, 'sms_fallback_method'),
'smsFallbackUrl' => Values::array_get($payload, 'sms_fallback_url'),
'smsMethod' => Values::array_get($payload, 'sms_method'),
'smsUrl' => Values::array_get($payload, 'sms_url'),
'addressRequirements' => Values::array_get($payload, 'address_requirements'),
'capabilities' => Values::array_get($payload, 'capabilities'),
'statusCallback' => Values::array_get($payload, 'status_callback'),
'statusCallbackMethod' => Values::array_get($payload, 'status_callback_method'),
'apiVersion' => Values::array_get($payload, 'api_version'),
'smsApplicationSid' => Values::array_get($payload, 'sms_application_sid'),
'voiceApplicationSid' => Values::array_get($payload, 'voice_application_sid'),
'trunkSid' => Values::array_get($payload, 'trunk_sid'),
'emergencyStatus' => Values::array_get($payload, 'emergency_status'),
'emergencyAddressSid' => Values::array_get($payload, 'emergency_address_sid'),
'uri' => Values::array_get($payload, 'uri'),
];
$this->solution = ['accountSid' => $accountSid, 'addressSid' => $addressSid, ];
}
/**
* 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.Api.V2010.DependentPhoneNumberInstance]';
}
}

View File

@@ -0,0 +1,122 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\Address;
use Twilio\ListResource;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class DependentPhoneNumberList extends ListResource {
/**
* Construct the DependentPhoneNumberList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that created the resource
* @param string $addressSid The unique string that identifies the resource
*/
public function __construct(Version $version, string $accountSid, string $addressSid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'addressSid' => $addressSid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Addresses/' . \rawurlencode($addressSid) . '/DependentPhoneNumbers.json';
}
/**
* Streams DependentPhoneNumberInstance records from the API as a generator
* stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads DependentPhoneNumberInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return DependentPhoneNumberInstance[] Array of results
*/
public function read(int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Retrieve a single page of DependentPhoneNumberInstance records from the API.
* Request is executed immediately
*
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return DependentPhoneNumberPage Page of DependentPhoneNumberInstance
*/
public function page($pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): DependentPhoneNumberPage {
$params = Values::of(['PageToken' => $pageToken, 'Page' => $pageNumber, 'PageSize' => $pageSize, ]);
$response = $this->version->page('GET', $this->uri, $params);
return new DependentPhoneNumberPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of DependentPhoneNumberInstance records from the
* API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return DependentPhoneNumberPage Page of DependentPhoneNumberInstance
*/
public function getPage(string $targetUrl): DependentPhoneNumberPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new DependentPhoneNumberPage($this->version, $response, $this->solution);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.DependentPhoneNumberList]';
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\Address;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class DependentPhoneNumberPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return DependentPhoneNumberInstance \Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberInstance
*/
public function buildInstance(array $payload): DependentPhoneNumberInstance {
return new DependentPhoneNumberInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['addressSid']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.DependentPhoneNumberPage]';
}
}

View File

@@ -0,0 +1,163 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberList;
use Twilio\Serialize;
use Twilio\Values;
use Twilio\Version;
/**
* @property DependentPhoneNumberList $dependentPhoneNumbers
*/
class AddressContext extends InstanceContext {
protected $_dependentPhoneNumbers;
/**
* Initialize the AddressContext
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that is responsible for
* this address
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, $accountSid, $sid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'sid' => $sid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Addresses/' . \rawurlencode($sid) . '.json';
}
/**
* Delete the AddressInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->version->delete('DELETE', $this->uri);
}
/**
* Fetch the AddressInstance
*
* @return AddressInstance Fetched AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AddressInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new AddressInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['sid']
);
}
/**
* Update the AddressInstance
*
* @param array|Options $options Optional Arguments
* @return AddressInstance Updated AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AddressInstance {
$options = new Values($options);
$data = Values::of([
'FriendlyName' => $options['friendlyName'],
'CustomerName' => $options['customerName'],
'Street' => $options['street'],
'City' => $options['city'],
'Region' => $options['region'],
'PostalCode' => $options['postalCode'],
'EmergencyEnabled' => Serialize::booleanToString($options['emergencyEnabled']),
'AutoCorrectAddress' => Serialize::booleanToString($options['autoCorrectAddress']),
'StreetSecondary' => $options['streetSecondary'],
]);
$payload = $this->version->update('POST', $this->uri, [], $data);
return new AddressInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['sid']
);
}
/**
* Access the dependentPhoneNumbers
*/
protected function getDependentPhoneNumbers(): DependentPhoneNumberList {
if (!$this->_dependentPhoneNumbers) {
$this->_dependentPhoneNumbers = new DependentPhoneNumberList(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->_dependentPhoneNumbers;
}
/**
* Magic getter to lazy load subresources
*
* @param string $name Subresource to return
* @return ListResource The requested subresource
* @throws TwilioException For unknown subresources
*/
public function __get(string $name): ListResource {
if (\property_exists($this, '_' . $name)) {
$method = 'get' . \ucfirst($name);
return $this->$method();
}
throw new TwilioException('Unknown subresource ' . $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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.AddressContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,164 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Rest\Api\V2010\Account\Address\DependentPhoneNumberList;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $accountSid
* @property string $city
* @property string $customerName
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $friendlyName
* @property string $isoCountry
* @property string $postalCode
* @property string $region
* @property string $sid
* @property string $street
* @property string $uri
* @property bool $emergencyEnabled
* @property bool $validated
* @property bool $verified
* @property string $streetSecondary
*/
class AddressInstance extends InstanceResource {
protected $_dependentPhoneNumbers;
/**
* Initialize the AddressInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The SID of the Account that is responsible for the
* resource
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, array $payload, string $accountSid, string $sid = null) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'city' => Values::array_get($payload, 'city'),
'customerName' => Values::array_get($payload, 'customer_name'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'isoCountry' => Values::array_get($payload, 'iso_country'),
'postalCode' => Values::array_get($payload, 'postal_code'),
'region' => Values::array_get($payload, 'region'),
'sid' => Values::array_get($payload, 'sid'),
'street' => Values::array_get($payload, 'street'),
'uri' => Values::array_get($payload, 'uri'),
'emergencyEnabled' => Values::array_get($payload, 'emergency_enabled'),
'validated' => Values::array_get($payload, 'validated'),
'verified' => Values::array_get($payload, 'verified'),
'streetSecondary' => Values::array_get($payload, 'street_secondary'),
];
$this->solution = ['accountSid' => $accountSid, 'sid' => $sid ?: $this->properties['sid'], ];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return AddressContext Context for this AddressInstance
*/
protected function proxy(): AddressContext {
if (!$this->context) {
$this->context = new AddressContext(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->context;
}
/**
* Delete the AddressInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->proxy()->delete();
}
/**
* Fetch the AddressInstance
*
* @return AddressInstance Fetched AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AddressInstance {
return $this->proxy()->fetch();
}
/**
* Update the AddressInstance
*
* @param array|Options $options Optional Arguments
* @return AddressInstance Updated AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): AddressInstance {
return $this->proxy()->update($options);
}
/**
* Access the dependentPhoneNumbers
*/
protected function getDependentPhoneNumbers(): DependentPhoneNumberList {
return $this->proxy()->dependentPhoneNumbers;
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.AddressInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,178 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Serialize;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class AddressList extends ListResource {
/**
* Construct the AddressList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that is responsible for the
* resource
*/
public function __construct(Version $version, string $accountSid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Addresses.json';
}
/**
* Create the AddressInstance
*
* @param string $customerName The name to associate with the new address
* @param string $street The number and street address of the new address
* @param string $city The city of the new address
* @param string $region The state or region of the new address
* @param string $postalCode The postal code of the new address
* @param string $isoCountry The ISO country code of the new address
* @param array|Options $options Optional Arguments
* @return AddressInstance Created AddressInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(string $customerName, string $street, string $city, string $region, string $postalCode, string $isoCountry, array $options = []): AddressInstance {
$options = new Values($options);
$data = Values::of([
'CustomerName' => $customerName,
'Street' => $street,
'City' => $city,
'Region' => $region,
'PostalCode' => $postalCode,
'IsoCountry' => $isoCountry,
'FriendlyName' => $options['friendlyName'],
'EmergencyEnabled' => Serialize::booleanToString($options['emergencyEnabled']),
'AutoCorrectAddress' => Serialize::booleanToString($options['autoCorrectAddress']),
'StreetSecondary' => $options['streetSecondary'],
]);
$payload = $this->version->create('POST', $this->uri, [], $data);
return new AddressInstance($this->version, $payload, $this->solution['accountSid']);
}
/**
* Streams AddressInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(array $options = [], int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads AddressInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return AddressInstance[] Array of results
*/
public function read(array $options = [], int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
}
/**
* Retrieve a single page of AddressInstance records from the API.
* Request is executed immediately
*
* @param array|Options $options Optional Arguments
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return AddressPage Page of AddressInstance
*/
public function page(array $options = [], $pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): AddressPage {
$options = new Values($options);
$params = Values::of([
'CustomerName' => $options['customerName'],
'FriendlyName' => $options['friendlyName'],
'IsoCountry' => $options['isoCountry'],
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$response = $this->version->page('GET', $this->uri, $params);
return new AddressPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of AddressInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return AddressPage Page of AddressInstance
*/
public function getPage(string $targetUrl): AddressPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new AddressPage($this->version, $response, $this->solution);
}
/**
* Constructs a AddressContext
*
* @param string $sid The unique string that identifies the resource
*/
public function getContext(string $sid): AddressContext {
return new AddressContext($this->version, $this->solution['accountSid'], $sid);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.AddressList]';
}
}

View File

@@ -0,0 +1,338 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Options;
use Twilio\Values;
abstract class AddressOptions {
/**
* @param string $friendlyName A string to describe the new resource
* @param bool $emergencyEnabled Whether to enable emergency calling on the new
* address
* @param bool $autoCorrectAddress Whether we should automatically correct the
* address
* @param string $streetSecondary The additional number and street address of
* the address
* @return CreateAddressOptions Options builder
*/
public static function create(string $friendlyName = Values::NONE, bool $emergencyEnabled = Values::NONE, bool $autoCorrectAddress = Values::NONE, string $streetSecondary = Values::NONE): CreateAddressOptions {
return new CreateAddressOptions($friendlyName, $emergencyEnabled, $autoCorrectAddress, $streetSecondary);
}
/**
* @param string $friendlyName A string to describe the resource
* @param string $customerName The name to associate with the address
* @param string $street The number and street address of the address
* @param string $city The city of the address
* @param string $region The state or region of the address
* @param string $postalCode The postal code of the address
* @param bool $emergencyEnabled Whether to enable emergency calling on the
* address
* @param bool $autoCorrectAddress Whether we should automatically correct the
* address
* @param string $streetSecondary The additional number and street address of
* the address
* @return UpdateAddressOptions Options builder
*/
public static function update(string $friendlyName = Values::NONE, string $customerName = Values::NONE, string $street = Values::NONE, string $city = Values::NONE, string $region = Values::NONE, string $postalCode = Values::NONE, bool $emergencyEnabled = Values::NONE, bool $autoCorrectAddress = Values::NONE, string $streetSecondary = Values::NONE): UpdateAddressOptions {
return new UpdateAddressOptions($friendlyName, $customerName, $street, $city, $region, $postalCode, $emergencyEnabled, $autoCorrectAddress, $streetSecondary);
}
/**
* @param string $customerName The `customer_name` of the Address resources to
* read
* @param string $friendlyName The string that identifies the Address resources
* to read
* @param string $isoCountry The ISO country code of the Address resources to
* read
* @return ReadAddressOptions Options builder
*/
public static function read(string $customerName = Values::NONE, string $friendlyName = Values::NONE, string $isoCountry = Values::NONE): ReadAddressOptions {
return new ReadAddressOptions($customerName, $friendlyName, $isoCountry);
}
}
class CreateAddressOptions extends Options {
/**
* @param string $friendlyName A string to describe the new resource
* @param bool $emergencyEnabled Whether to enable emergency calling on the new
* address
* @param bool $autoCorrectAddress Whether we should automatically correct the
* address
* @param string $streetSecondary The additional number and street address of
* the address
*/
public function __construct(string $friendlyName = Values::NONE, bool $emergencyEnabled = Values::NONE, bool $autoCorrectAddress = Values::NONE, string $streetSecondary = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
$this->options['emergencyEnabled'] = $emergencyEnabled;
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
$this->options['streetSecondary'] = $streetSecondary;
}
/**
* A descriptive string that you create to describe the new address. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the new resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Whether to enable emergency calling on the new address. Can be: `true` or `false`.
*
* @param bool $emergencyEnabled Whether to enable emergency calling on the new
* address
* @return $this Fluent Builder
*/
public function setEmergencyEnabled(bool $emergencyEnabled): self {
$this->options['emergencyEnabled'] = $emergencyEnabled;
return $this;
}
/**
* Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
*
* @param bool $autoCorrectAddress Whether we should automatically correct the
* address
* @return $this Fluent Builder
*/
public function setAutoCorrectAddress(bool $autoCorrectAddress): self {
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
return $this;
}
/**
* The additional number and street address of the address.
*
* @param string $streetSecondary The additional number and street address of
* the address
* @return $this Fluent Builder
*/
public function setStreetSecondary(string $streetSecondary): self {
$this->options['streetSecondary'] = $streetSecondary;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.CreateAddressOptions ' . $options . ']';
}
}
class UpdateAddressOptions extends Options {
/**
* @param string $friendlyName A string to describe the resource
* @param string $customerName The name to associate with the address
* @param string $street The number and street address of the address
* @param string $city The city of the address
* @param string $region The state or region of the address
* @param string $postalCode The postal code of the address
* @param bool $emergencyEnabled Whether to enable emergency calling on the
* address
* @param bool $autoCorrectAddress Whether we should automatically correct the
* address
* @param string $streetSecondary The additional number and street address of
* the address
*/
public function __construct(string $friendlyName = Values::NONE, string $customerName = Values::NONE, string $street = Values::NONE, string $city = Values::NONE, string $region = Values::NONE, string $postalCode = Values::NONE, bool $emergencyEnabled = Values::NONE, bool $autoCorrectAddress = Values::NONE, string $streetSecondary = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
$this->options['customerName'] = $customerName;
$this->options['street'] = $street;
$this->options['city'] = $city;
$this->options['region'] = $region;
$this->options['postalCode'] = $postalCode;
$this->options['emergencyEnabled'] = $emergencyEnabled;
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
$this->options['streetSecondary'] = $streetSecondary;
}
/**
* A descriptive string that you create to describe the address. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The name to associate with the address.
*
* @param string $customerName The name to associate with the address
* @return $this Fluent Builder
*/
public function setCustomerName(string $customerName): self {
$this->options['customerName'] = $customerName;
return $this;
}
/**
* The number and street address of the address.
*
* @param string $street The number and street address of the address
* @return $this Fluent Builder
*/
public function setStreet(string $street): self {
$this->options['street'] = $street;
return $this;
}
/**
* The city of the address.
*
* @param string $city The city of the address
* @return $this Fluent Builder
*/
public function setCity(string $city): self {
$this->options['city'] = $city;
return $this;
}
/**
* The state or region of the address.
*
* @param string $region The state or region of the address
* @return $this Fluent Builder
*/
public function setRegion(string $region): self {
$this->options['region'] = $region;
return $this;
}
/**
* The postal code of the address.
*
* @param string $postalCode The postal code of the address
* @return $this Fluent Builder
*/
public function setPostalCode(string $postalCode): self {
$this->options['postalCode'] = $postalCode;
return $this;
}
/**
* Whether to enable emergency calling on the address. Can be: `true` or `false`.
*
* @param bool $emergencyEnabled Whether to enable emergency calling on the
* address
* @return $this Fluent Builder
*/
public function setEmergencyEnabled(bool $emergencyEnabled): self {
$this->options['emergencyEnabled'] = $emergencyEnabled;
return $this;
}
/**
* Whether we should automatically correct the address. Can be: `true` or `false` and the default is `true`. If empty or `true`, we will correct the address you provide if necessary. If `false`, we won't alter the address you provide.
*
* @param bool $autoCorrectAddress Whether we should automatically correct the
* address
* @return $this Fluent Builder
*/
public function setAutoCorrectAddress(bool $autoCorrectAddress): self {
$this->options['autoCorrectAddress'] = $autoCorrectAddress;
return $this;
}
/**
* The additional number and street address of the address.
*
* @param string $streetSecondary The additional number and street address of
* the address
* @return $this Fluent Builder
*/
public function setStreetSecondary(string $streetSecondary): self {
$this->options['streetSecondary'] = $streetSecondary;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.UpdateAddressOptions ' . $options . ']';
}
}
class ReadAddressOptions extends Options {
/**
* @param string $customerName The `customer_name` of the Address resources to
* read
* @param string $friendlyName The string that identifies the Address resources
* to read
* @param string $isoCountry The ISO country code of the Address resources to
* read
*/
public function __construct(string $customerName = Values::NONE, string $friendlyName = Values::NONE, string $isoCountry = Values::NONE) {
$this->options['customerName'] = $customerName;
$this->options['friendlyName'] = $friendlyName;
$this->options['isoCountry'] = $isoCountry;
}
/**
* The `customer_name` of the Address resources to read.
*
* @param string $customerName The `customer_name` of the Address resources to
* read
* @return $this Fluent Builder
*/
public function setCustomerName(string $customerName): self {
$this->options['customerName'] = $customerName;
return $this;
}
/**
* The string that identifies the Address resources to read.
*
* @param string $friendlyName The string that identifies the Address resources
* to read
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The ISO country code of the Address resources to read.
*
* @param string $isoCountry The ISO country code of the Address resources to
* read
* @return $this Fluent Builder
*/
public function setIsoCountry(string $isoCountry): self {
$this->options['isoCountry'] = $isoCountry;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.ReadAddressOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class AddressPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return AddressInstance \Twilio\Rest\Api\V2010\Account\AddressInstance
*/
public function buildInstance(array $payload): AddressInstance {
return new AddressInstance($this->version, $payload, $this->solution['accountSid']);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.AddressPage]';
}
}

View File

@@ -0,0 +1,115 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Options;
use Twilio\Serialize;
use Twilio\Values;
use Twilio\Version;
class ApplicationContext extends InstanceContext {
/**
* Initialize the ApplicationContext
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that created the resource
* to fetch
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, $accountSid, $sid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'sid' => $sid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Applications/' . \rawurlencode($sid) . '.json';
}
/**
* Delete the ApplicationInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->version->delete('DELETE', $this->uri);
}
/**
* Fetch the ApplicationInstance
*
* @return ApplicationInstance Fetched ApplicationInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): ApplicationInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new ApplicationInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['sid']
);
}
/**
* Update the ApplicationInstance
*
* @param array|Options $options Optional Arguments
* @return ApplicationInstance Updated ApplicationInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): ApplicationInstance {
$options = new Values($options);
$data = Values::of([
'FriendlyName' => $options['friendlyName'],
'ApiVersion' => $options['apiVersion'],
'VoiceUrl' => $options['voiceUrl'],
'VoiceMethod' => $options['voiceMethod'],
'VoiceFallbackUrl' => $options['voiceFallbackUrl'],
'VoiceFallbackMethod' => $options['voiceFallbackMethod'],
'StatusCallback' => $options['statusCallback'],
'StatusCallbackMethod' => $options['statusCallbackMethod'],
'VoiceCallerIdLookup' => Serialize::booleanToString($options['voiceCallerIdLookup']),
'SmsUrl' => $options['smsUrl'],
'SmsMethod' => $options['smsMethod'],
'SmsFallbackUrl' => $options['smsFallbackUrl'],
'SmsFallbackMethod' => $options['smsFallbackMethod'],
'SmsStatusCallback' => $options['smsStatusCallback'],
'MessageStatusCallback' => $options['messageStatusCallback'],
'PublicApplicationConnectEnabled' => Serialize::booleanToString($options['publicApplicationConnectEnabled']),
]);
$payload = $this->version->update('POST', $this->uri, [], $data);
return new ApplicationInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['sid']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.ApplicationContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,163 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Options;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $accountSid
* @property string $apiVersion
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string $friendlyName
* @property string $messageStatusCallback
* @property string $sid
* @property string $smsFallbackMethod
* @property string $smsFallbackUrl
* @property string $smsMethod
* @property string $smsStatusCallback
* @property string $smsUrl
* @property string $statusCallback
* @property string $statusCallbackMethod
* @property string $uri
* @property bool $voiceCallerIdLookup
* @property string $voiceFallbackMethod
* @property string $voiceFallbackUrl
* @property string $voiceMethod
* @property string $voiceUrl
* @property bool $publicApplicationConnectEnabled
*/
class ApplicationInstance extends InstanceResource {
/**
* Initialize the ApplicationInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The SID of the Account that created the resource
* @param string $sid The unique string that identifies the resource
*/
public function __construct(Version $version, array $payload, string $accountSid, string $sid = null) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'apiVersion' => Values::array_get($payload, 'api_version'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'messageStatusCallback' => Values::array_get($payload, 'message_status_callback'),
'sid' => Values::array_get($payload, 'sid'),
'smsFallbackMethod' => Values::array_get($payload, 'sms_fallback_method'),
'smsFallbackUrl' => Values::array_get($payload, 'sms_fallback_url'),
'smsMethod' => Values::array_get($payload, 'sms_method'),
'smsStatusCallback' => Values::array_get($payload, 'sms_status_callback'),
'smsUrl' => Values::array_get($payload, 'sms_url'),
'statusCallback' => Values::array_get($payload, 'status_callback'),
'statusCallbackMethod' => Values::array_get($payload, 'status_callback_method'),
'uri' => Values::array_get($payload, 'uri'),
'voiceCallerIdLookup' => Values::array_get($payload, 'voice_caller_id_lookup'),
'voiceFallbackMethod' => Values::array_get($payload, 'voice_fallback_method'),
'voiceFallbackUrl' => Values::array_get($payload, 'voice_fallback_url'),
'voiceMethod' => Values::array_get($payload, 'voice_method'),
'voiceUrl' => Values::array_get($payload, 'voice_url'),
'publicApplicationConnectEnabled' => Values::array_get($payload, 'public_application_connect_enabled'),
];
$this->solution = ['accountSid' => $accountSid, 'sid' => $sid ?: $this->properties['sid'], ];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return ApplicationContext Context for this ApplicationInstance
*/
protected function proxy(): ApplicationContext {
if (!$this->context) {
$this->context = new ApplicationContext(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->context;
}
/**
* Delete the ApplicationInstance
*
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(): bool {
return $this->proxy()->delete();
}
/**
* Fetch the ApplicationInstance
*
* @return ApplicationInstance Fetched ApplicationInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): ApplicationInstance {
return $this->proxy()->fetch();
}
/**
* Update the ApplicationInstance
*
* @param array|Options $options Optional Arguments
* @return ApplicationInstance Updated ApplicationInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): ApplicationInstance {
return $this->proxy()->update($options);
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.ApplicationInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,175 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Serialize;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class ApplicationList extends ListResource {
/**
* Construct the ApplicationList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that created the resource
*/
public function __construct(Version $version, string $accountSid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/Applications.json';
}
/**
* Create the ApplicationInstance
*
* @param array|Options $options Optional Arguments
* @return ApplicationInstance Created ApplicationInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $options = []): ApplicationInstance {
$options = new Values($options);
$data = Values::of([
'ApiVersion' => $options['apiVersion'],
'VoiceUrl' => $options['voiceUrl'],
'VoiceMethod' => $options['voiceMethod'],
'VoiceFallbackUrl' => $options['voiceFallbackUrl'],
'VoiceFallbackMethod' => $options['voiceFallbackMethod'],
'StatusCallback' => $options['statusCallback'],
'StatusCallbackMethod' => $options['statusCallbackMethod'],
'VoiceCallerIdLookup' => Serialize::booleanToString($options['voiceCallerIdLookup']),
'SmsUrl' => $options['smsUrl'],
'SmsMethod' => $options['smsMethod'],
'SmsFallbackUrl' => $options['smsFallbackUrl'],
'SmsFallbackMethod' => $options['smsFallbackMethod'],
'SmsStatusCallback' => $options['smsStatusCallback'],
'MessageStatusCallback' => $options['messageStatusCallback'],
'FriendlyName' => $options['friendlyName'],
'PublicApplicationConnectEnabled' => Serialize::booleanToString($options['publicApplicationConnectEnabled']),
]);
$payload = $this->version->create('POST', $this->uri, [], $data);
return new ApplicationInstance($this->version, $payload, $this->solution['accountSid']);
}
/**
* Streams ApplicationInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(array $options = [], int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads ApplicationInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return ApplicationInstance[] Array of results
*/
public function read(array $options = [], int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
}
/**
* Retrieve a single page of ApplicationInstance records from the API.
* Request is executed immediately
*
* @param array|Options $options Optional Arguments
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return ApplicationPage Page of ApplicationInstance
*/
public function page(array $options = [], $pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): ApplicationPage {
$options = new Values($options);
$params = Values::of([
'FriendlyName' => $options['friendlyName'],
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$response = $this->version->page('GET', $this->uri, $params);
return new ApplicationPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of ApplicationInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return ApplicationPage Page of ApplicationInstance
*/
public function getPage(string $targetUrl): ApplicationPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new ApplicationPage($this->version, $response, $this->solution);
}
/**
* Constructs a ApplicationContext
*
* @param string $sid The unique string that identifies the resource
*/
public function getContext(string $sid): ApplicationContext {
return new ApplicationContext($this->version, $this->solution['accountSid'], $sid);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.ApplicationList]';
}
}

View File

@@ -0,0 +1,609 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Options;
use Twilio\Values;
abstract class ApplicationOptions {
/**
* @param string $apiVersion The API version to use to start a new TwiML session
* @param string $voiceUrl The URL to call when the phone number receives a call
* @param string $voiceMethod The HTTP method to use with the voice_url
* @param string $voiceFallbackUrl The URL to call when a TwiML error occurs
* @param string $voiceFallbackMethod The HTTP method to use with
* voice_fallback_url
* @param string $statusCallback The URL to send status information to your
* application
* @param string $statusCallbackMethod The HTTP method to use to call
* status_callback
* @param bool $voiceCallerIdLookup Whether to lookup the caller's name
* @param string $smsUrl The URL to call when the phone number receives an
* incoming SMS message
* @param string $smsMethod The HTTP method to use with sms_url
* @param string $smsFallbackUrl The URL to call when an error occurs while
* retrieving or executing the TwiML
* @param string $smsFallbackMethod The HTTP method to use with sms_fallback_url
* @param string $smsStatusCallback The URL to send status information to your
* application
* @param string $messageStatusCallback The URL to send message status
* information to your application
* @param string $friendlyName A string to describe the new resource
* @param bool $publicApplicationConnectEnabled Whether to allow other Twilio
* accounts to dial this
* application
* @return CreateApplicationOptions Options builder
*/
public static function create(string $apiVersion = Values::NONE, string $voiceUrl = Values::NONE, string $voiceMethod = Values::NONE, string $voiceFallbackUrl = Values::NONE, string $voiceFallbackMethod = Values::NONE, string $statusCallback = Values::NONE, string $statusCallbackMethod = Values::NONE, bool $voiceCallerIdLookup = Values::NONE, string $smsUrl = Values::NONE, string $smsMethod = Values::NONE, string $smsFallbackUrl = Values::NONE, string $smsFallbackMethod = Values::NONE, string $smsStatusCallback = Values::NONE, string $messageStatusCallback = Values::NONE, string $friendlyName = Values::NONE, bool $publicApplicationConnectEnabled = Values::NONE): CreateApplicationOptions {
return new CreateApplicationOptions($apiVersion, $voiceUrl, $voiceMethod, $voiceFallbackUrl, $voiceFallbackMethod, $statusCallback, $statusCallbackMethod, $voiceCallerIdLookup, $smsUrl, $smsMethod, $smsFallbackUrl, $smsFallbackMethod, $smsStatusCallback, $messageStatusCallback, $friendlyName, $publicApplicationConnectEnabled);
}
/**
* @param string $friendlyName The string that identifies the Application
* resources to read
* @return ReadApplicationOptions Options builder
*/
public static function read(string $friendlyName = Values::NONE): ReadApplicationOptions {
return new ReadApplicationOptions($friendlyName);
}
/**
* @param string $friendlyName A string to describe the resource
* @param string $apiVersion The API version to use to start a new TwiML session
* @param string $voiceUrl The URL to call when the phone number receives a call
* @param string $voiceMethod The HTTP method to use with the voice_url
* @param string $voiceFallbackUrl The URL to call when a TwiML error occurs
* @param string $voiceFallbackMethod The HTTP method to use with
* voice_fallback_url
* @param string $statusCallback The URL to send status information to your
* application
* @param string $statusCallbackMethod The HTTP method to use to call
* status_callback
* @param bool $voiceCallerIdLookup Whether to lookup the caller's name
* @param string $smsUrl The URL to call when the phone number receives an
* incoming SMS message
* @param string $smsMethod The HTTP method to use with sms_url
* @param string $smsFallbackUrl The URL to call when an error occurs while
* retrieving or executing the TwiML
* @param string $smsFallbackMethod The HTTP method to use with sms_fallback_url
* @param string $smsStatusCallback Same as message_status_callback.
* Deprecated, included for backwards
* compatibility.
* @param string $messageStatusCallback The URL to send message status
* information to your application
* @param bool $publicApplicationConnectEnabled Whether to allow other Twilio
* accounts to dial this
* application
* @return UpdateApplicationOptions Options builder
*/
public static function update(string $friendlyName = Values::NONE, string $apiVersion = Values::NONE, string $voiceUrl = Values::NONE, string $voiceMethod = Values::NONE, string $voiceFallbackUrl = Values::NONE, string $voiceFallbackMethod = Values::NONE, string $statusCallback = Values::NONE, string $statusCallbackMethod = Values::NONE, bool $voiceCallerIdLookup = Values::NONE, string $smsUrl = Values::NONE, string $smsMethod = Values::NONE, string $smsFallbackUrl = Values::NONE, string $smsFallbackMethod = Values::NONE, string $smsStatusCallback = Values::NONE, string $messageStatusCallback = Values::NONE, bool $publicApplicationConnectEnabled = Values::NONE): UpdateApplicationOptions {
return new UpdateApplicationOptions($friendlyName, $apiVersion, $voiceUrl, $voiceMethod, $voiceFallbackUrl, $voiceFallbackMethod, $statusCallback, $statusCallbackMethod, $voiceCallerIdLookup, $smsUrl, $smsMethod, $smsFallbackUrl, $smsFallbackMethod, $smsStatusCallback, $messageStatusCallback, $publicApplicationConnectEnabled);
}
}
class CreateApplicationOptions extends Options {
/**
* @param string $apiVersion The API version to use to start a new TwiML session
* @param string $voiceUrl The URL to call when the phone number receives a call
* @param string $voiceMethod The HTTP method to use with the voice_url
* @param string $voiceFallbackUrl The URL to call when a TwiML error occurs
* @param string $voiceFallbackMethod The HTTP method to use with
* voice_fallback_url
* @param string $statusCallback The URL to send status information to your
* application
* @param string $statusCallbackMethod The HTTP method to use to call
* status_callback
* @param bool $voiceCallerIdLookup Whether to lookup the caller's name
* @param string $smsUrl The URL to call when the phone number receives an
* incoming SMS message
* @param string $smsMethod The HTTP method to use with sms_url
* @param string $smsFallbackUrl The URL to call when an error occurs while
* retrieving or executing the TwiML
* @param string $smsFallbackMethod The HTTP method to use with sms_fallback_url
* @param string $smsStatusCallback The URL to send status information to your
* application
* @param string $messageStatusCallback The URL to send message status
* information to your application
* @param string $friendlyName A string to describe the new resource
* @param bool $publicApplicationConnectEnabled Whether to allow other Twilio
* accounts to dial this
* application
*/
public function __construct(string $apiVersion = Values::NONE, string $voiceUrl = Values::NONE, string $voiceMethod = Values::NONE, string $voiceFallbackUrl = Values::NONE, string $voiceFallbackMethod = Values::NONE, string $statusCallback = Values::NONE, string $statusCallbackMethod = Values::NONE, bool $voiceCallerIdLookup = Values::NONE, string $smsUrl = Values::NONE, string $smsMethod = Values::NONE, string $smsFallbackUrl = Values::NONE, string $smsFallbackMethod = Values::NONE, string $smsStatusCallback = Values::NONE, string $messageStatusCallback = Values::NONE, string $friendlyName = Values::NONE, bool $publicApplicationConnectEnabled = Values::NONE) {
$this->options['apiVersion'] = $apiVersion;
$this->options['voiceUrl'] = $voiceUrl;
$this->options['voiceMethod'] = $voiceMethod;
$this->options['voiceFallbackUrl'] = $voiceFallbackUrl;
$this->options['voiceFallbackMethod'] = $voiceFallbackMethod;
$this->options['statusCallback'] = $statusCallback;
$this->options['statusCallbackMethod'] = $statusCallbackMethod;
$this->options['voiceCallerIdLookup'] = $voiceCallerIdLookup;
$this->options['smsUrl'] = $smsUrl;
$this->options['smsMethod'] = $smsMethod;
$this->options['smsFallbackUrl'] = $smsFallbackUrl;
$this->options['smsFallbackMethod'] = $smsFallbackMethod;
$this->options['smsStatusCallback'] = $smsStatusCallback;
$this->options['messageStatusCallback'] = $messageStatusCallback;
$this->options['friendlyName'] = $friendlyName;
$this->options['publicApplicationConnectEnabled'] = $publicApplicationConnectEnabled;
}
/**
* The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is the account's default API version.
*
* @param string $apiVersion The API version to use to start a new TwiML session
* @return $this Fluent Builder
*/
public function setApiVersion(string $apiVersion): self {
$this->options['apiVersion'] = $apiVersion;
return $this;
}
/**
* The URL we should call when the phone number assigned to this application receives a call.
*
* @param string $voiceUrl The URL to call when the phone number receives a call
* @return $this Fluent Builder
*/
public function setVoiceUrl(string $voiceUrl): self {
$this->options['voiceUrl'] = $voiceUrl;
return $this;
}
/**
* The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
*
* @param string $voiceMethod The HTTP method to use with the voice_url
* @return $this Fluent Builder
*/
public function setVoiceMethod(string $voiceMethod): self {
$this->options['voiceMethod'] = $voiceMethod;
return $this;
}
/**
* The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
*
* @param string $voiceFallbackUrl The URL to call when a TwiML error occurs
* @return $this Fluent Builder
*/
public function setVoiceFallbackUrl(string $voiceFallbackUrl): self {
$this->options['voiceFallbackUrl'] = $voiceFallbackUrl;
return $this;
}
/**
* The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
*
* @param string $voiceFallbackMethod The HTTP method to use with
* voice_fallback_url
* @return $this Fluent Builder
*/
public function setVoiceFallbackMethod(string $voiceFallbackMethod): self {
$this->options['voiceFallbackMethod'] = $voiceFallbackMethod;
return $this;
}
/**
* The URL we should call using the `status_callback_method` to send status information to your application.
*
* @param string $statusCallback The URL to send status information to your
* application
* @return $this Fluent Builder
*/
public function setStatusCallback(string $statusCallback): self {
$this->options['statusCallback'] = $statusCallback;
return $this;
}
/**
* The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
*
* @param string $statusCallbackMethod The HTTP method to use to call
* status_callback
* @return $this Fluent Builder
*/
public function setStatusCallbackMethod(string $statusCallbackMethod): self {
$this->options['statusCallbackMethod'] = $statusCallbackMethod;
return $this;
}
/**
* Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
*
* @param bool $voiceCallerIdLookup Whether to lookup the caller's name
* @return $this Fluent Builder
*/
public function setVoiceCallerIdLookup(bool $voiceCallerIdLookup): self {
$this->options['voiceCallerIdLookup'] = $voiceCallerIdLookup;
return $this;
}
/**
* The URL we should call when the phone number receives an incoming SMS message.
*
* @param string $smsUrl The URL to call when the phone number receives an
* incoming SMS message
* @return $this Fluent Builder
*/
public function setSmsUrl(string $smsUrl): self {
$this->options['smsUrl'] = $smsUrl;
return $this;
}
/**
* The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
*
* @param string $smsMethod The HTTP method to use with sms_url
* @return $this Fluent Builder
*/
public function setSmsMethod(string $smsMethod): self {
$this->options['smsMethod'] = $smsMethod;
return $this;
}
/**
* The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
*
* @param string $smsFallbackUrl The URL to call when an error occurs while
* retrieving or executing the TwiML
* @return $this Fluent Builder
*/
public function setSmsFallbackUrl(string $smsFallbackUrl): self {
$this->options['smsFallbackUrl'] = $smsFallbackUrl;
return $this;
}
/**
* The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
*
* @param string $smsFallbackMethod The HTTP method to use with sms_fallback_url
* @return $this Fluent Builder
*/
public function setSmsFallbackMethod(string $smsFallbackMethod): self {
$this->options['smsFallbackMethod'] = $smsFallbackMethod;
return $this;
}
/**
* The URL we should call using a POST method to send status information about SMS messages sent by the application.
*
* @param string $smsStatusCallback The URL to send status information to your
* application
* @return $this Fluent Builder
*/
public function setSmsStatusCallback(string $smsStatusCallback): self {
$this->options['smsStatusCallback'] = $smsStatusCallback;
return $this;
}
/**
* The URL we should call using a POST method to send message status information to your application.
*
* @param string $messageStatusCallback The URL to send message status
* information to your application
* @return $this Fluent Builder
*/
public function setMessageStatusCallback(string $messageStatusCallback): self {
$this->options['messageStatusCallback'] = $messageStatusCallback;
return $this;
}
/**
* A descriptive string that you create to describe the new application. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the new resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
*
* @param bool $publicApplicationConnectEnabled Whether to allow other Twilio
* accounts to dial this
* application
* @return $this Fluent Builder
*/
public function setPublicApplicationConnectEnabled(bool $publicApplicationConnectEnabled): self {
$this->options['publicApplicationConnectEnabled'] = $publicApplicationConnectEnabled;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.CreateApplicationOptions ' . $options . ']';
}
}
class ReadApplicationOptions extends Options {
/**
* @param string $friendlyName The string that identifies the Application
* resources to read
*/
public function __construct(string $friendlyName = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
}
/**
* The string that identifies the Application resources to read.
*
* @param string $friendlyName The string that identifies the Application
* resources to read
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.ReadApplicationOptions ' . $options . ']';
}
}
class UpdateApplicationOptions extends Options {
/**
* @param string $friendlyName A string to describe the resource
* @param string $apiVersion The API version to use to start a new TwiML session
* @param string $voiceUrl The URL to call when the phone number receives a call
* @param string $voiceMethod The HTTP method to use with the voice_url
* @param string $voiceFallbackUrl The URL to call when a TwiML error occurs
* @param string $voiceFallbackMethod The HTTP method to use with
* voice_fallback_url
* @param string $statusCallback The URL to send status information to your
* application
* @param string $statusCallbackMethod The HTTP method to use to call
* status_callback
* @param bool $voiceCallerIdLookup Whether to lookup the caller's name
* @param string $smsUrl The URL to call when the phone number receives an
* incoming SMS message
* @param string $smsMethod The HTTP method to use with sms_url
* @param string $smsFallbackUrl The URL to call when an error occurs while
* retrieving or executing the TwiML
* @param string $smsFallbackMethod The HTTP method to use with sms_fallback_url
* @param string $smsStatusCallback Same as message_status_callback.
* Deprecated, included for backwards
* compatibility.
* @param string $messageStatusCallback The URL to send message status
* information to your application
* @param bool $publicApplicationConnectEnabled Whether to allow other Twilio
* accounts to dial this
* application
*/
public function __construct(string $friendlyName = Values::NONE, string $apiVersion = Values::NONE, string $voiceUrl = Values::NONE, string $voiceMethod = Values::NONE, string $voiceFallbackUrl = Values::NONE, string $voiceFallbackMethod = Values::NONE, string $statusCallback = Values::NONE, string $statusCallbackMethod = Values::NONE, bool $voiceCallerIdLookup = Values::NONE, string $smsUrl = Values::NONE, string $smsMethod = Values::NONE, string $smsFallbackUrl = Values::NONE, string $smsFallbackMethod = Values::NONE, string $smsStatusCallback = Values::NONE, string $messageStatusCallback = Values::NONE, bool $publicApplicationConnectEnabled = Values::NONE) {
$this->options['friendlyName'] = $friendlyName;
$this->options['apiVersion'] = $apiVersion;
$this->options['voiceUrl'] = $voiceUrl;
$this->options['voiceMethod'] = $voiceMethod;
$this->options['voiceFallbackUrl'] = $voiceFallbackUrl;
$this->options['voiceFallbackMethod'] = $voiceFallbackMethod;
$this->options['statusCallback'] = $statusCallback;
$this->options['statusCallbackMethod'] = $statusCallbackMethod;
$this->options['voiceCallerIdLookup'] = $voiceCallerIdLookup;
$this->options['smsUrl'] = $smsUrl;
$this->options['smsMethod'] = $smsMethod;
$this->options['smsFallbackUrl'] = $smsFallbackUrl;
$this->options['smsFallbackMethod'] = $smsFallbackMethod;
$this->options['smsStatusCallback'] = $smsStatusCallback;
$this->options['messageStatusCallback'] = $messageStatusCallback;
$this->options['publicApplicationConnectEnabled'] = $publicApplicationConnectEnabled;
}
/**
* A descriptive string that you create to describe the resource. It can be up to 64 characters long.
*
* @param string $friendlyName A string to describe the resource
* @return $this Fluent Builder
*/
public function setFriendlyName(string $friendlyName): self {
$this->options['friendlyName'] = $friendlyName;
return $this;
}
/**
* The API version to use to start a new TwiML session. Can be: `2010-04-01` or `2008-08-01`. The default value is your account's default API version.
*
* @param string $apiVersion The API version to use to start a new TwiML session
* @return $this Fluent Builder
*/
public function setApiVersion(string $apiVersion): self {
$this->options['apiVersion'] = $apiVersion;
return $this;
}
/**
* The URL we should call when the phone number assigned to this application receives a call.
*
* @param string $voiceUrl The URL to call when the phone number receives a call
* @return $this Fluent Builder
*/
public function setVoiceUrl(string $voiceUrl): self {
$this->options['voiceUrl'] = $voiceUrl;
return $this;
}
/**
* The HTTP method we should use to call `voice_url`. Can be: `GET` or `POST`.
*
* @param string $voiceMethod The HTTP method to use with the voice_url
* @return $this Fluent Builder
*/
public function setVoiceMethod(string $voiceMethod): self {
$this->options['voiceMethod'] = $voiceMethod;
return $this;
}
/**
* The URL that we should call when an error occurs retrieving or executing the TwiML requested by `url`.
*
* @param string $voiceFallbackUrl The URL to call when a TwiML error occurs
* @return $this Fluent Builder
*/
public function setVoiceFallbackUrl(string $voiceFallbackUrl): self {
$this->options['voiceFallbackUrl'] = $voiceFallbackUrl;
return $this;
}
/**
* The HTTP method we should use to call `voice_fallback_url`. Can be: `GET` or `POST`.
*
* @param string $voiceFallbackMethod The HTTP method to use with
* voice_fallback_url
* @return $this Fluent Builder
*/
public function setVoiceFallbackMethod(string $voiceFallbackMethod): self {
$this->options['voiceFallbackMethod'] = $voiceFallbackMethod;
return $this;
}
/**
* The URL we should call using the `status_callback_method` to send status information to your application.
*
* @param string $statusCallback The URL to send status information to your
* application
* @return $this Fluent Builder
*/
public function setStatusCallback(string $statusCallback): self {
$this->options['statusCallback'] = $statusCallback;
return $this;
}
/**
* The HTTP method we should use to call `status_callback`. Can be: `GET` or `POST`.
*
* @param string $statusCallbackMethod The HTTP method to use to call
* status_callback
* @return $this Fluent Builder
*/
public function setStatusCallbackMethod(string $statusCallbackMethod): self {
$this->options['statusCallbackMethod'] = $statusCallbackMethod;
return $this;
}
/**
* Whether we should look up the caller's caller-ID name from the CNAM database (additional charges apply). Can be: `true` or `false`.
*
* @param bool $voiceCallerIdLookup Whether to lookup the caller's name
* @return $this Fluent Builder
*/
public function setVoiceCallerIdLookup(bool $voiceCallerIdLookup): self {
$this->options['voiceCallerIdLookup'] = $voiceCallerIdLookup;
return $this;
}
/**
* The URL we should call when the phone number receives an incoming SMS message.
*
* @param string $smsUrl The URL to call when the phone number receives an
* incoming SMS message
* @return $this Fluent Builder
*/
public function setSmsUrl(string $smsUrl): self {
$this->options['smsUrl'] = $smsUrl;
return $this;
}
/**
* The HTTP method we should use to call `sms_url`. Can be: `GET` or `POST`.
*
* @param string $smsMethod The HTTP method to use with sms_url
* @return $this Fluent Builder
*/
public function setSmsMethod(string $smsMethod): self {
$this->options['smsMethod'] = $smsMethod;
return $this;
}
/**
* The URL that we should call when an error occurs while retrieving or executing the TwiML from `sms_url`.
*
* @param string $smsFallbackUrl The URL to call when an error occurs while
* retrieving or executing the TwiML
* @return $this Fluent Builder
*/
public function setSmsFallbackUrl(string $smsFallbackUrl): self {
$this->options['smsFallbackUrl'] = $smsFallbackUrl;
return $this;
}
/**
* The HTTP method we should use to call `sms_fallback_url`. Can be: `GET` or `POST`.
*
* @param string $smsFallbackMethod The HTTP method to use with sms_fallback_url
* @return $this Fluent Builder
*/
public function setSmsFallbackMethod(string $smsFallbackMethod): self {
$this->options['smsFallbackMethod'] = $smsFallbackMethod;
return $this;
}
/**
* Same as message_status_callback: The URL we should call using a POST method to send status information about SMS messages sent by the application. Deprecated, included for backwards compatibility.
*
* @param string $smsStatusCallback Same as message_status_callback.
* Deprecated, included for backwards
* compatibility.
* @return $this Fluent Builder
*/
public function setSmsStatusCallback(string $smsStatusCallback): self {
$this->options['smsStatusCallback'] = $smsStatusCallback;
return $this;
}
/**
* The URL we should call using a POST method to send message status information to your application.
*
* @param string $messageStatusCallback The URL to send message status
* information to your application
* @return $this Fluent Builder
*/
public function setMessageStatusCallback(string $messageStatusCallback): self {
$this->options['messageStatusCallback'] = $messageStatusCallback;
return $this;
}
/**
* Whether to allow other Twilio accounts to dial this applicaton using Dial verb. Can be: `true` or `false`.
*
* @param bool $publicApplicationConnectEnabled Whether to allow other Twilio
* accounts to dial this
* application
* @return $this Fluent Builder
*/
public function setPublicApplicationConnectEnabled(bool $publicApplicationConnectEnabled): self {
$this->options['publicApplicationConnectEnabled'] = $publicApplicationConnectEnabled;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.UpdateApplicationOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class ApplicationPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return ApplicationInstance \Twilio\Rest\Api\V2010\Account\ApplicationInstance
*/
public function buildInstance(array $payload): ApplicationInstance {
return new ApplicationInstance($this->version, $payload, $this->solution['accountSid']);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.ApplicationPage]';
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceContext;
use Twilio\Values;
use Twilio\Version;
class AuthorizedConnectAppContext extends InstanceContext {
/**
* Initialize the AuthorizedConnectAppContext
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that created the resource
* to fetch
* @param string $connectAppSid The SID of the Connect App to fetch
*/
public function __construct(Version $version, $accountSid, $connectAppSid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'connectAppSid' => $connectAppSid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/AuthorizedConnectApps/' . \rawurlencode($connectAppSid) . '.json';
}
/**
* Fetch the AuthorizedConnectAppInstance
*
* @return AuthorizedConnectAppInstance Fetched AuthorizedConnectAppInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AuthorizedConnectAppInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new AuthorizedConnectAppInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['connectAppSid']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.AuthorizedConnectAppContext ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Deserialize;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $accountSid
* @property string $connectAppCompanyName
* @property string $connectAppDescription
* @property string $connectAppFriendlyName
* @property string $connectAppHomepageUrl
* @property string $connectAppSid
* @property \DateTime $dateCreated
* @property \DateTime $dateUpdated
* @property string[] $permissions
* @property string $uri
*/
class AuthorizedConnectAppInstance extends InstanceResource {
/**
* Initialize the AuthorizedConnectAppInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The SID of the Account that created the resource
* @param string $connectAppSid The SID of the Connect App to fetch
*/
public function __construct(Version $version, array $payload, string $accountSid, string $connectAppSid = null) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'accountSid' => Values::array_get($payload, 'account_sid'),
'connectAppCompanyName' => Values::array_get($payload, 'connect_app_company_name'),
'connectAppDescription' => Values::array_get($payload, 'connect_app_description'),
'connectAppFriendlyName' => Values::array_get($payload, 'connect_app_friendly_name'),
'connectAppHomepageUrl' => Values::array_get($payload, 'connect_app_homepage_url'),
'connectAppSid' => Values::array_get($payload, 'connect_app_sid'),
'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
'permissions' => Values::array_get($payload, 'permissions'),
'uri' => Values::array_get($payload, 'uri'),
];
$this->solution = [
'accountSid' => $accountSid,
'connectAppSid' => $connectAppSid ?: $this->properties['connectAppSid'],
];
}
/**
* Generate an instance context for the instance, the context is capable of
* performing various actions. All instance actions are proxied to the context
*
* @return AuthorizedConnectAppContext Context for this
* AuthorizedConnectAppInstance
*/
protected function proxy(): AuthorizedConnectAppContext {
if (!$this->context) {
$this->context = new AuthorizedConnectAppContext(
$this->version,
$this->solution['accountSid'],
$this->solution['connectAppSid']
);
}
return $this->context;
}
/**
* Fetch the AuthorizedConnectAppInstance
*
* @return AuthorizedConnectAppInstance Fetched AuthorizedConnectAppInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): AuthorizedConnectAppInstance {
return $this->proxy()->fetch();
}
/**
* 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 {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Api.V2010.AuthorizedConnectAppInstance ' . \implode(' ', $context) . ']';
}
}

View File

@@ -0,0 +1,134 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\ListResource;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class AuthorizedConnectAppList extends ListResource {
/**
* Construct the AuthorizedConnectAppList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The SID of the Account that created the resource
*/
public function __construct(Version $version, string $accountSid) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/AuthorizedConnectApps.json';
}
/**
* Streams AuthorizedConnectAppInstance records from the API as a generator
* stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads AuthorizedConnectAppInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return AuthorizedConnectAppInstance[] Array of results
*/
public function read(int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($limit, $pageSize), false);
}
/**
* Retrieve a single page of AuthorizedConnectAppInstance records from the API.
* Request is executed immediately
*
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return AuthorizedConnectAppPage Page of AuthorizedConnectAppInstance
*/
public function page($pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): AuthorizedConnectAppPage {
$params = Values::of(['PageToken' => $pageToken, 'Page' => $pageNumber, 'PageSize' => $pageSize, ]);
$response = $this->version->page('GET', $this->uri, $params);
return new AuthorizedConnectAppPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of AuthorizedConnectAppInstance records from the
* API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return AuthorizedConnectAppPage Page of AuthorizedConnectAppInstance
*/
public function getPage(string $targetUrl): AuthorizedConnectAppPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new AuthorizedConnectAppPage($this->version, $response, $this->solution);
}
/**
* Constructs a AuthorizedConnectAppContext
*
* @param string $connectAppSid The SID of the Connect App to fetch
*/
public function getContext(string $connectAppSid): AuthorizedConnectAppContext {
return new AuthorizedConnectAppContext(
$this->version,
$this->solution['accountSid'],
$connectAppSid
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.AuthorizedConnectAppList]';
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class AuthorizedConnectAppPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return AuthorizedConnectAppInstance \Twilio\Rest\Api\V2010\Account\AuthorizedConnectAppInstance
*/
public function buildInstance(array $payload): AuthorizedConnectAppInstance {
return new AuthorizedConnectAppInstance($this->version, $payload, $this->solution['accountSid']);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.AuthorizedConnectAppPage]';
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $friendlyName
* @property string $phoneNumber
* @property string $lata
* @property string $locality
* @property string $rateCenter
* @property string $latitude
* @property string $longitude
* @property string $region
* @property string $postalCode
* @property string $isoCountry
* @property string $addressRequirements
* @property bool $beta
* @property string $capabilities
*/
class LocalInstance extends InstanceResource {
/**
* Initialize the LocalInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, array $payload, string $accountSid, string $countryCode) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
'lata' => Values::array_get($payload, 'lata'),
'locality' => Values::array_get($payload, 'locality'),
'rateCenter' => Values::array_get($payload, 'rate_center'),
'latitude' => Values::array_get($payload, 'latitude'),
'longitude' => Values::array_get($payload, 'longitude'),
'region' => Values::array_get($payload, 'region'),
'postalCode' => Values::array_get($payload, 'postal_code'),
'isoCountry' => Values::array_get($payload, 'iso_country'),
'addressRequirements' => Values::array_get($payload, 'address_requirements'),
'beta' => Values::array_get($payload, 'beta'),
'capabilities' => Values::array_get($payload, 'capabilities'),
];
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
}
/**
* 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.Api.V2010.LocalInstance]';
}
}

View File

@@ -0,0 +1,149 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Serialize;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class LocalList extends ListResource {
/**
* Construct the LocalList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, string $accountSid, string $countryCode) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/AvailablePhoneNumbers/' . \rawurlencode($countryCode) . '/Local.json';
}
/**
* Streams LocalInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(array $options = [], int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads LocalInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return LocalInstance[] Array of results
*/
public function read(array $options = [], int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
}
/**
* Retrieve a single page of LocalInstance records from the API.
* Request is executed immediately
*
* @param array|Options $options Optional Arguments
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return LocalPage Page of LocalInstance
*/
public function page(array $options = [], $pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): LocalPage {
$options = new Values($options);
$params = Values::of([
'AreaCode' => $options['areaCode'],
'Contains' => $options['contains'],
'SmsEnabled' => Serialize::booleanToString($options['smsEnabled']),
'MmsEnabled' => Serialize::booleanToString($options['mmsEnabled']),
'VoiceEnabled' => Serialize::booleanToString($options['voiceEnabled']),
'ExcludeAllAddressRequired' => Serialize::booleanToString($options['excludeAllAddressRequired']),
'ExcludeLocalAddressRequired' => Serialize::booleanToString($options['excludeLocalAddressRequired']),
'ExcludeForeignAddressRequired' => Serialize::booleanToString($options['excludeForeignAddressRequired']),
'Beta' => Serialize::booleanToString($options['beta']),
'NearNumber' => $options['nearNumber'],
'NearLatLong' => $options['nearLatLong'],
'Distance' => $options['distance'],
'InPostalCode' => $options['inPostalCode'],
'InRegion' => $options['inRegion'],
'InRateCenter' => $options['inRateCenter'],
'InLata' => $options['inLata'],
'InLocality' => $options['inLocality'],
'FaxEnabled' => Serialize::booleanToString($options['faxEnabled']),
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$response = $this->version->page('GET', $this->uri, $params);
return new LocalPage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of LocalInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return LocalPage Page of LocalInstance
*/
public function getPage(string $targetUrl): LocalPage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new LocalPage($this->version, $response, $this->solution);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.LocalList]';
}
}

View File

@@ -0,0 +1,327 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Options;
use Twilio\Values;
abstract class LocalOptions {
/**
* @param int $areaCode The area code of the phone numbers to read
* @param string $contains The pattern on which to match phone numbers
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @param string $inLocality Limit results to a particular locality
* @param bool $faxEnabled Whether the phone numbers can receive faxes
* @return ReadLocalOptions Options builder
*/
public static function read(int $areaCode = Values::NONE, string $contains = Values::NONE, bool $smsEnabled = Values::NONE, bool $mmsEnabled = Values::NONE, bool $voiceEnabled = Values::NONE, bool $excludeAllAddressRequired = Values::NONE, bool $excludeLocalAddressRequired = Values::NONE, bool $excludeForeignAddressRequired = Values::NONE, bool $beta = Values::NONE, string $nearNumber = Values::NONE, string $nearLatLong = Values::NONE, int $distance = Values::NONE, string $inPostalCode = Values::NONE, string $inRegion = Values::NONE, string $inRateCenter = Values::NONE, string $inLata = Values::NONE, string $inLocality = Values::NONE, bool $faxEnabled = Values::NONE): ReadLocalOptions {
return new ReadLocalOptions($areaCode, $contains, $smsEnabled, $mmsEnabled, $voiceEnabled, $excludeAllAddressRequired, $excludeLocalAddressRequired, $excludeForeignAddressRequired, $beta, $nearNumber, $nearLatLong, $distance, $inPostalCode, $inRegion, $inRateCenter, $inLata, $inLocality, $faxEnabled);
}
}
class ReadLocalOptions extends Options {
/**
* @param int $areaCode The area code of the phone numbers to read
* @param string $contains The pattern on which to match phone numbers
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @param string $inLocality Limit results to a particular locality
* @param bool $faxEnabled Whether the phone numbers can receive faxes
*/
public function __construct(int $areaCode = Values::NONE, string $contains = Values::NONE, bool $smsEnabled = Values::NONE, bool $mmsEnabled = Values::NONE, bool $voiceEnabled = Values::NONE, bool $excludeAllAddressRequired = Values::NONE, bool $excludeLocalAddressRequired = Values::NONE, bool $excludeForeignAddressRequired = Values::NONE, bool $beta = Values::NONE, string $nearNumber = Values::NONE, string $nearLatLong = Values::NONE, int $distance = Values::NONE, string $inPostalCode = Values::NONE, string $inRegion = Values::NONE, string $inRateCenter = Values::NONE, string $inLata = Values::NONE, string $inLocality = Values::NONE, bool $faxEnabled = Values::NONE) {
$this->options['areaCode'] = $areaCode;
$this->options['contains'] = $contains;
$this->options['smsEnabled'] = $smsEnabled;
$this->options['mmsEnabled'] = $mmsEnabled;
$this->options['voiceEnabled'] = $voiceEnabled;
$this->options['excludeAllAddressRequired'] = $excludeAllAddressRequired;
$this->options['excludeLocalAddressRequired'] = $excludeLocalAddressRequired;
$this->options['excludeForeignAddressRequired'] = $excludeForeignAddressRequired;
$this->options['beta'] = $beta;
$this->options['nearNumber'] = $nearNumber;
$this->options['nearLatLong'] = $nearLatLong;
$this->options['distance'] = $distance;
$this->options['inPostalCode'] = $inPostalCode;
$this->options['inRegion'] = $inRegion;
$this->options['inRateCenter'] = $inRateCenter;
$this->options['inLata'] = $inLata;
$this->options['inLocality'] = $inLocality;
$this->options['faxEnabled'] = $faxEnabled;
}
/**
* The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
*
* @param int $areaCode The area code of the phone numbers to read
* @return $this Fluent Builder
*/
public function setAreaCode(int $areaCode): self {
$this->options['areaCode'] = $areaCode;
return $this;
}
/**
* The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-character-pattern). If specified, this value must have at least two characters.
*
* @param string $contains The pattern on which to match phone numbers
* @return $this Fluent Builder
*/
public function setContains(string $contains): self {
$this->options['contains'] = $contains;
return $this;
}
/**
* Whether the phone numbers can receive text messages. Can be: `true` or `false`.
*
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @return $this Fluent Builder
*/
public function setSmsEnabled(bool $smsEnabled): self {
$this->options['smsEnabled'] = $smsEnabled;
return $this;
}
/**
* Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
*
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @return $this Fluent Builder
*/
public function setMmsEnabled(bool $mmsEnabled): self {
$this->options['mmsEnabled'] = $mmsEnabled;
return $this;
}
/**
* Whether the phone numbers can receive calls. Can be: `true` or `false`.
*
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @return $this Fluent Builder
*/
public function setVoiceEnabled(bool $voiceEnabled): self {
$this->options['voiceEnabled'] = $voiceEnabled;
return $this;
}
/**
* Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @return $this Fluent Builder
*/
public function setExcludeAllAddressRequired(bool $excludeAllAddressRequired): self {
$this->options['excludeAllAddressRequired'] = $excludeAllAddressRequired;
return $this;
}
/**
* Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @return $this Fluent Builder
*/
public function setExcludeLocalAddressRequired(bool $excludeLocalAddressRequired): self {
$this->options['excludeLocalAddressRequired'] = $excludeLocalAddressRequired;
return $this;
}
/**
* Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @return $this Fluent Builder
*/
public function setExcludeForeignAddressRequired(bool $excludeForeignAddressRequired): self {
$this->options['excludeForeignAddressRequired'] = $excludeForeignAddressRequired;
return $this;
}
/**
* Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
*
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @return $this Fluent Builder
*/
public function setBeta(bool $beta): self {
$this->options['beta'] = $beta;
return $this;
}
/**
* Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
*
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @return $this Fluent Builder
*/
public function setNearNumber(string $nearNumber): self {
$this->options['nearNumber'] = $nearNumber;
return $this;
}
/**
* Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
*
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @return $this Fluent Builder
*/
public function setNearLatLong(string $nearLatLong): self {
$this->options['nearLatLong'] = $nearLatLong;
return $this;
}
/**
* The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
*
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @return $this Fluent Builder
*/
public function setDistance(int $distance): self {
$this->options['distance'] = $distance;
return $this;
}
/**
* Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @return $this Fluent Builder
*/
public function setInPostalCode(string $inPostalCode): self {
$this->options['inPostalCode'] = $inPostalCode;
return $this;
}
/**
* Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @return $this Fluent Builder
*/
public function setInRegion(string $inRegion): self {
$this->options['inRegion'] = $inRegion;
return $this;
}
/**
* Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
*
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @return $this Fluent Builder
*/
public function setInRateCenter(string $inRateCenter): self {
$this->options['inRateCenter'] = $inRateCenter;
return $this;
}
/**
* Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @return $this Fluent Builder
*/
public function setInLata(string $inLata): self {
$this->options['inLata'] = $inLata;
return $this;
}
/**
* Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
*
* @param string $inLocality Limit results to a particular locality
* @return $this Fluent Builder
*/
public function setInLocality(string $inLocality): self {
$this->options['inLocality'] = $inLocality;
return $this;
}
/**
* Whether the phone numbers can receive faxes. Can be: `true` or `false`.
*
* @param bool $faxEnabled Whether the phone numbers can receive faxes
* @return $this Fluent Builder
*/
public function setFaxEnabled(bool $faxEnabled): self {
$this->options['faxEnabled'] = $faxEnabled;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.ReadLocalOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class LocalPage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return LocalInstance \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\LocalInstance
*/
public function buildInstance(array $payload): LocalInstance {
return new LocalInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.LocalPage]';
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $friendlyName
* @property string $phoneNumber
* @property string $lata
* @property string $locality
* @property string $rateCenter
* @property string $latitude
* @property string $longitude
* @property string $region
* @property string $postalCode
* @property string $isoCountry
* @property string $addressRequirements
* @property bool $beta
* @property string $capabilities
*/
class MachineToMachineInstance extends InstanceResource {
/**
* Initialize the MachineToMachineInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, array $payload, string $accountSid, string $countryCode) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
'lata' => Values::array_get($payload, 'lata'),
'locality' => Values::array_get($payload, 'locality'),
'rateCenter' => Values::array_get($payload, 'rate_center'),
'latitude' => Values::array_get($payload, 'latitude'),
'longitude' => Values::array_get($payload, 'longitude'),
'region' => Values::array_get($payload, 'region'),
'postalCode' => Values::array_get($payload, 'postal_code'),
'isoCountry' => Values::array_get($payload, 'iso_country'),
'addressRequirements' => Values::array_get($payload, 'address_requirements'),
'beta' => Values::array_get($payload, 'beta'),
'capabilities' => Values::array_get($payload, 'capabilities'),
];
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
}
/**
* 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.Api.V2010.MachineToMachineInstance]';
}
}

View File

@@ -0,0 +1,149 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Serialize;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class MachineToMachineList extends ListResource {
/**
* Construct the MachineToMachineList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, string $accountSid, string $countryCode) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/AvailablePhoneNumbers/' . \rawurlencode($countryCode) . '/MachineToMachine.json';
}
/**
* Streams MachineToMachineInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(array $options = [], int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads MachineToMachineInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return MachineToMachineInstance[] Array of results
*/
public function read(array $options = [], int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
}
/**
* Retrieve a single page of MachineToMachineInstance records from the API.
* Request is executed immediately
*
* @param array|Options $options Optional Arguments
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return MachineToMachinePage Page of MachineToMachineInstance
*/
public function page(array $options = [], $pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): MachineToMachinePage {
$options = new Values($options);
$params = Values::of([
'AreaCode' => $options['areaCode'],
'Contains' => $options['contains'],
'SmsEnabled' => Serialize::booleanToString($options['smsEnabled']),
'MmsEnabled' => Serialize::booleanToString($options['mmsEnabled']),
'VoiceEnabled' => Serialize::booleanToString($options['voiceEnabled']),
'ExcludeAllAddressRequired' => Serialize::booleanToString($options['excludeAllAddressRequired']),
'ExcludeLocalAddressRequired' => Serialize::booleanToString($options['excludeLocalAddressRequired']),
'ExcludeForeignAddressRequired' => Serialize::booleanToString($options['excludeForeignAddressRequired']),
'Beta' => Serialize::booleanToString($options['beta']),
'NearNumber' => $options['nearNumber'],
'NearLatLong' => $options['nearLatLong'],
'Distance' => $options['distance'],
'InPostalCode' => $options['inPostalCode'],
'InRegion' => $options['inRegion'],
'InRateCenter' => $options['inRateCenter'],
'InLata' => $options['inLata'],
'InLocality' => $options['inLocality'],
'FaxEnabled' => Serialize::booleanToString($options['faxEnabled']),
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$response = $this->version->page('GET', $this->uri, $params);
return new MachineToMachinePage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of MachineToMachineInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return MachineToMachinePage Page of MachineToMachineInstance
*/
public function getPage(string $targetUrl): MachineToMachinePage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new MachineToMachinePage($this->version, $response, $this->solution);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.MachineToMachineList]';
}
}

View File

@@ -0,0 +1,327 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Options;
use Twilio\Values;
abstract class MachineToMachineOptions {
/**
* @param int $areaCode The area code of the phone numbers to read
* @param string $contains The pattern on which to match phone numbers
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @param string $inLocality Limit results to a particular locality
* @param bool $faxEnabled Whether the phone numbers can receive faxes
* @return ReadMachineToMachineOptions Options builder
*/
public static function read(int $areaCode = Values::NONE, string $contains = Values::NONE, bool $smsEnabled = Values::NONE, bool $mmsEnabled = Values::NONE, bool $voiceEnabled = Values::NONE, bool $excludeAllAddressRequired = Values::NONE, bool $excludeLocalAddressRequired = Values::NONE, bool $excludeForeignAddressRequired = Values::NONE, bool $beta = Values::NONE, string $nearNumber = Values::NONE, string $nearLatLong = Values::NONE, int $distance = Values::NONE, string $inPostalCode = Values::NONE, string $inRegion = Values::NONE, string $inRateCenter = Values::NONE, string $inLata = Values::NONE, string $inLocality = Values::NONE, bool $faxEnabled = Values::NONE): ReadMachineToMachineOptions {
return new ReadMachineToMachineOptions($areaCode, $contains, $smsEnabled, $mmsEnabled, $voiceEnabled, $excludeAllAddressRequired, $excludeLocalAddressRequired, $excludeForeignAddressRequired, $beta, $nearNumber, $nearLatLong, $distance, $inPostalCode, $inRegion, $inRateCenter, $inLata, $inLocality, $faxEnabled);
}
}
class ReadMachineToMachineOptions extends Options {
/**
* @param int $areaCode The area code of the phone numbers to read
* @param string $contains The pattern on which to match phone numbers
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @param string $inLocality Limit results to a particular locality
* @param bool $faxEnabled Whether the phone numbers can receive faxes
*/
public function __construct(int $areaCode = Values::NONE, string $contains = Values::NONE, bool $smsEnabled = Values::NONE, bool $mmsEnabled = Values::NONE, bool $voiceEnabled = Values::NONE, bool $excludeAllAddressRequired = Values::NONE, bool $excludeLocalAddressRequired = Values::NONE, bool $excludeForeignAddressRequired = Values::NONE, bool $beta = Values::NONE, string $nearNumber = Values::NONE, string $nearLatLong = Values::NONE, int $distance = Values::NONE, string $inPostalCode = Values::NONE, string $inRegion = Values::NONE, string $inRateCenter = Values::NONE, string $inLata = Values::NONE, string $inLocality = Values::NONE, bool $faxEnabled = Values::NONE) {
$this->options['areaCode'] = $areaCode;
$this->options['contains'] = $contains;
$this->options['smsEnabled'] = $smsEnabled;
$this->options['mmsEnabled'] = $mmsEnabled;
$this->options['voiceEnabled'] = $voiceEnabled;
$this->options['excludeAllAddressRequired'] = $excludeAllAddressRequired;
$this->options['excludeLocalAddressRequired'] = $excludeLocalAddressRequired;
$this->options['excludeForeignAddressRequired'] = $excludeForeignAddressRequired;
$this->options['beta'] = $beta;
$this->options['nearNumber'] = $nearNumber;
$this->options['nearLatLong'] = $nearLatLong;
$this->options['distance'] = $distance;
$this->options['inPostalCode'] = $inPostalCode;
$this->options['inRegion'] = $inRegion;
$this->options['inRateCenter'] = $inRateCenter;
$this->options['inLata'] = $inLata;
$this->options['inLocality'] = $inLocality;
$this->options['faxEnabled'] = $faxEnabled;
}
/**
* The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
*
* @param int $areaCode The area code of the phone numbers to read
* @return $this Fluent Builder
*/
public function setAreaCode(int $areaCode): self {
$this->options['areaCode'] = $areaCode;
return $this;
}
/**
* The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
*
* @param string $contains The pattern on which to match phone numbers
* @return $this Fluent Builder
*/
public function setContains(string $contains): self {
$this->options['contains'] = $contains;
return $this;
}
/**
* Whether the phone numbers can receive text messages. Can be: `true` or `false`.
*
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @return $this Fluent Builder
*/
public function setSmsEnabled(bool $smsEnabled): self {
$this->options['smsEnabled'] = $smsEnabled;
return $this;
}
/**
* Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
*
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @return $this Fluent Builder
*/
public function setMmsEnabled(bool $mmsEnabled): self {
$this->options['mmsEnabled'] = $mmsEnabled;
return $this;
}
/**
* Whether the phone numbers can receive calls. Can be: `true` or `false`.
*
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @return $this Fluent Builder
*/
public function setVoiceEnabled(bool $voiceEnabled): self {
$this->options['voiceEnabled'] = $voiceEnabled;
return $this;
}
/**
* Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @return $this Fluent Builder
*/
public function setExcludeAllAddressRequired(bool $excludeAllAddressRequired): self {
$this->options['excludeAllAddressRequired'] = $excludeAllAddressRequired;
return $this;
}
/**
* Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @return $this Fluent Builder
*/
public function setExcludeLocalAddressRequired(bool $excludeLocalAddressRequired): self {
$this->options['excludeLocalAddressRequired'] = $excludeLocalAddressRequired;
return $this;
}
/**
* Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @return $this Fluent Builder
*/
public function setExcludeForeignAddressRequired(bool $excludeForeignAddressRequired): self {
$this->options['excludeForeignAddressRequired'] = $excludeForeignAddressRequired;
return $this;
}
/**
* Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
*
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @return $this Fluent Builder
*/
public function setBeta(bool $beta): self {
$this->options['beta'] = $beta;
return $this;
}
/**
* Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
*
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @return $this Fluent Builder
*/
public function setNearNumber(string $nearNumber): self {
$this->options['nearNumber'] = $nearNumber;
return $this;
}
/**
* Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
*
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @return $this Fluent Builder
*/
public function setNearLatLong(string $nearLatLong): self {
$this->options['nearLatLong'] = $nearLatLong;
return $this;
}
/**
* The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
*
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @return $this Fluent Builder
*/
public function setDistance(int $distance): self {
$this->options['distance'] = $distance;
return $this;
}
/**
* Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @return $this Fluent Builder
*/
public function setInPostalCode(string $inPostalCode): self {
$this->options['inPostalCode'] = $inPostalCode;
return $this;
}
/**
* Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @return $this Fluent Builder
*/
public function setInRegion(string $inRegion): self {
$this->options['inRegion'] = $inRegion;
return $this;
}
/**
* Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
*
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @return $this Fluent Builder
*/
public function setInRateCenter(string $inRateCenter): self {
$this->options['inRateCenter'] = $inRateCenter;
return $this;
}
/**
* Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @return $this Fluent Builder
*/
public function setInLata(string $inLata): self {
$this->options['inLata'] = $inLata;
return $this;
}
/**
* Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
*
* @param string $inLocality Limit results to a particular locality
* @return $this Fluent Builder
*/
public function setInLocality(string $inLocality): self {
$this->options['inLocality'] = $inLocality;
return $this;
}
/**
* Whether the phone numbers can receive faxes. Can be: `true` or `false`.
*
* @param bool $faxEnabled Whether the phone numbers can receive faxes
* @return $this Fluent Builder
*/
public function setFaxEnabled(bool $faxEnabled): self {
$this->options['faxEnabled'] = $faxEnabled;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.ReadMachineToMachineOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class MachineToMachinePage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return MachineToMachineInstance \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\MachineToMachineInstance
*/
public function buildInstance(array $payload): MachineToMachineInstance {
return new MachineToMachineInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.MachineToMachinePage]';
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $friendlyName
* @property string $phoneNumber
* @property string $lata
* @property string $locality
* @property string $rateCenter
* @property string $latitude
* @property string $longitude
* @property string $region
* @property string $postalCode
* @property string $isoCountry
* @property string $addressRequirements
* @property bool $beta
* @property string $capabilities
*/
class MobileInstance extends InstanceResource {
/**
* Initialize the MobileInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, array $payload, string $accountSid, string $countryCode) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
'lata' => Values::array_get($payload, 'lata'),
'locality' => Values::array_get($payload, 'locality'),
'rateCenter' => Values::array_get($payload, 'rate_center'),
'latitude' => Values::array_get($payload, 'latitude'),
'longitude' => Values::array_get($payload, 'longitude'),
'region' => Values::array_get($payload, 'region'),
'postalCode' => Values::array_get($payload, 'postal_code'),
'isoCountry' => Values::array_get($payload, 'iso_country'),
'addressRequirements' => Values::array_get($payload, 'address_requirements'),
'beta' => Values::array_get($payload, 'beta'),
'capabilities' => Values::array_get($payload, 'capabilities'),
];
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
}
/**
* 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.Api.V2010.MobileInstance]';
}
}

View File

@@ -0,0 +1,149 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\ListResource;
use Twilio\Options;
use Twilio\Serialize;
use Twilio\Stream;
use Twilio\Values;
use Twilio\Version;
class MobileList extends ListResource {
/**
* Construct the MobileList
*
* @param Version $version Version that contains the resource
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, string $accountSid, string $countryCode) {
parent::__construct($version);
// Path Solution
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
$this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/AvailablePhoneNumbers/' . \rawurlencode($countryCode) . '/Mobile.json';
}
/**
* Streams MobileInstance records from the API as a generator stream.
* This operation lazily loads records as efficiently as possible until the
* limit
* is reached.
* The results are returned as a generator, so this operation is memory
* efficient.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. stream()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, stream()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return Stream stream of results
*/
public function stream(array $options = [], int $limit = null, $pageSize = null): Stream {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
}
/**
* Reads MobileInstance records from the API as a list.
* Unlike stream(), this operation is eager and will load `limit` records into
* memory before returning.
*
* @param array|Options $options Optional Arguments
* @param int $limit Upper limit for the number of records to return. read()
* guarantees to never return more than limit. Default is no
* limit
* @param mixed $pageSize Number of records to fetch per request, when not set
* will use the default value of 50 records. If no
* page_size is defined but a limit is defined, read()
* will attempt to read the limit with the most
* efficient page size, i.e. min(limit, 1000)
* @return MobileInstance[] Array of results
*/
public function read(array $options = [], int $limit = null, $pageSize = null): array {
return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
}
/**
* Retrieve a single page of MobileInstance records from the API.
* Request is executed immediately
*
* @param array|Options $options Optional Arguments
* @param mixed $pageSize Number of records to return, defaults to 50
* @param string $pageToken PageToken provided by the API
* @param mixed $pageNumber Page Number, this value is simply for client state
* @return MobilePage Page of MobileInstance
*/
public function page(array $options = [], $pageSize = Values::NONE, string $pageToken = Values::NONE, $pageNumber = Values::NONE): MobilePage {
$options = new Values($options);
$params = Values::of([
'AreaCode' => $options['areaCode'],
'Contains' => $options['contains'],
'SmsEnabled' => Serialize::booleanToString($options['smsEnabled']),
'MmsEnabled' => Serialize::booleanToString($options['mmsEnabled']),
'VoiceEnabled' => Serialize::booleanToString($options['voiceEnabled']),
'ExcludeAllAddressRequired' => Serialize::booleanToString($options['excludeAllAddressRequired']),
'ExcludeLocalAddressRequired' => Serialize::booleanToString($options['excludeLocalAddressRequired']),
'ExcludeForeignAddressRequired' => Serialize::booleanToString($options['excludeForeignAddressRequired']),
'Beta' => Serialize::booleanToString($options['beta']),
'NearNumber' => $options['nearNumber'],
'NearLatLong' => $options['nearLatLong'],
'Distance' => $options['distance'],
'InPostalCode' => $options['inPostalCode'],
'InRegion' => $options['inRegion'],
'InRateCenter' => $options['inRateCenter'],
'InLata' => $options['inLata'],
'InLocality' => $options['inLocality'],
'FaxEnabled' => Serialize::booleanToString($options['faxEnabled']),
'PageToken' => $pageToken,
'Page' => $pageNumber,
'PageSize' => $pageSize,
]);
$response = $this->version->page('GET', $this->uri, $params);
return new MobilePage($this->version, $response, $this->solution);
}
/**
* Retrieve a specific page of MobileInstance records from the API.
* Request is executed immediately
*
* @param string $targetUrl API-generated URL for the requested results page
* @return MobilePage Page of MobileInstance
*/
public function getPage(string $targetUrl): MobilePage {
$response = $this->version->getDomain()->getClient()->request(
'GET',
$targetUrl
);
return new MobilePage($this->version, $response, $this->solution);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.MobileList]';
}
}

View File

@@ -0,0 +1,327 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Options;
use Twilio\Values;
abstract class MobileOptions {
/**
* @param int $areaCode The area code of the phone numbers to read
* @param string $contains The pattern on which to match phone numbers
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @param string $inLocality Limit results to a particular locality
* @param bool $faxEnabled Whether the phone numbers can receive faxes
* @return ReadMobileOptions Options builder
*/
public static function read(int $areaCode = Values::NONE, string $contains = Values::NONE, bool $smsEnabled = Values::NONE, bool $mmsEnabled = Values::NONE, bool $voiceEnabled = Values::NONE, bool $excludeAllAddressRequired = Values::NONE, bool $excludeLocalAddressRequired = Values::NONE, bool $excludeForeignAddressRequired = Values::NONE, bool $beta = Values::NONE, string $nearNumber = Values::NONE, string $nearLatLong = Values::NONE, int $distance = Values::NONE, string $inPostalCode = Values::NONE, string $inRegion = Values::NONE, string $inRateCenter = Values::NONE, string $inLata = Values::NONE, string $inLocality = Values::NONE, bool $faxEnabled = Values::NONE): ReadMobileOptions {
return new ReadMobileOptions($areaCode, $contains, $smsEnabled, $mmsEnabled, $voiceEnabled, $excludeAllAddressRequired, $excludeLocalAddressRequired, $excludeForeignAddressRequired, $beta, $nearNumber, $nearLatLong, $distance, $inPostalCode, $inRegion, $inRateCenter, $inLata, $inLocality, $faxEnabled);
}
}
class ReadMobileOptions extends Options {
/**
* @param int $areaCode The area code of the phone numbers to read
* @param string $contains The pattern on which to match phone numbers
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @param string $inLocality Limit results to a particular locality
* @param bool $faxEnabled Whether the phone numbers can receive faxes
*/
public function __construct(int $areaCode = Values::NONE, string $contains = Values::NONE, bool $smsEnabled = Values::NONE, bool $mmsEnabled = Values::NONE, bool $voiceEnabled = Values::NONE, bool $excludeAllAddressRequired = Values::NONE, bool $excludeLocalAddressRequired = Values::NONE, bool $excludeForeignAddressRequired = Values::NONE, bool $beta = Values::NONE, string $nearNumber = Values::NONE, string $nearLatLong = Values::NONE, int $distance = Values::NONE, string $inPostalCode = Values::NONE, string $inRegion = Values::NONE, string $inRateCenter = Values::NONE, string $inLata = Values::NONE, string $inLocality = Values::NONE, bool $faxEnabled = Values::NONE) {
$this->options['areaCode'] = $areaCode;
$this->options['contains'] = $contains;
$this->options['smsEnabled'] = $smsEnabled;
$this->options['mmsEnabled'] = $mmsEnabled;
$this->options['voiceEnabled'] = $voiceEnabled;
$this->options['excludeAllAddressRequired'] = $excludeAllAddressRequired;
$this->options['excludeLocalAddressRequired'] = $excludeLocalAddressRequired;
$this->options['excludeForeignAddressRequired'] = $excludeForeignAddressRequired;
$this->options['beta'] = $beta;
$this->options['nearNumber'] = $nearNumber;
$this->options['nearLatLong'] = $nearLatLong;
$this->options['distance'] = $distance;
$this->options['inPostalCode'] = $inPostalCode;
$this->options['inRegion'] = $inRegion;
$this->options['inRateCenter'] = $inRateCenter;
$this->options['inLata'] = $inLata;
$this->options['inLocality'] = $inLocality;
$this->options['faxEnabled'] = $faxEnabled;
}
/**
* The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.
*
* @param int $areaCode The area code of the phone numbers to read
* @return $this Fluent Builder
*/
public function setAreaCode(int $areaCode): self {
$this->options['areaCode'] = $areaCode;
return $this;
}
/**
* The pattern on which to match phone numbers. Valid characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see [Example 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
*
* @param string $contains The pattern on which to match phone numbers
* @return $this Fluent Builder
*/
public function setContains(string $contains): self {
$this->options['contains'] = $contains;
return $this;
}
/**
* Whether the phone numbers can receive text messages. Can be: `true` or `false`.
*
* @param bool $smsEnabled Whether the phone numbers can receive text messages
* @return $this Fluent Builder
*/
public function setSmsEnabled(bool $smsEnabled): self {
$this->options['smsEnabled'] = $smsEnabled;
return $this;
}
/**
* Whether the phone numbers can receive MMS messages. Can be: `true` or `false`.
*
* @param bool $mmsEnabled Whether the phone numbers can receive MMS messages
* @return $this Fluent Builder
*/
public function setMmsEnabled(bool $mmsEnabled): self {
$this->options['mmsEnabled'] = $mmsEnabled;
return $this;
}
/**
* Whether the phone numbers can receive calls. Can be: `true` or `false`.
*
* @param bool $voiceEnabled Whether the phone numbers can receive calls.
* @return $this Fluent Builder
*/
public function setVoiceEnabled(bool $voiceEnabled): self {
$this->options['voiceEnabled'] = $voiceEnabled;
return $this;
}
/**
* Whether to exclude phone numbers that require an [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeAllAddressRequired Whether to exclude phone numbers that
* require an Address
* @return $this Fluent Builder
*/
public function setExcludeAllAddressRequired(bool $excludeAllAddressRequired): self {
$this->options['excludeAllAddressRequired'] = $excludeAllAddressRequired;
return $this;
}
/**
* Whether to exclude phone numbers that require a local [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeLocalAddressRequired Whether to exclude phone numbers
* that require a local address
* @return $this Fluent Builder
*/
public function setExcludeLocalAddressRequired(bool $excludeLocalAddressRequired): self {
$this->options['excludeLocalAddressRequired'] = $excludeLocalAddressRequired;
return $this;
}
/**
* Whether to exclude phone numbers that require a foreign [Address](https://www.twilio.com/docs/usage/api/address). Can be: `true` or `false` and the default is `false`.
*
* @param bool $excludeForeignAddressRequired Whether to exclude phone numbers
* that require a foreign address
* @return $this Fluent Builder
*/
public function setExcludeForeignAddressRequired(bool $excludeForeignAddressRequired): self {
$this->options['excludeForeignAddressRequired'] = $excludeForeignAddressRequired;
return $this;
}
/**
* Whether to read phone numbers that are new to the Twilio platform. Can be: `true` or `false` and the default is `true`.
*
* @param bool $beta Whether to read phone numbers new to the Twilio platform
* @return $this Fluent Builder
*/
public function setBeta(bool $beta): self {
$this->options['beta'] = $beta;
return $this;
}
/**
* Given a phone number, find a geographically close number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
*
* @param string $nearNumber Given a phone number, find a geographically close
* number within distance miles. (US/Canada only)
* @return $this Fluent Builder
*/
public function setNearNumber(string $nearNumber): self {
$this->options['nearNumber'] = $nearNumber;
return $this;
}
/**
* Given a latitude/longitude pair `lat,long` find geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
*
* @param string $nearLatLong Given a latitude/longitude pair lat,long find
* geographically close numbers within distance
* miles. (US/Canada only)
* @return $this Fluent Builder
*/
public function setNearLatLong(string $nearLatLong): self {
$this->options['nearLatLong'] = $nearLatLong;
return $this;
}
/**
* The search radius, in miles, for a `near_` query. Can be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
*
* @param int $distance The search radius, in miles, for a near_ query.
* (US/Canada only)
* @return $this Fluent Builder
*/
public function setDistance(int $distance): self {
$this->options['distance'] = $distance;
return $this;
}
/**
* Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inPostalCode Limit results to a particular postal code.
* (US/Canada only)
* @return $this Fluent Builder
*/
public function setInPostalCode(string $inPostalCode): self {
$this->options['inPostalCode'] = $inPostalCode;
return $this;
}
/**
* Limit results to a particular region, state, or province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inRegion Limit results to a particular region. (US/Canada
* only)
* @return $this Fluent Builder
*/
public function setInRegion(string $inRegion): self {
$this->options['inRegion'] = $inRegion;
return $this;
}
/**
* Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
*
* @param string $inRateCenter Limit results to a specific rate center, or
* given a phone number search within the same rate
* center as that number. (US/Canada only)
* @return $this Fluent Builder
*/
public function setInRateCenter(string $inRateCenter): self {
$this->options['inRateCenter'] = $inRateCenter;
return $this;
}
/**
* Limit results to a specific local access and transport area ([LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](https://en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. Applies to only phone numbers in the US and Canada.
*
* @param string $inLata Limit results to a specific local access and transport
* area. (US/Canada only)
* @return $this Fluent Builder
*/
public function setInLata(string $inLata): self {
$this->options['inLata'] = $inLata;
return $this;
}
/**
* Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.
*
* @param string $inLocality Limit results to a particular locality
* @return $this Fluent Builder
*/
public function setInLocality(string $inLocality): self {
$this->options['inLocality'] = $inLocality;
return $this;
}
/**
* Whether the phone numbers can receive faxes. Can be: `true` or `false`.
*
* @param bool $faxEnabled Whether the phone numbers can receive faxes
* @return $this Fluent Builder
*/
public function setFaxEnabled(bool $faxEnabled): self {
$this->options['faxEnabled'] = $faxEnabled;
return $this;
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$options = \http_build_query(Values::of($this->options), '', ' ');
return '[Twilio.Api.V2010.ReadMobileOptions ' . $options . ']';
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Http\Response;
use Twilio\Page;
use Twilio\Version;
class MobilePage extends Page {
/**
* @param Version $version Version that contains the resource
* @param Response $response Response from the API
* @param array $solution The context solution
*/
public function __construct(Version $version, Response $response, array $solution) {
parent::__construct($version, $response);
// Path Solution
$this->solution = $solution;
}
/**
* @param array $payload Payload response from the API
* @return MobileInstance \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\MobileInstance
*/
public function buildInstance(array $payload): MobileInstance {
return new MobileInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
return '[Twilio.Api.V2010.MobilePage]';
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* This code was generated by
* \ / _ _ _| _ _
* | (_)\/(_)(_|\/| |(/_ v1.0.0
* / /
*/
namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
use Twilio\Exceptions\TwilioException;
use Twilio\InstanceResource;
use Twilio\Values;
use Twilio\Version;
/**
* @property string $friendlyName
* @property string $phoneNumber
* @property string $lata
* @property string $locality
* @property string $rateCenter
* @property string $latitude
* @property string $longitude
* @property string $region
* @property string $postalCode
* @property string $isoCountry
* @property string $addressRequirements
* @property bool $beta
* @property string $capabilities
*/
class NationalInstance extends InstanceResource {
/**
* Initialize the NationalInstance
*
* @param Version $version Version that contains the resource
* @param mixed[] $payload The response payload
* @param string $accountSid The account_sid
* @param string $countryCode The ISO-3166-1 country code of the country.
*/
public function __construct(Version $version, array $payload, string $accountSid, string $countryCode) {
parent::__construct($version);
// Marshaled Properties
$this->properties = [
'friendlyName' => Values::array_get($payload, 'friendly_name'),
'phoneNumber' => Values::array_get($payload, 'phone_number'),
'lata' => Values::array_get($payload, 'lata'),
'locality' => Values::array_get($payload, 'locality'),
'rateCenter' => Values::array_get($payload, 'rate_center'),
'latitude' => Values::array_get($payload, 'latitude'),
'longitude' => Values::array_get($payload, 'longitude'),
'region' => Values::array_get($payload, 'region'),
'postalCode' => Values::array_get($payload, 'postal_code'),
'isoCountry' => Values::array_get($payload, 'iso_country'),
'addressRequirements' => Values::array_get($payload, 'address_requirements'),
'beta' => Values::array_get($payload, 'beta'),
'capabilities' => Values::array_get($payload, 'capabilities'),
];
$this->solution = ['accountSid' => $accountSid, 'countryCode' => $countryCode, ];
}
/**
* 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.Api.V2010.NationalInstance]';
}
}

Some files were not shown because too many files have changed in this diff Show More