From c8e10442629d7cac2c239fe3d0ad930c5d4ac4e7 Mon Sep 17 00:00:00 2001 From: Jacob Mulford <39915377+jmulford-bw@users.noreply.github.com> Date: Wed, 2 Dec 2020 10:28:47 -0500 Subject: [PATCH] Fix media download encoding (#14) * Deploy * fixed media download url encoding * updated user agent version Co-authored-by: DX-Bandwidth --- composer.json | 66 ++++++++-------- src/Controllers/BaseController.php | 2 +- src/Messaging/Controllers/APIController.php | 3 +- src/Voice/Bxml/StartGather.php | 88 +++++++++++++++++++++ src/Voice/Bxml/StopGather.php | 20 +++++ src/WebRtc/Utils/WebRtcTransfer.php | 2 +- 6 files changed, 143 insertions(+), 38 deletions(-) create mode 100644 src/Voice/Bxml/StartGather.php create mode 100644 src/Voice/Bxml/StopGather.php diff --git a/composer.json b/composer.json index 3edff5c..71e337c 100644 --- a/composer.json +++ b/composer.json @@ -1,38 +1,34 @@ { - "name": "bandwidth/sdk", - "type": "library", - "description": "Bandwidth's set of APIs", - "keywords": [ - "bandwidth", - "API", - "SDK" - ], - "homepage": "https://github.com/bandwidth/php-sdk", - "license": "MIT", - "authors": [ - { - "name": "APIMatic SDK Generator", - "email": "support@apimatic.io", - "homepage": "https://apimatic.io", - "role": "API Tool" + "name": "bandwidth/sdk", + "type": "library", + "description": "Bandwidth's set of APIs", + "keywords": ["bandwidth","API","SDK"], + "homepage": "https://apimatic.io", + "license": "MIT", + "authors": [ + { + "name": "APIMatic SDK Generator", + "email": "support@apimatic.io", + "homepage": "https://apimatic.io", + "role": "API Tool" + } + ], + "require": { + "ext-SimpleXML": "*", + "php": ">=5.4.0", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "mashape/unirest-php": "~3.0.1", + "apimatic/jsonmapper": "~1.3.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "^2.7", + "phan/phan": "^1.2" + }, + "autoload": { + "psr-4": { + "BandwidthLib\\": "src/" + } } - ], - "require": { - "ext-SimpleXML": "*", - "php": ">=5.4.0", - "ext-curl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "mashape/unirest-php": "~3.0.1", - "apimatic/jsonmapper": "~1.3.0" - }, - "require-dev": { - "squizlabs/php_codesniffer": "^2.7", - "phan/phan": "^1.2" - }, - "autoload": { - "psr-4": { - "BandwidthLib\\": "src/" - } - } } \ No newline at end of file diff --git a/src/Controllers/BaseController.php b/src/Controllers/BaseController.php index dfe474f..5897069 100644 --- a/src/Controllers/BaseController.php +++ b/src/Controllers/BaseController.php @@ -22,7 +22,7 @@ class BaseController * User-agent to be sent with API calls * @var string */ - const USER_AGENT = 'php-sdk-refs/tags/php2.11.1'; + const USER_AGENT = 'php-sdk-refs/tags/phpold2.13.3'; /** * HttpCallBack instance associated with this controller diff --git a/src/Messaging/Controllers/APIController.php b/src/Messaging/Controllers/APIController.php index fb91840..27afbf0 100644 --- a/src/Messaging/Controllers/APIController.php +++ b/src/Messaging/Controllers/APIController.php @@ -139,7 +139,8 @@ public function getMedia( $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( 'userId' => $userId, 'mediaId' => $mediaId, - )); + ), false + ); //validate and preprocess url $_queryUrl = APIHelper::cleanUrl($this->config->getBaseUri(Servers::MESSAGINGDEFAULT) . $_queryBuilder); diff --git a/src/Voice/Bxml/StartGather.php b/src/Voice/Bxml/StartGather.php new file mode 100644 index 0000000..5778346 --- /dev/null +++ b/src/Voice/Bxml/StartGather.php @@ -0,0 +1,88 @@ +username = $username; + } + + /** + * Sets the password attribute for StartGather + * + * @param string $password The password for http authentication for the gather callback + */ + public function password($password) { + $this->password = $password; + } + + /** + * Sets the dtmfUrl attribute for StartGather + * + * @param string $dtmfUrl The url to receive the dtmf callback + */ + public function dtmfUrl($dtmfUrl) { + $this->dtmfUrl = $dtmfUrl; + } + + /** + * Sets the dtmfMethod attribute for StartGather + * + * @param string $dtmfMethod The http method to send the dtmf callback + */ + public function dtmfMethod($dtmfMethod) { + $this->dtmfMethod = $dtmfMethod; + } + + /** + * Sets the tag attribute for StartGather + * + * @param string $tag A custom string to be included in callbacks + */ + public function tag($tag) { + $this->tag = $tag; + } + + public function toBxml($doc) { + $element = $doc->createElement("StartGather"); + + if(isset($this->username)) { + $element->setAttribute("username", $this->username); + } + + if(isset($this->password)) { + $element->setAttribute("password", $this->password); + } + + if(isset($this->tag)) { + $element->setAttribute("tag", $this->tag); + } + + if(isset($this->dtmfUrl)) { + $element->setAttribute("dtmfUrl", $this->dtmfUrl); + } + + if(isset($this->dtmfMethod)) { + $element->setAttribute("dtmfMethod", $this->dtmfMethod); + } + + return $element; + } +} diff --git a/src/Voice/Bxml/StopGather.php b/src/Voice/Bxml/StopGather.php new file mode 100644 index 0000000..4de839f --- /dev/null +++ b/src/Voice/Bxml/StopGather.php @@ -0,0 +1,20 @@ +createElement("StopGather"); + return $element; + } +} diff --git a/src/WebRtc/Utils/WebRtcTransfer.php b/src/WebRtc/Utils/WebRtcTransfer.php index 056f768..86debd0 100644 --- a/src/WebRtc/Utils/WebRtcTransfer.php +++ b/src/WebRtc/Utils/WebRtcTransfer.php @@ -11,6 +11,6 @@ class WebRtcTransfer { public static function generateBxml($deviceToken, $sipUri = "sip:sipx.webrtc.bandwidth.com:5060") { - return '' . $sipUri . ''; + return '' . $sipUri . ''; } }