diff --git a/CHANGELOG.md b/CHANGELOG.md index 8feea7dd..c27a0702 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## [4.50.0](https://github.com/plivo/plivo-php/tree/v4.50.0) (2023-05-02) +**Feature - CNAM Lookup** +- Added New Param `cnam_lookup` in to the response of the [list all numbers API], [list single number API] +- Added `cnam_lookup` filter to AccountPhoneNumber - list all my numbers API. +- Added `cnam_lookup` parameter to buy number[Buy a Phone Number] to configure CNAM Lookup while buying a US number +- Added `cnam_lookup` parameter to update number[Update an account phone number] to configure CNAM Lookup while buying a US number + ## [v4.49.0](https://github.com/plivo/plivo-php/tree/v4.43.1) (2023-03-16) **Feature - Added New Param 'cnam_lookup_number_config' in GetCall and ListCalls** - Add `cnam_lookup_number_config` to the response for the [retrieve a call details API](https://www.plivo.com/docs/voice/api/call#retrieve-a-call) and the [retreive all call details API](https://www.plivo.com/docs/voice/api/call#retrieve-all-calls) diff --git a/src/Plivo/Resources/Number/Number.php b/src/Plivo/Resources/Number/Number.php index 48de2d9c..ac61f08f 100644 --- a/src/Plivo/Resources/Number/Number.php +++ b/src/Plivo/Resources/Number/Number.php @@ -75,6 +75,7 @@ function __construct(BaseClient $client, array $response, $authId) 'tendlcRegistrationStatus' => $response['tendlc_registration_status'], 'tollFreeSMSVerification' => $response['toll_free_sms_verification'], 'renewalDate' => $response['renewal_date'], + 'cnamLookup' => $response['cnam_lookup'], ]; if (isset($response['object_id'])) { $this->properties['objectId'] = $response['object_id']; diff --git a/src/Plivo/Resources/Number/NumberInterface.php b/src/Plivo/Resources/Number/NumberInterface.php index 51fb61b2..6811d062 100644 --- a/src/Plivo/Resources/Number/NumberInterface.php +++ b/src/Plivo/Resources/Number/NumberInterface.php @@ -48,6 +48,7 @@ function __construct(BaseClient $plivoClient, $authId) *
sms - Returns a list of numbers that provide only 'sms' services. * + [int] limit - Used to display the number of results per page. The maximum number of results that can be fetched is 20. * + [int] offset - Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results. + * + [string] cnam_lookup - Used to filter on the basis of this param. If this parameter is included in the request, all numbers of the particular cnam lookup are displayed. * + [string] renewal_date - Used to filter on the basis of this param. If this parameter is included in the request, all numbers of the particular renewal date are displayed. * + [string] renewal_date__gt - Used to filter on the basis of this param. If this parameter is included in the request, all numbers greater than renewal date are displayed. * + [string] renewal_date__gte - Used to filter on the basis of this param. If this parameter is included in the request, all numbers greater than equal renewal date are displayed. @@ -107,9 +108,21 @@ public function get($number) [] ); - return new Number( + $responseContents = $response->getContent(); + if(!array_key_exists("error",$responseContents)){ + return new Number( $this->client, $response->getContent(), $this->pathParams['authId']); + } else { + throw new PlivoResponseException( + $responseContents['error'], + 0, + null, + $response->getContent(), + $response->getStatusCode() + + ); + } } /** @@ -120,6 +133,7 @@ public function get($number) * + [string] alias - The textual name given to the number. * + [string] app_id - The application id of the application that is to be linked. * + [string] subaccount - The auth_id of the subaccount to which this number should be added. This can only be performed by a main account holder. + * + [string] cnam_lookup - The cnam lookup value for the number (Valid values : enabled, disabled). * @return ResponseUpdate */ public function update($number, $optionalArgs = []) diff --git a/src/Plivo/Resources/PhoneNumber/PhoneNumberInterface.php b/src/Plivo/Resources/PhoneNumber/PhoneNumberInterface.php index 206f25b8..930d70cc 100644 --- a/src/Plivo/Resources/PhoneNumber/PhoneNumberInterface.php +++ b/src/Plivo/Resources/PhoneNumber/PhoneNumberInterface.php @@ -89,13 +89,14 @@ public function getList($countryIso, $optionalArgs = []) * * @param number $phoneNumber * @param string|null $appId + * @param string|null $cnamLookup * @return PhoneNumberBuyResponse output */ - public function buy($phoneNumber, $appId = null) + public function buy($phoneNumber, $appId = null, $cnamLookup = null) { $response = $this->client->update( $this->uri . $phoneNumber . '/', - ['app_id'=>$appId] + ['app_id'=>$appId,'cnam_lookup'=>$cnamLookup] ); $responseContents = $response->getContent(); @@ -108,6 +109,14 @@ public function buy($phoneNumber, $appId = null) $responseContents['status'], $response->getStatusCode() ); + } elseif (gettype($responseContents['error']) == "array" && array_key_exists("error",$responseContents['error'])) { + throw new PlivoResponseException( + $responseContents['error']['error'], + 0, + null, + $response->getContent(), + $response->getStatusCode() + ); } else { throw new PlivoResponseException( $responseContents['error'], diff --git a/src/Plivo/Version.php b/src/Plivo/Version.php index 2f61c1b4..d4af782d 100644 --- a/src/Plivo/Version.php +++ b/src/Plivo/Version.php @@ -20,7 +20,7 @@ class Version /** * @const int PHP helper library minor version number */ - const MINOR = 48; + const MINOR = 50; /** * @const int PHP helper library patch number diff --git a/tests/Mocks/numberGetResponse.json b/tests/Mocks/numberGetResponse.json index f959e545..fa632667 100644 --- a/tests/Mocks/numberGetResponse.json +++ b/tests/Mocks/numberGetResponse.json @@ -19,6 +19,7 @@ "voice_rate": "0.00850", "mms_enabled": true, "mms_rate": "0.00750", + "cnam_lookup": "enabled", "compliance_application_id": "20372631212782797", "compliance_status": "submitted", "renewal_date": "2014-03-14", diff --git a/tests/Mocks/numberListResponse.json b/tests/Mocks/numberListResponse.json index 40183eaf..257eb24f 100644 --- a/tests/Mocks/numberListResponse.json +++ b/tests/Mocks/numberListResponse.json @@ -28,6 +28,7 @@ "voice_rate": "0.00850", "mms_enabled": true, "mms_rate": "0.00950", + "cnam_lookup": "enabled", "compliance_application_id": "20372631212782797", "compliance_status": "submitted", "renewal_date": "2014-09-05", @@ -57,6 +58,7 @@ "voice_rate": "0.00850", "mms_enabled": true, "mms_rate": "0.00750", + "cnam_lookup": "enabled", "compliance_application_id": "20372631212782797", "compliance_status": "submitted", "renewal_date": "2013-02-01", @@ -86,6 +88,7 @@ "voice_rate": "0.00850", "mms_enabled": true, "mms_rate": "0.00850", + "cnam_lookup": "disabled", "compliance_application_id": "20372631212782799", "compliance_status": "submitted", "renewal_date": "2013-04-25",