Skip to content

SWI-2615 #64

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04]
php-version: [7.4, 8.0]
php-version: [7.4, 8.0, 8.1, 8.2]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
vendor
composer.lock
.phpunit.result.cache
composer.phar
composer.phar
.idea
30 changes: 15 additions & 15 deletions src/APIHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class APIHelper
{
/**
* Replaces template parameters in the given url
* @param string $url The query string builder to replace the template parameters
* @param array $parameters The parameters to replace in the url
* @param string $url The query string builder to replace the template parameters
* @param array $parameters The parameters to replace in the url
* @return string The processed url
*/
public static function appendUrlWithTemplateParameters($url, $parameters, $encode = true)
public static function appendUrlWithTemplateParameters(string $url, array $parameters, $encode = true): string
{
//perform parameter validation
if (is_null($url) || !is_string($url)) {
Expand Down Expand Up @@ -55,11 +55,11 @@ public static function appendUrlWithTemplateParameters($url, $parameters, $encod

/**
* Appends the given set of parameters to the given query string
* @param string $queryBuilder The query url string to append the parameters
* @param array $parameters The parameters to append
* @param string $queryBuilder The query url string to append the parameters
* @param array $parameters The parameters to append
* @return void
*/
public static function appendUrlWithQueryParameters(&$queryBuilder, $parameters)
public static function appendUrlWithQueryParameters(string &$queryBuilder, array $parameters)
{
//perform parameter validation
if (is_null($queryBuilder) || !is_string($queryBuilder)) {
Expand All @@ -80,9 +80,9 @@ public static function appendUrlWithQueryParameters(&$queryBuilder, $parameters)

/**
* Validates and processes the given Url
* @param string $url The given Url to process
* @param string $url The given Url to process
* @return string Pre-processed Url as string */
public static function cleanUrl($url)
public static function cleanUrl(string $url): string
{
//perform parameter validation
if (is_null($url) || !is_string($url)) {
Expand All @@ -106,12 +106,12 @@ public static function cleanUrl($url)

/**
* Deserialize a Json string
* @param string $json A valid Json string
* @param string $json A valid Json string
* @param mixed $instance Instance of an object to map the json into
* @param boolean $isArray Is the Json an object array?
* @param boolean $isArray Is the Json an object array?
* @return mixed Decoded Json
*/
public static function deserialize($json, $instance = null, $isArray = false)
public static function deserialize(string $json, $instance = null, bool $isArray = false)
{
if ($instance == null) {
return json_decode($json, true);
Expand All @@ -127,10 +127,10 @@ public static function deserialize($json, $instance = null, $isArray = false)

/**
* Check if an array isAssociative (has string keys)
* @param array $arr A valid array
* @param array $arr A valid array
* @return boolean True if the array is Associative, false if it is Indexed
*/
private static function isAssociative($arr)
private static function isAssociative(array $arr): bool
{
foreach ($arr as $key => $value) {
if (is_string($key)) {
Expand All @@ -143,10 +143,10 @@ private static function isAssociative($arr)

/**
* Prepare a model for form encoding
* @param JsonSerializable $model A valid instance of JsonSerializable
* @param JsonSerializable $model A valid instance of JsonSerializable
* @return array The model as a map of key value pairs
*/
public static function prepareFormFields($model)
public static function prepareFormFields(JsonSerializable $model)
{
if (!$model instanceof JsonSerializable) {
return $model;
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ public function getBaseUrl()

/**
* Get the base uri for a given server in the current environment
* @param string $server Server name
* @param string $server Server name
* @return string Base URI
*/
public function getBaseUri($server = Servers::DEFAULT_)
public function getBaseUri(string $server = Servers::DEFAULT_)
{
return APIHelper::appendUrlWithTemplateParameters(
static::$environmentsMap[$this->environment][$server],
Expand Down
4 changes: 2 additions & 2 deletions src/Http/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class ApiResponse

/**
* Create a new instance of a HttpResponse
* @param int $statusCode Response code
* @param int $statusCode Response code
* @param array $headers Map of headers
* @param mixed $result The deserialized response
*/
public function __construct($statusCode, array $headers, $result)
public function __construct(int $statusCode, array $headers, $result)
{
$this->statusCode = $statusCode;
$this->headers = $headers;
Expand Down
12 changes: 6 additions & 6 deletions src/Http/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class HttpRequest

/**
* Create a new HttpRequest
* @param string $httpMethod Http method
* @param string|null $httpMethod Http method
* @param array|null $headers Map of headers
* @param string $queryUrl Query url
* @param string|null $queryUrl Query url
* @param array|null $parameters Map of parameters sent
*/
public function __construct($httpMethod = null, array $headers = null, $queryUrl = null, array $parameters = null)
public function __construct(string $httpMethod = null, array $headers = null, string $queryUrl = null, array $parameters = null)
{
$this->httpMethod = $httpMethod;
$this->headers = $headers;
Expand All @@ -64,7 +64,7 @@ public function getHttpMethod()
* Set http method
* @param string $httpMethod Http Method as defined in HttpMethod class
*/
public function setHttpMethod($httpMethod)
public function setHttpMethod(string $httpMethod)
{
$this->httpMethod = $httpMethod;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getQueryUrl()
* Set query url
* @param string $queryUrl Query url
*/
public function setQueryUrl($queryUrl)
public function setQueryUrl(string $queryUrl)
{
$this->queryUrl = $queryUrl;
}
Expand All @@ -118,7 +118,7 @@ public function getParameters()
* Set parameters
* @param array $parameters Map of input parameters
*/
public function setParameters($parameters)
public function setParameters(array $parameters)
{
$this->parameters = $parameters;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Http/HttpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class HttpResponse

/**
* Create a new instance of a HttpResponse
* @param int $statusCode Response code
* @param int $statusCode Response code
* @param array $headers Map of headers
* @param string $rawBody Raw response body
*/
public function __construct($statusCode, array $headers, $rawBody)
public function __construct(int $statusCode, array $headers, string $rawBody)
{
$this->statusCode = $statusCode;
$this->headers = $headers;
Expand Down
72 changes: 36 additions & 36 deletions src/Messaging/Controllers/APIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public function __construct($config, $httpCallBack = null)
* Gets a list of your media files. No query parameters are supported.
*
* @param string $accountId User's account ID
* @param string $continuationToken (optional) Continuation token used to retrieve subsequent media.
* @param string|null $continuationToken (optional) Continuation token used to retrieve subsequent media.
* @return ApiResponse response from the API call
* @throws APIException Thrown if API call fails
*/
public function listMedia(
$accountId,
$continuationToken = null
string $accountId,
string $continuationToken = null
) {

//prepare query string for API call
Expand Down Expand Up @@ -128,8 +128,8 @@ public function listMedia(
* @throws APIException Thrown if API call fails
*/
public function getMedia(
$accountId,
$mediaId
string $accountId,
string $mediaId
) {

//prepare query string for API call
Expand Down Expand Up @@ -215,17 +215,17 @@ public function getMedia(
* @param string $mediaId The user supplied custom media ID
* @param string $body TODO: type description here
* @param string $contentType (optional) The media type of the entity-body
* @param string $cacheControl (optional) General-header field is used to specify directives that MUST be obeyed
* @param string|null $cacheControl (optional) General-header field is used to specify directives that MUST be obeyed
* by all caching mechanisms along the request/response chain.
* @return ApiResponse response from the API call
* @throws APIException Thrown if API call fails
*/
public function uploadMedia(
$accountId,
$mediaId,
$body,
$contentType = 'application/octet-stream',
$cacheControl = null
string $accountId,
string $mediaId,
string $body,
string $contentType = 'application/octet-stream',
string $cacheControl = null
) {

//prepare query string for API call
Expand Down Expand Up @@ -318,8 +318,8 @@ public function uploadMedia(
* @throws APIException Thrown if API call fails
*/
public function deleteMedia(
$accountId,
$mediaId
string $accountId,
string $mediaId
) {

//prepare query string for API call
Expand Down Expand Up @@ -399,35 +399,35 @@ public function deleteMedia(
/**
* Gets a list of messages based on query parameters.
*
* @param string $accountId User's account ID
* @param string $messageId (optional) The ID of the message to search for. Special characters need to be
* @param string $accountId User's account ID
* @param string|null $messageId (optional) The ID of the message to search for. Special characters need to be
* encoded using URL encoding
* @param string $sourceTn (optional) The phone number that sent the message
* @param string $destinationTn (optional) The phone number that received the message
* @param string $messageStatus (optional) The status of the message. One of RECEIVED, QUEUED, SENDING, SENT,
* @param string|null $sourceTn (optional) The phone number that sent the message
* @param string|null $destinationTn (optional) The phone number that received the message
* @param string|null $messageStatus (optional) The status of the message. One of RECEIVED, QUEUED, SENDING, SENT,
* FAILED, DELIVERED, ACCEPTED, UNDELIVERED
* @param integer $errorCode (optional) The error code of the message
* @param string $fromDateTime (optional) The start of the date range to search in ISO 8601 format. Uses the
* @param integer|null $errorCode (optional) The error code of the message
* @param string|null $fromDateTime (optional) The start of the date range to search in ISO 8601 format. Uses the
* message receive time. The date range to search in is currently 14 days.
* @param string $toDateTime (optional) The end of the date range to search in ISO 8601 format. Uses the
* @param string|null $toDateTime (optional) The end of the date range to search in ISO 8601 format. Uses the
* message receive time. The date range to search in is currently 14 days.
* @param string $pageToken (optional) A base64 encoded value used for pagination of results
* @param integer $limit (optional) The maximum records requested in search result. Default 100. The sum of
* @param string|null $pageToken (optional) A base64 encoded value used for pagination of results
* @param integer|null $limit (optional) The maximum records requested in search result. Default 100. The sum of
* limit and after cannot be more than 10000
* @return ApiResponse response from the API call
* @throws APIException Thrown if API call fails
*/
public function getMessages(
$accountId,
$messageId = null,
$sourceTn = null,
$destinationTn = null,
$messageStatus = null,
$errorCode = null,
$fromDateTime = null,
$toDateTime = null,
$pageToken = null,
$limit = null
string $accountId,
string $messageId = null,
string $sourceTn = null,
string $destinationTn = null,
string $messageStatus = null,
int $errorCode = null,
string $fromDateTime = null,
string $toDateTime = null,
string $pageToken = null,
int $limit = null
) {

//prepare query string for API call
Expand Down Expand Up @@ -524,14 +524,14 @@ public function getMessages(
/**
* Endpoint for sending text messages and picture messages using V2 messaging.
*
* @param string $accountId User's account ID
* @param string $accountId User's account ID
* @param Models\MessageRequest $body TODO: type description here
* @return ApiResponse response from the API call
* @throws APIException Thrown if API call fails
*/
public function createMessage(
$accountId,
$body
string $accountId,
Models\MessageRequest $body
) {

//prepare query string for API call
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/BandwidthCallbackMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['time'] = $this->time;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/BandwidthMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['id'] = $this->id;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/BandwidthMessageItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['messageId'] = $this->messageId;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/BandwidthMessagesList.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['totalCount'] = $this->totalCount;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/DeferredResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['result'] = $this->result;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['content'] = $this->content;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/MessageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['applicationId'] = $this->applicationId;
Expand Down
2 changes: 1 addition & 1 deletion src/Messaging/Models/PageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct()
/**
* Encode this object to JSON
*/
public function jsonSerialize()
public function jsonSerialize(): array
{
$json = array();
$json['prevPage'] = $this->prevPage;
Expand Down
Loading