From 5aa6b1dd07da4210d46d9a7dba0f16ea90061fa3 Mon Sep 17 00:00:00 2001
From: weroh <50031971+weroh@users.noreply.github.com>
Date: Fri, 11 Dec 2020 10:50:02 -0800
Subject: [PATCH 1/5] Updated Verify API

Also included demo in /examples/verify_sms_demo.php
---
 examples/verify_sms_demo.php                  | 152 ++++++++++++++++++
 init.php                                      |   3 +
 lib/Util/ObjectTypes.php                      |   3 +
 lib/{TwoFactorVerify.php => Verification.php} |  26 +--
 ...TwoFactorProfile.php => VerifyProfile.php} |   9 +-
 lib/VerifyVerification.php                    |  15 ++
 tests/api_resources/AddressTest.php           |   9 +-
 tests/api_resources/TwoFactorProfileTest.php  |  74 ---------
 tests/api_resources/TwoFactorVerifyTest.php   |  63 --------
 tests/api_resources/VerificationTest.php      |  60 +++++++
 tests/api_resources/VerifyProfileTest.php     |  73 +++++++++
 11 files changed, 326 insertions(+), 161 deletions(-)
 create mode 100644 examples/verify_sms_demo.php
 rename lib/{TwoFactorVerify.php => Verification.php} (60%)
 rename lib/{TwoFactorProfile.php => VerifyProfile.php} (64%)
 create mode 100644 lib/VerifyVerification.php
 delete mode 100644 tests/api_resources/TwoFactorProfileTest.php
 delete mode 100644 tests/api_resources/TwoFactorVerifyTest.php
 create mode 100644 tests/api_resources/VerificationTest.php
 create mode 100644 tests/api_resources/VerifyProfileTest.php

diff --git a/examples/verify_sms_demo.php b/examples/verify_sms_demo.php
new file mode 100644
index 0000000..8a1eb7d
--- /dev/null
+++ b/examples/verify_sms_demo.php
@@ -0,0 +1,152 @@
+<?php
+require_once(__DIR__ . '/../init.php');
+
+// Please fetch your API key from here https://portal.telnyx.com/#/app/api-keys
+\Telnyx\Telnyx::setApiKey('######');
+
+?>
+<style>
+    .code {
+        background: #ddd;
+        border: 1px solid #333;
+        padding: 20px;
+        border-radius: 3px;
+    }
+</style>
+<?php
+if (isset($_POST['action'])) {
+    switch ($_POST['action']) {
+        case 'send_verification':
+
+            // Create a Verification profile
+            $verify_profile = \Telnyx\VerifyProfile::create(["name" => "Test Profile"]);
+
+            // Trigger a verification request and send SMS
+            $verification = \Telnyx\Verification::create([
+                'verify_profile_id' => $verify_profile['id'],
+                'phone_number' => $_POST['phone'],
+                'type' => 'sms'
+            ]);
+            ?>
+            <h3>Verification was sent to: <?php echo $_POST['phone'];?></h3>
+            <form method="post" action="">
+
+                <input type="hidden" name="action" value="check_verification">
+                <input type="hidden" name="verification_id" value="<?php echo $verification['id']; ?>">
+
+                <button type="submit">Check Verification Status</button>
+                <pre class="code">
+                // Retrieve the status of the verification
+                $verification = \Telnyx\Verification::retrieve('<?php echo $verification['id']; ?>');
+                </pre>
+            </form>
+            <?php
+        break;
+
+        case 'check_verification':
+
+            // Retrieve the status of the verification
+            $verification = \Telnyx\Verification::retrieve($_POST['verification_id']);
+
+            ?>
+            <h3>Verification Status for ID: <?php echo $_POST['verification_id'];?></h3>
+            <pre><?php print_r($verification); ?></pre>
+
+            <form method="post" action="">
+                
+                <input type="hidden" name="action" value="check_verification">
+                <input type="hidden" name="verification_id" value="<?php echo $_POST['verification_id']; ?>">
+
+                <button type="submit">Check Verification Status</button>
+                <pre class="code">
+                // Retrieve the status of the verification
+                $verification = \Telnyx\Verification::retrieve('<?php echo $_POST['verification_id']; ?>');
+                </pre>
+            </form>
+
+
+            <h3>Submit Verification Code</h3>
+
+            <form method="post" action="">
+                
+                <input type="hidden" name="action" value="submit_verification_code">
+                <input type="hidden" name="verification_id" value="<?php echo $_POST['verification_id']; ?>">
+
+                <input id="verify-code-text" type="text" name="verification_code" placeholder="000000" oninput="update_verification_code()">
+
+                <button type="submit">Submit Verification Code</button>
+                <pre class="code">
+                // Submit verificaiton code
+                $verify_status = \Telnyx\Verification::submit_verification('<?php echo $verification['phone_number']; ?>', '<span id="verify-code">000000</span>');
+                </pre>
+            </form>
+            <script>
+                function update_verification_code() {
+                    var textbox = document.getElementById("verify-code-text");
+                    var span = document.getElementById("verify-code");
+                    span.innerHTML = textbox.value;
+                }
+            </script>
+            <?php
+        break;
+
+        case 'submit_verification_code':
+
+            // Retrieve the status of the verification
+            $verification = \Telnyx\Verification::retrieve($_POST['verification_id']);
+
+            // Submit verification code here
+            $verify_status = \Telnyx\Verification::submit_verification($verification['phone_number'], $_POST['verification_code']);
+            ?>
+            <h3>Submitted Verification Code: <?php echo $_POST['verification_code']; ?></h3>
+
+            <pre><?php print_r($verify_status); ?></pre>
+
+            <form method="post" action="">
+                
+                <input type="hidden" name="action" value="check_verification">
+                <input type="hidden" name="verification_id" value="<?php echo $_POST['verification_id']; ?>">
+
+                <button type="submit">Check Verification Status</button>
+                <pre class="code">
+                // Retrieve the status of the verification
+                $verification = \Telnyx\Verification::retrieve('<?php echo $_POST['verification_id']; ?>');
+                </pre>
+            </form>
+            <?php
+        break;
+    }
+}
+else {
+    ?>
+    <h1>Telnyx Verify Demo</h1>
+    <p>Hi and welcome to the Telnyx Verify API demo.</p>
+    <form method="post" action="">
+
+        <input type="hidden" name="action" value="send_verification">
+
+        <p><label>Enter a phone number. Please remember to include <a target="_blank" href="https://support.telnyx.com/en/articles/1130706-sip-connection-number-formats">country code</a>:</label></p>
+        <input id="phone-number-text" type="text" name="phone" placeholder="+15557770000" oninput="update_phone()">
+        <button type="submit">Send Verification Code to Phone</button>
+        <pre class="code">
+        // Create a Verification profile
+        $verify_profile = VerifyProfile::create(["name" => "Test Profile"]);
+
+        // Trigger a verification request and send SMS
+        $verification = Verification::create([
+            'verify_profile_id' => $verify_profile['id'],
+            'phone_number' => '<span id="phone-number-code">+15557770000</span>',
+            'type' => 'sms'
+        ]);
+        </pre>
+    </form>
+    <script>
+        function update_phone() {
+            var textbox = document.getElementById("phone-number-text");
+            var span = document.getElementById("phone-number-code");
+            span.innerHTML = textbox.value;
+        }
+    </script>
+    <?php
+}
+
diff --git a/init.php b/init.php
index 4e50e85..9c3b612 100644
--- a/init.php
+++ b/init.php
@@ -82,6 +82,9 @@
 require __DIR__ . '/lib/OtaUpdate.php';
 require __DIR__ . '/lib/MobileOperatorNetwork.php';
 require __DIR__ . '/lib/Balance.php';
+require __DIR__ . '/lib/VerifyProfile.php';
+require __DIR__ . '/lib/Verification.php';
+require __DIR__ . '/lib/VerifyVerification.php';
 
 // Telnyx API: Connections
 require __DIR__ . '/lib/Connection.php';
diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php
index 4e0c0e5..ad51df1 100644
--- a/lib/Util/ObjectTypes.php
+++ b/lib/Util/ObjectTypes.php
@@ -42,6 +42,9 @@ class ObjectTypes
         \Telnyx\OtaUpdate::OBJECT_NAME => \Telnyx\OtaUpdate::class,
         \Telnyx\MobileOperatorNetwork::OBJECT_NAME => \Telnyx\MobileOperatorNetwork::class,
         \Telnyx\Balance::OBJECT_NAME => \Telnyx\Balance::class,
+        \Telnyx\VerifyProfile::OBJECT_NAME => \Telnyx\VerifyProfile::class,
+        \Telnyx\Verification::OBJECT_NAME => \Telnyx\Verification::class,
+        \Telnyx\VerifyVerification::OBJECT_NAME => \Telnyx\VerifyVerification::class,
 
         // Telnyx API: Connections
         \Telnyx\Connection::OBJECT_NAME => \Telnyx\Connection::class,
diff --git a/lib/TwoFactorVerify.php b/lib/Verification.php
similarity index 60%
rename from lib/TwoFactorVerify.php
rename to lib/Verification.php
index bfce925..beb3592 100644
--- a/lib/TwoFactorVerify.php
+++ b/lib/Verification.php
@@ -3,29 +3,19 @@
 namespace Telnyx;
 
 /**
- * Class TwoFactorProfile
+ * Class Verification
  *
  * @package Telnyx
  */
-class TwoFactorVerify extends ApiResource
+class Verification extends ApiResource
 {
-    const OBJECT_NAME = "twofa_verification";
+    const OBJECT_NAME = "verification";
 
     use ApiOperations\Create;
     use ApiOperations\Retrieve;
 
     /**
-     * @return string The endpoint associated with this singleton class.
-     */
-    public static function classUrl()
-    {
-        // Use a custom URL for this resource
-        // NOTE: This endpoint is special because object name is "twofa_verification" and endpoint is "2fa_verifications"
-        return "/v2/2fa_verifications";
-    }
-
-    /**
-     * Retrieve a 2FA verification by phone number.
+     * Retrieve a verification by phone number
      *
      * @param string $phone_number
      * @param array|string|null $options
@@ -34,7 +24,7 @@ public static function classUrl()
      */
     public static function retrieve_by_phone_number($phone_number, $options = null)
     {
-        $url = '/v2/2fa_verifications/by_tn/' . urlencode($phone_number);
+        $url = '/v2/verifications/by_phone_number/' . urlencode($phone_number);
 
         list($response, $opts) = static::_staticRequest('get', $url, null, $options);
         $obj = \Telnyx\Util\Util::convertToTelnyxObject($response->json, $opts);
@@ -42,7 +32,7 @@ public static function retrieve_by_phone_number($phone_number, $options = null)
     }
 
     /**
-     * Submit a 2FA verification code
+     * Submit a verification code
      *
      * @param string $phone_number
      * @param string $verification_code
@@ -54,10 +44,10 @@ public static function submit_verification($phone_number, $verification_code, $o
     {
         $params = ['code' => $verification_code];
         self::_validateParams($params);
-        $url = '/v2/2fa_verifications/by_tn/' . urlencode($phone_number) . '/actions/verify';
+        $url = '/v2/verifications/by_phone_number/' . urlencode($phone_number) . '/actions/verify';
 
         list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
         $obj = \Telnyx\Util\Util::convertToTelnyxObject($response->json, $opts);
         return $obj;
     }
-}
+}
\ No newline at end of file
diff --git a/lib/TwoFactorProfile.php b/lib/VerifyProfile.php
similarity index 64%
rename from lib/TwoFactorProfile.php
rename to lib/VerifyProfile.php
index cc31295..6c359d3 100644
--- a/lib/TwoFactorProfile.php
+++ b/lib/VerifyProfile.php
@@ -3,18 +3,17 @@
 namespace Telnyx;
 
 /**
- * Class TwoFactorProfile
+ * Class VerifyProfile
  *
  * @package Telnyx
  */
-class TwoFactorProfile extends ApiResource
+class VerifyProfile extends ApiResource
 {
-    const OBJECT_NAME = "2fa_profile";
+    const OBJECT_NAME = "verify_profile";
 
     use ApiOperations\All;
     use ApiOperations\Create;
     use ApiOperations\Retrieve;
     use ApiOperations\Update;
     use ApiOperations\Delete;
-    
-}
+}
\ No newline at end of file
diff --git a/lib/VerifyVerification.php b/lib/VerifyVerification.php
new file mode 100644
index 0000000..7bdd9ae
--- /dev/null
+++ b/lib/VerifyVerification.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace Telnyx;
+
+/**
+ * Class Verification
+ *
+ * @package Telnyx
+ */
+class VerifyVerification extends ApiResource
+{
+    const OBJECT_NAME = "verify_verification";
+
+    // Note: this is only a result used by VerificationTest
+}
\ No newline at end of file
diff --git a/tests/api_resources/AddressTest.php b/tests/api_resources/AddressTest.php
index da01bf6..f4fd24d 100644
--- a/tests/api_resources/AddressTest.php
+++ b/tests/api_resources/AddressTest.php
@@ -27,7 +27,14 @@ public function testIsCreatable()
             'post',
             '/v2/addresses'
         );
-        $resource = Address::create(['administrative_area'=>'IL']);
+        $resource = Address::create([
+            "first_name" => "Alfred",
+            "last_name" => "Foster",
+            "business_name" => "Company",
+            "country_code" => "US",
+            "locality" => "Chicago",
+            "street_address" => "311 W Superior Street"
+        ]);
         $this->assertInstanceOf(\Telnyx\Address::class, $resource);
     }
 
diff --git a/tests/api_resources/TwoFactorProfileTest.php b/tests/api_resources/TwoFactorProfileTest.php
deleted file mode 100644
index 91a8f19..0000000
--- a/tests/api_resources/TwoFactorProfileTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-namespace Telnyx;
-
-/**
- * @internal
- * @covers \Telnyx\TwoFactorProfile
- */
-final class TwoFactorProfileTest extends \Telnyx\TestCase
-{
-    const TEST_RESOURCE_ID = '12ade33a-21c0-473b-b055-b3c836e1c292';
-
-    /*
-    public function testIsListable()
-    {
-        $this->expectsRequest(
-            'get',
-            '/v2/2fa_profiles'
-        );
-        $resources = TwoFactorProfile::all();
-        $this->assertInstanceOf(\Telnyx\Collection::class, $resources);
-        $this->assertInstanceOf(\Telnyx\TwoFactorProfile::class, $resources['data'][0]);
-    }
-
-    public function testIsCreatable()
-    {
-        $this->expectsRequest(
-            'post',
-            '/v2/2fa_profiles'
-        );
-        $resource = TwoFactorProfile::create([
-            "name" => "Test Profile",
-            "default_timeout_secs" => 300
-        ]);
-        $this->assertInstanceOf(\Telnyx\TwoFactorProfile::class, $resource);
-    }
-    */
-
-    public function testIsRetrievable()
-    {
-        $this->expectsRequest(
-            'get',
-            '/v2/2fa_profiles/' . urlencode(self::TEST_RESOURCE_ID)
-        );
-        $resource = TwoFactorProfile::retrieve(self::TEST_RESOURCE_ID);
-        $this->assertInstanceOf(\Telnyx\TwoFactorProfile::class, $resource);
-    }
-
-    public function testIsDeletable()
-    {
-        $resource = TwoFactorProfile::retrieve(self::TEST_RESOURCE_ID);
-        $this->expectsRequest(
-            'delete',
-            '/v2/2fa_profiles/' . urlencode(self::TEST_RESOURCE_ID)
-        );
-        $resource->delete();
-        $this->assertInstanceOf(\Telnyx\TwoFactorProfile::class, $resource);
-    }
-
-    /*
-    public function testIsUpdatable()
-    {
-        $this->expectsRequest(
-            'patch',
-            '/v2/2fa_profiles/' . urlencode(self::TEST_RESOURCE_ID)
-        );
-        $resource = TwoFactorProfile::update(self::TEST_RESOURCE_ID, [
-            "name" => "Test Profile",
-            "default_timeout_secs" => 300
-        ]);
-        $this->assertInstanceOf(\Telnyx\TwoFactorProfile::class, $resource);
-    }
-    */
-}
diff --git a/tests/api_resources/TwoFactorVerifyTest.php b/tests/api_resources/TwoFactorVerifyTest.php
deleted file mode 100644
index e5bc7aa..0000000
--- a/tests/api_resources/TwoFactorVerifyTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-
-namespace Telnyx;
-
-/**
- * @internal
- * @covers \Telnyx\TwoFactorVerify
- */
-final class TwoFactorVerifyTest extends \Telnyx\TestCase
-{
-    const TEST_RESOURCE_ID = '12ade33a-21c0-473b-b055-b3c836e1c292';
-    const TEST_PHONE_NUMBER = '+13035551234';
-    const TEST_VERIFICATION_CODE = '17686';
-
-    /*
-    public function testIsCreatable()
-    {
-        $this->expectsRequest(
-            'post',
-            '/v2/2fa_verifications'
-        );
-        $resource = TwoFactorVerify::create([
-            "phone_number" => self::TEST_PHONE_NUMBER,
-            "twofa_profile_id" => self::TEST_RESOURCE_ID,
-            "type" => "sms"
-        ]);
-        $this->assertInstanceOf(\Telnyx\TwoFactorVerify::class, $resource);
-    }
-    */
-
-    public function testIsRetrievable()
-    {
-        $this->expectsRequest(
-            'get',
-            '/v2/2fa_verifications/' . urlencode(self::TEST_RESOURCE_ID)
-        );
-        $resource = TwoFactorVerify::retrieve(self::TEST_RESOURCE_ID);
-        $this->assertInstanceOf(\Telnyx\TwoFactorVerify::class, $resource);
-    }
-
-    /*
-    public function testRetrieveByPhoneNumber()
-    {
-        $this->expectsRequest(
-            'get',
-            '/v2/2fa_verifications/by_tn/' . urlencode(self::TEST_PHONE_NUMBER)
-        );
-        $resource = TwoFactorVerify::retrieve_by_phone_number(self::TEST_PHONE_NUMBER);
-        $this->assertInstanceOf(\Telnyx\TwoFactorVerify::class, $resource);
-    }
-
-    public function testSubmitVerification()
-    {
-        $this->expectsRequest(
-            'post',
-            '/v2/2fa_verifications/by_tn/' . urlencode(self::TEST_PHONE_NUMBER) . '/actions/verify'
-        );
-        $resource = TwoFactorVerify::submit_verification(self::TEST_PHONE_NUMBER, self::TEST_VERIFICATION_CODE);
-        $this->assertInstanceOf(\Telnyx\TwoFactorVerify::class, $resource);
-    }
-    */
-
-}
diff --git a/tests/api_resources/VerificationTest.php b/tests/api_resources/VerificationTest.php
new file mode 100644
index 0000000..ec1ee5b
--- /dev/null
+++ b/tests/api_resources/VerificationTest.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Telnyx;
+
+/**
+ * @internal
+ * @covers \Telnyx\Verification
+ */
+final class VerificationTest extends \Telnyx\TestCase
+{
+    const TEST_RESOURCE_ID = '12ade33a-21c0-473b-b055-b3c836e1c292';
+    const TEST_PHONE_NUMBER = '+13035551234';
+    const TEST_VERIFICATION_CODE = '17686';
+
+    public function testIsCreatable()
+    {
+        $this->expectsRequest(
+            'post',
+            '/v2/verifications'
+        );
+        $resource = Verification::create([
+            "verify_profile_id" => self::TEST_RESOURCE_ID,
+            "phone_number" => self::TEST_PHONE_NUMBER,
+            "type" => "sms"
+        ]);
+        $this->assertInstanceOf(\Telnyx\VerifyVerification::class, $resource);
+    }
+
+    public function testIsRetrievable()
+    {
+        $this->expectsRequest(
+            'get',
+            '/v2/verifications/' . urlencode(self::TEST_RESOURCE_ID)
+        );
+        $resource = Verification::retrieve(self::TEST_RESOURCE_ID);
+        $this->assertInstanceOf(\Telnyx\Verification::class, $resource);
+    }
+
+    public function testRetrieveByPhoneNumber()
+    {
+        $this->expectsRequest(
+            'get',
+            '/v2/verifications/by_phone_number/' . urlencode(self::TEST_PHONE_NUMBER)
+        );
+        $resource = Verification::retrieve_by_phone_number(self::TEST_PHONE_NUMBER);
+        $this->assertInstanceOf(\Telnyx\Collection::class, $resource);
+        $this->assertInstanceOf(\Telnyx\VerifyVerification::class, $resource['data'][0]);
+    }
+
+    public function testSubmitVerification()
+    {
+        $this->expectsRequest(
+            'post',
+            '/v2/verifications/by_phone_number/' . urlencode(self::TEST_PHONE_NUMBER) . '/actions/verify'
+        );
+        $resource = Verification::submit_verification(self::TEST_PHONE_NUMBER, self::TEST_VERIFICATION_CODE);
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $resource);
+    }
+
+}
diff --git a/tests/api_resources/VerifyProfileTest.php b/tests/api_resources/VerifyProfileTest.php
new file mode 100644
index 0000000..4f7c910
--- /dev/null
+++ b/tests/api_resources/VerifyProfileTest.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace Telnyx;
+
+/**
+ * @internal
+ * @covers \Telnyx\VerifyProfile
+ */
+final class VerifyProfileTest extends \Telnyx\TestCase
+{
+    const TEST_RESOURCE_ID = '12ade33a-21c0-473b-b055-b3c836e1c292';
+
+    public function testIsListable()
+    {
+        $this->expectsRequest(
+            'get',
+            '/v2/verify_profiles'
+        );
+        $resources = VerifyProfile::all();
+        $this->assertInstanceOf(\Telnyx\Collection::class, $resources);
+        $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resources['data'][0]);
+    }
+
+    public function testIsCreatable()
+    {
+        $this->expectsRequest(
+            'post',
+            '/v2/verify_profiles'
+        );
+        $resource = VerifyProfile::create([
+            "name" => "Test Profile",
+            "default_timeout_secs" => 300
+        ]);
+        $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
+    }
+
+    public function testIsRetrievable()
+    {
+        $this->expectsRequest(
+            'get',
+            '/v2/verify_profiles/' . urlencode(self::TEST_RESOURCE_ID)
+        );
+        $resource = VerifyProfile::retrieve(self::TEST_RESOURCE_ID);
+        $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
+    }
+
+    public function testIsDeletable()
+    {
+        $resource = VerifyProfile::retrieve(self::TEST_RESOURCE_ID);
+        $this->expectsRequest(
+            'delete',
+            '/v2/verify_profiles/' . urlencode(self::TEST_RESOURCE_ID)
+        );
+        $resource->delete();
+        $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
+    }
+
+    /*
+    public function testIsUpdatable()
+    {
+        $this->expectsRequest(
+            'patch',
+            '/v2/verify_profiles/' . urlencode(self::TEST_RESOURCE_ID)
+        );
+
+        VerifyProfile::update(self::TEST_RESOURCE_ID, [
+            "name" => "Test Profile",
+            "default_timeout_secs" => 300
+        ]);
+        $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
+    }
+    */
+}

From 833e4e8150fad3506379ca4a3d837432b0203d4b Mon Sep 17 00:00:00 2001
From: weroh <50031971+weroh@users.noreply.github.com>
Date: Sat, 12 Dec 2020 10:35:56 -0800
Subject: [PATCH 2/5] Modified the delete method to be able to be called
 statically

Updated delete trait and associated tests
---
 lib/ApiOperations/Delete.php                  | 20 +++++++++++--------
 lib/ApiOperations/Update.php                  | 16 ---------------
 tests/api_resources/AddressTest.php           |  3 +--
 .../ApiOperations/DeleteTest.php              |  3 +--
 .../ApiOperations/UpdateTest.php              |  9 ---------
 tests/api_resources/BillingGroupTest.php      |  3 +--
 .../CallControlApplicationTest.php            |  3 +--
 .../CredentialConnectionTest.php              |  3 +--
 tests/api_resources/FQDNConnectionTest.php    |  3 +--
 tests/api_resources/FQDNTest.php              |  3 +--
 tests/api_resources/IPConnectionTest.php      |  3 +--
 tests/api_resources/IPTest.php                |  3 +--
 tests/api_resources/MessagingProfileTest.php  |  7 ++-----
 .../OutboundVoiceProfileTest.php              |  3 +--
 tests/api_resources/PhoneNumberTest.php       |  3 +--
 tests/api_resources/VerifyProfileTest.php     |  3 +--
 16 files changed, 26 insertions(+), 62 deletions(-)

diff --git a/lib/ApiOperations/Delete.php b/lib/ApiOperations/Delete.php
index 03c9ed7..d6dee03 100644
--- a/lib/ApiOperations/Delete.php
+++ b/lib/ApiOperations/Delete.php
@@ -3,25 +3,29 @@
 namespace Telnyx\ApiOperations;
 
 /**
- * Trait for deletable resources. Adds a `delete()` method to the class.
+ * Trait for deletable resources. Adds a `delete()` and `remove()` method to the class.
  *
  * This trait should only be applied to classes that derive from TelnyxObject.
  */
 trait Delete
-{
+{    
     /**
+     * @param string $id The ID of the resource to delete.
      * @param array|null $params
      * @param array|string|null $opts
      *
-     * @return \Telnyx\ApiResource The deleted resource.
+     * @return \Telnyx\ApiResource The updated resource.
      */
-    public function delete($params = null, $opts = null)
+    public static function delete($id, $params = null, $opts = null)
     {
         self::_validateParams($params);
 
-        $url = $this->instanceUrl();
-        list($response, $opts) = $this->_request('delete', $url, $params, $opts);
-        $this->refreshFrom($response, $opts);
-        return $this;
+        $url = static::resourceUrl($id);
+
+        list($response, $opts) = static::_staticRequest('delete', $url, $params, $opts);
+        $obj = \Telnyx\Util\Util::convertToTelnyxObject($response->json, $opts);
+        $obj->setLastResponse($response);
+
+        return $obj;
     }
 }
diff --git a/lib/ApiOperations/Update.php b/lib/ApiOperations/Update.php
index 079d036..3f49b19 100644
--- a/lib/ApiOperations/Update.php
+++ b/lib/ApiOperations/Update.php
@@ -27,20 +27,4 @@ public static function update($id, $params = null, $opts = null)
         $obj->setLastResponse($response);
         return $obj;
     }
-
-    /**
-     * @param array|string|null $opts
-     *
-     * @return \Telnyx\ApiResource The saved resource.
-     */
-    public function save($opts = null)
-    {
-        $params = $this->serializeParameters();
-        if (count($params) > 0) {
-            $url = $this->instanceUrl();
-            list($response, $opts) = $this->_request('patch', $url, $params, $opts);
-            $this->refreshFrom($response, $opts);
-        }
-        return $this;
-    }
 }
diff --git a/tests/api_resources/AddressTest.php b/tests/api_resources/AddressTest.php
index f4fd24d..fd11445 100644
--- a/tests/api_resources/AddressTest.php
+++ b/tests/api_resources/AddressTest.php
@@ -40,12 +40,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = Address::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/addresses/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = Address::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\Address::class, $resource);
     }
 
diff --git a/tests/api_resources/ApiOperations/DeleteTest.php b/tests/api_resources/ApiOperations/DeleteTest.php
index 01cee21..3911112 100644
--- a/tests/api_resources/ApiOperations/DeleteTest.php
+++ b/tests/api_resources/ApiOperations/DeleteTest.php
@@ -20,8 +20,7 @@ final class DeleteTest extends \Telnyx\TestCase
 
     public function testTraitDelete()
     {
-        $class = new DummyDelete(self::TEST_RESOURCE_ID);
-        $result = $class->delete();
+        $result = DummyDelete::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $result);
     }
 }
diff --git a/tests/api_resources/ApiOperations/UpdateTest.php b/tests/api_resources/ApiOperations/UpdateTest.php
index f298d0f..eb1b72e 100644
--- a/tests/api_resources/ApiOperations/UpdateTest.php
+++ b/tests/api_resources/ApiOperations/UpdateTest.php
@@ -25,13 +25,4 @@ public function testTraitUpdate()
         $this->assertNotNull($result['connection_id']);
         $this->assertNotNull($result['id']);
     }
-
-    public function testTraitSave()
-    {
-        $class = new DummyUpdate(self::TEST_RESOURCE_ID);
-        $class->customer_reference = 'MY REF 001';
-        $result = $class->save();
-        $this->assertNotNull($result['connection_id']);
-        $this->assertNotNull($result['id']);
-    }
 }
diff --git a/tests/api_resources/BillingGroupTest.php b/tests/api_resources/BillingGroupTest.php
index 9f6e2c8..a30d31c 100644
--- a/tests/api_resources/BillingGroupTest.php
+++ b/tests/api_resources/BillingGroupTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = BillingGroup::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/billing_groups/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = BillingGroup::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\BillingGroup::class, $resource);
     }
 
diff --git a/tests/api_resources/CallControlApplicationTest.php b/tests/api_resources/CallControlApplicationTest.php
index d094315..303121b 100644
--- a/tests/api_resources/CallControlApplicationTest.php
+++ b/tests/api_resources/CallControlApplicationTest.php
@@ -36,12 +36,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = CallControlApplication::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/call_control_applications/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = CallControlApplication::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\CallControlApplication::class, $resource);
     }
 
diff --git a/tests/api_resources/CredentialConnectionTest.php b/tests/api_resources/CredentialConnectionTest.php
index 9ac6bb1..f7d093b 100644
--- a/tests/api_resources/CredentialConnectionTest.php
+++ b/tests/api_resources/CredentialConnectionTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = CredentialConnection::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/credential_connections/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = CredentialConnection::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\CredentialConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/FQDNConnectionTest.php b/tests/api_resources/FQDNConnectionTest.php
index 5b66ee2..6662183 100644
--- a/tests/api_resources/FQDNConnectionTest.php
+++ b/tests/api_resources/FQDNConnectionTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = FQDNConnection::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/fqdn_connections/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = FQDNConnection::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\FQDNConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/FQDNTest.php b/tests/api_resources/FQDNTest.php
index ba85c8f..19ac2f1 100644
--- a/tests/api_resources/FQDNTest.php
+++ b/tests/api_resources/FQDNTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = FQDN::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/fqdns/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = FQDN::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\FQDN::class, $resource);
     }
 
diff --git a/tests/api_resources/IPConnectionTest.php b/tests/api_resources/IPConnectionTest.php
index eeef9c8..f37c6c6 100644
--- a/tests/api_resources/IPConnectionTest.php
+++ b/tests/api_resources/IPConnectionTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = IPConnection::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/ip_connections/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = IPConnection::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\IPConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/IPTest.php b/tests/api_resources/IPTest.php
index cb7776d..aae2bac 100644
--- a/tests/api_resources/IPTest.php
+++ b/tests/api_resources/IPTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = IP::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/ips/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = IP::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\IP::class, $resource);
     }
 
diff --git a/tests/api_resources/MessagingProfileTest.php b/tests/api_resources/MessagingProfileTest.php
index 7173f35..bcc6a44 100644
--- a/tests/api_resources/MessagingProfileTest.php
+++ b/tests/api_resources/MessagingProfileTest.php
@@ -57,16 +57,14 @@ public function testIsUpdatable()
 
     public function testIsDeletable()
     {
-        $resource = MessagingProfile::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/messaging_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = MessagingProfile::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\MessagingProfile::class, $resource);
     }
 
-    /*
     public function testPhoneNumbers()
     {
         $messaging_profile = MessagingProfile::retrieve(self::TEST_RESOURCE_ID);
@@ -76,9 +74,8 @@ public function testPhoneNumbers()
         );
         $resources = $messaging_profile->phone_numbers();
         $this->assertInstanceOf(\Telnyx\MessagingProfile::class, $resources);
-        $this->assertInstanceOf(\Telnyx\MessagingPhoneNumber::class, $resources['data'][0]);
+        $this->assertInstanceOf(\Telnyx\PhoneNumber\Messaging::class, $resources['data'][0]);
     }
-    */
 
     public function testShortCodes()
     {
diff --git a/tests/api_resources/OutboundVoiceProfileTest.php b/tests/api_resources/OutboundVoiceProfileTest.php
index 415897f..a7d370b 100644
--- a/tests/api_resources/OutboundVoiceProfileTest.php
+++ b/tests/api_resources/OutboundVoiceProfileTest.php
@@ -33,12 +33,11 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
-        $resource = OutboundVoiceProfile::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/outbound_voice_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = OutboundVoiceProfile::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resource);
     }
 
diff --git a/tests/api_resources/PhoneNumberTest.php b/tests/api_resources/PhoneNumberTest.php
index 820142e..483f8bc 100644
--- a/tests/api_resources/PhoneNumberTest.php
+++ b/tests/api_resources/PhoneNumberTest.php
@@ -23,12 +23,11 @@ public function testIsListable()
 
     public function testIsDeletable()
     {
-        $resource = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = PhoneNumber::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\PhoneNumber::class, $resource);
     }
 
diff --git a/tests/api_resources/VerifyProfileTest.php b/tests/api_resources/VerifyProfileTest.php
index 4f7c910..019c075 100644
--- a/tests/api_resources/VerifyProfileTest.php
+++ b/tests/api_resources/VerifyProfileTest.php
@@ -46,12 +46,11 @@ public function testIsRetrievable()
 
     public function testIsDeletable()
     {
-        $resource = VerifyProfile::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/verify_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource->delete();
+        $resource = VerifyProfile::delete(self::TEST_RESOURCE_ID);
         $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
     }
 

From 445e5933129458887b27e054b11d04b44e685102 Mon Sep 17 00:00:00 2001
From: weroh <50031971+weroh@users.noreply.github.com>
Date: Tue, 15 Dec 2020 08:07:41 -0800
Subject: [PATCH 3/5] Revert "Modified the delete method to be able to be
 called statically"

This reverts commit 833e4e8150fad3506379ca4a3d837432b0203d4b.
---
 lib/ApiOperations/Delete.php                  | 20 ++++++++-----------
 lib/ApiOperations/Update.php                  | 16 +++++++++++++++
 tests/api_resources/AddressTest.php           |  3 ++-
 .../ApiOperations/DeleteTest.php              |  3 ++-
 .../ApiOperations/UpdateTest.php              |  9 +++++++++
 tests/api_resources/BillingGroupTest.php      |  3 ++-
 .../CallControlApplicationTest.php            |  3 ++-
 .../CredentialConnectionTest.php              |  3 ++-
 tests/api_resources/FQDNConnectionTest.php    |  3 ++-
 tests/api_resources/FQDNTest.php              |  3 ++-
 tests/api_resources/IPConnectionTest.php      |  3 ++-
 tests/api_resources/IPTest.php                |  3 ++-
 tests/api_resources/MessagingProfileTest.php  |  7 +++++--
 .../OutboundVoiceProfileTest.php              |  3 ++-
 tests/api_resources/PhoneNumberTest.php       |  3 ++-
 tests/api_resources/VerifyProfileTest.php     |  3 ++-
 16 files changed, 62 insertions(+), 26 deletions(-)

diff --git a/lib/ApiOperations/Delete.php b/lib/ApiOperations/Delete.php
index d6dee03..03c9ed7 100644
--- a/lib/ApiOperations/Delete.php
+++ b/lib/ApiOperations/Delete.php
@@ -3,29 +3,25 @@
 namespace Telnyx\ApiOperations;
 
 /**
- * Trait for deletable resources. Adds a `delete()` and `remove()` method to the class.
+ * Trait for deletable resources. Adds a `delete()` method to the class.
  *
  * This trait should only be applied to classes that derive from TelnyxObject.
  */
 trait Delete
-{    
+{
     /**
-     * @param string $id The ID of the resource to delete.
      * @param array|null $params
      * @param array|string|null $opts
      *
-     * @return \Telnyx\ApiResource The updated resource.
+     * @return \Telnyx\ApiResource The deleted resource.
      */
-    public static function delete($id, $params = null, $opts = null)
+    public function delete($params = null, $opts = null)
     {
         self::_validateParams($params);
 
-        $url = static::resourceUrl($id);
-
-        list($response, $opts) = static::_staticRequest('delete', $url, $params, $opts);
-        $obj = \Telnyx\Util\Util::convertToTelnyxObject($response->json, $opts);
-        $obj->setLastResponse($response);
-
-        return $obj;
+        $url = $this->instanceUrl();
+        list($response, $opts) = $this->_request('delete', $url, $params, $opts);
+        $this->refreshFrom($response, $opts);
+        return $this;
     }
 }
diff --git a/lib/ApiOperations/Update.php b/lib/ApiOperations/Update.php
index 3f49b19..079d036 100644
--- a/lib/ApiOperations/Update.php
+++ b/lib/ApiOperations/Update.php
@@ -27,4 +27,20 @@ public static function update($id, $params = null, $opts = null)
         $obj->setLastResponse($response);
         return $obj;
     }
+
+    /**
+     * @param array|string|null $opts
+     *
+     * @return \Telnyx\ApiResource The saved resource.
+     */
+    public function save($opts = null)
+    {
+        $params = $this->serializeParameters();
+        if (count($params) > 0) {
+            $url = $this->instanceUrl();
+            list($response, $opts) = $this->_request('patch', $url, $params, $opts);
+            $this->refreshFrom($response, $opts);
+        }
+        return $this;
+    }
 }
diff --git a/tests/api_resources/AddressTest.php b/tests/api_resources/AddressTest.php
index fd11445..f4fd24d 100644
--- a/tests/api_resources/AddressTest.php
+++ b/tests/api_resources/AddressTest.php
@@ -40,11 +40,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = Address::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/addresses/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = Address::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\Address::class, $resource);
     }
 
diff --git a/tests/api_resources/ApiOperations/DeleteTest.php b/tests/api_resources/ApiOperations/DeleteTest.php
index 3911112..01cee21 100644
--- a/tests/api_resources/ApiOperations/DeleteTest.php
+++ b/tests/api_resources/ApiOperations/DeleteTest.php
@@ -20,7 +20,8 @@ final class DeleteTest extends \Telnyx\TestCase
 
     public function testTraitDelete()
     {
-        $result = DummyDelete::delete(self::TEST_RESOURCE_ID);
+        $class = new DummyDelete(self::TEST_RESOURCE_ID);
+        $result = $class->delete();
         $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $result);
     }
 }
diff --git a/tests/api_resources/ApiOperations/UpdateTest.php b/tests/api_resources/ApiOperations/UpdateTest.php
index eb1b72e..f298d0f 100644
--- a/tests/api_resources/ApiOperations/UpdateTest.php
+++ b/tests/api_resources/ApiOperations/UpdateTest.php
@@ -25,4 +25,13 @@ public function testTraitUpdate()
         $this->assertNotNull($result['connection_id']);
         $this->assertNotNull($result['id']);
     }
+
+    public function testTraitSave()
+    {
+        $class = new DummyUpdate(self::TEST_RESOURCE_ID);
+        $class->customer_reference = 'MY REF 001';
+        $result = $class->save();
+        $this->assertNotNull($result['connection_id']);
+        $this->assertNotNull($result['id']);
+    }
 }
diff --git a/tests/api_resources/BillingGroupTest.php b/tests/api_resources/BillingGroupTest.php
index a30d31c..9f6e2c8 100644
--- a/tests/api_resources/BillingGroupTest.php
+++ b/tests/api_resources/BillingGroupTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = BillingGroup::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/billing_groups/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = BillingGroup::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\BillingGroup::class, $resource);
     }
 
diff --git a/tests/api_resources/CallControlApplicationTest.php b/tests/api_resources/CallControlApplicationTest.php
index 303121b..d094315 100644
--- a/tests/api_resources/CallControlApplicationTest.php
+++ b/tests/api_resources/CallControlApplicationTest.php
@@ -36,11 +36,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = CallControlApplication::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/call_control_applications/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = CallControlApplication::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\CallControlApplication::class, $resource);
     }
 
diff --git a/tests/api_resources/CredentialConnectionTest.php b/tests/api_resources/CredentialConnectionTest.php
index f7d093b..9ac6bb1 100644
--- a/tests/api_resources/CredentialConnectionTest.php
+++ b/tests/api_resources/CredentialConnectionTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = CredentialConnection::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/credential_connections/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = CredentialConnection::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\CredentialConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/FQDNConnectionTest.php b/tests/api_resources/FQDNConnectionTest.php
index 6662183..5b66ee2 100644
--- a/tests/api_resources/FQDNConnectionTest.php
+++ b/tests/api_resources/FQDNConnectionTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = FQDNConnection::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/fqdn_connections/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = FQDNConnection::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\FQDNConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/FQDNTest.php b/tests/api_resources/FQDNTest.php
index 19ac2f1..ba85c8f 100644
--- a/tests/api_resources/FQDNTest.php
+++ b/tests/api_resources/FQDNTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = FQDN::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/fqdns/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = FQDN::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\FQDN::class, $resource);
     }
 
diff --git a/tests/api_resources/IPConnectionTest.php b/tests/api_resources/IPConnectionTest.php
index f37c6c6..eeef9c8 100644
--- a/tests/api_resources/IPConnectionTest.php
+++ b/tests/api_resources/IPConnectionTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = IPConnection::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/ip_connections/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = IPConnection::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\IPConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/IPTest.php b/tests/api_resources/IPTest.php
index aae2bac..cb7776d 100644
--- a/tests/api_resources/IPTest.php
+++ b/tests/api_resources/IPTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = IP::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/ips/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = IP::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\IP::class, $resource);
     }
 
diff --git a/tests/api_resources/MessagingProfileTest.php b/tests/api_resources/MessagingProfileTest.php
index bcc6a44..7173f35 100644
--- a/tests/api_resources/MessagingProfileTest.php
+++ b/tests/api_resources/MessagingProfileTest.php
@@ -57,14 +57,16 @@ public function testIsUpdatable()
 
     public function testIsDeletable()
     {
+        $resource = MessagingProfile::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/messaging_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = MessagingProfile::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\MessagingProfile::class, $resource);
     }
 
+    /*
     public function testPhoneNumbers()
     {
         $messaging_profile = MessagingProfile::retrieve(self::TEST_RESOURCE_ID);
@@ -74,8 +76,9 @@ public function testPhoneNumbers()
         );
         $resources = $messaging_profile->phone_numbers();
         $this->assertInstanceOf(\Telnyx\MessagingProfile::class, $resources);
-        $this->assertInstanceOf(\Telnyx\PhoneNumber\Messaging::class, $resources['data'][0]);
+        $this->assertInstanceOf(\Telnyx\MessagingPhoneNumber::class, $resources['data'][0]);
     }
+    */
 
     public function testShortCodes()
     {
diff --git a/tests/api_resources/OutboundVoiceProfileTest.php b/tests/api_resources/OutboundVoiceProfileTest.php
index a7d370b..415897f 100644
--- a/tests/api_resources/OutboundVoiceProfileTest.php
+++ b/tests/api_resources/OutboundVoiceProfileTest.php
@@ -33,11 +33,12 @@ public function testIsCreatable()
 
     public function testIsDeletable()
     {
+        $resource = OutboundVoiceProfile::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/outbound_voice_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = OutboundVoiceProfile::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resource);
     }
 
diff --git a/tests/api_resources/PhoneNumberTest.php b/tests/api_resources/PhoneNumberTest.php
index 483f8bc..820142e 100644
--- a/tests/api_resources/PhoneNumberTest.php
+++ b/tests/api_resources/PhoneNumberTest.php
@@ -23,11 +23,12 @@ public function testIsListable()
 
     public function testIsDeletable()
     {
+        $resource = PhoneNumber::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/phone_numbers/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = PhoneNumber::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\PhoneNumber::class, $resource);
     }
 
diff --git a/tests/api_resources/VerifyProfileTest.php b/tests/api_resources/VerifyProfileTest.php
index 019c075..4f7c910 100644
--- a/tests/api_resources/VerifyProfileTest.php
+++ b/tests/api_resources/VerifyProfileTest.php
@@ -46,11 +46,12 @@ public function testIsRetrievable()
 
     public function testIsDeletable()
     {
+        $resource = VerifyProfile::retrieve(self::TEST_RESOURCE_ID);
         $this->expectsRequest(
             'delete',
             '/v2/verify_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
-        $resource = VerifyProfile::delete(self::TEST_RESOURCE_ID);
+        $resource->delete();
         $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
     }
 

From fcc4fbd2229d7e6a3ba608321a62840eb09eae7d Mon Sep 17 00:00:00 2001
From: weroh <50031971+weroh@users.noreply.github.com>
Date: Tue, 15 Dec 2020 08:30:09 -0800
Subject: [PATCH 4/5] Added remove() method to Delete trait to be called
 statically

Based on commit "Modified the delete method to be able to be called statically"
---
 lib/ApiOperations/Delete.php                  | 20 +++++++++++++++++++
 .../ApiOperations/DeleteTest.php              |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/lib/ApiOperations/Delete.php b/lib/ApiOperations/Delete.php
index 03c9ed7..72eaed7 100644
--- a/lib/ApiOperations/Delete.php
+++ b/lib/ApiOperations/Delete.php
@@ -24,4 +24,24 @@ public function delete($params = null, $opts = null)
         $this->refreshFrom($response, $opts);
         return $this;
     }
+    
+    /**
+     * @param string $id The ID of the resource to delete.
+     * @param array|null $params
+     * @param array|string|null $opts
+     *
+     * @return \Telnyx\ApiResource The updated resource.
+     */
+    public static function remove($id, $params = null, $opts = null)
+    {
+        self::_validateParams($params);
+
+        $url = static::resourceUrl($id);
+
+        list($response, $opts) = static::_staticRequest('delete', $url, $params, $opts);
+        $obj = \Telnyx\Util\Util::convertToTelnyxObject($response->json, $opts);
+        $obj->setLastResponse($response);
+
+        return $obj;
+    }
 }
diff --git a/tests/api_resources/ApiOperations/DeleteTest.php b/tests/api_resources/ApiOperations/DeleteTest.php
index 01cee21..1bc4eac 100644
--- a/tests/api_resources/ApiOperations/DeleteTest.php
+++ b/tests/api_resources/ApiOperations/DeleteTest.php
@@ -24,4 +24,9 @@ public function testTraitDelete()
         $result = $class->delete();
         $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $result);
     }
+    public function testTraitRemove()
+    {
+        $result = DummyDelete::remove(self::TEST_RESOURCE_ID);
+        $this->assertInstanceOf(\Telnyx\TelnyxObject::class, $result);
+    }
 }

From cb4fa8417f22e24fbb25c3012d5e7b0a1f3f85c3 Mon Sep 17 00:00:00 2001
From: weroh <50031971+weroh@users.noreply.github.com>
Date: Tue, 15 Dec 2020 09:14:12 -0800
Subject: [PATCH 5/5] Updated Tests

-Updated VerificationTest and VerifyProfileTest
-Updated CredentialConnectionTest with required fields
---
 tests/api_resources/CredentialConnectionTest.php | 7 ++++++-
 tests/api_resources/VerificationTest.php         | 4 ++--
 tests/api_resources/VerifyProfileTest.php        | 4 +---
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tests/api_resources/CredentialConnectionTest.php b/tests/api_resources/CredentialConnectionTest.php
index 9ac6bb1..780796c 100644
--- a/tests/api_resources/CredentialConnectionTest.php
+++ b/tests/api_resources/CredentialConnectionTest.php
@@ -27,7 +27,12 @@ public function testIsCreatable()
             'post',
             '/v2/credential_connections'
         );
-        $resource = CredentialConnection::create(["connection_name" => "Test Connection"]);
+        $resource = CredentialConnection::create([
+            'user_name' => 'test_user',
+            'password' => 'iloveyou',
+            'connection_name' => 'Test Connection',
+            "anchorsite_override" => "Latency"
+        ]);
         $this->assertInstanceOf(\Telnyx\CredentialConnection::class, $resource);
     }
 
diff --git a/tests/api_resources/VerificationTest.php b/tests/api_resources/VerificationTest.php
index ec1ee5b..4737a7b 100644
--- a/tests/api_resources/VerificationTest.php
+++ b/tests/api_resources/VerificationTest.php
@@ -23,7 +23,7 @@ public function testIsCreatable()
             "phone_number" => self::TEST_PHONE_NUMBER,
             "type" => "sms"
         ]);
-        $this->assertInstanceOf(\Telnyx\VerifyVerification::class, $resource);
+        $this->assertInstanceOf(\Telnyx\Verification::class, $resource);
     }
 
     public function testIsRetrievable()
@@ -44,7 +44,7 @@ public function testRetrieveByPhoneNumber()
         );
         $resource = Verification::retrieve_by_phone_number(self::TEST_PHONE_NUMBER);
         $this->assertInstanceOf(\Telnyx\Collection::class, $resource);
-        $this->assertInstanceOf(\Telnyx\VerifyVerification::class, $resource['data'][0]);
+        $this->assertInstanceOf(\Telnyx\Verification::class, $resource['data'][0]);
     }
 
     public function testSubmitVerification()
diff --git a/tests/api_resources/VerifyProfileTest.php b/tests/api_resources/VerifyProfileTest.php
index 4f7c910..1bc6b5b 100644
--- a/tests/api_resources/VerifyProfileTest.php
+++ b/tests/api_resources/VerifyProfileTest.php
@@ -55,7 +55,6 @@ public function testIsDeletable()
         $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
     }
 
-    /*
     public function testIsUpdatable()
     {
         $this->expectsRequest(
@@ -63,11 +62,10 @@ public function testIsUpdatable()
             '/v2/verify_profiles/' . urlencode(self::TEST_RESOURCE_ID)
         );
 
-        VerifyProfile::update(self::TEST_RESOURCE_ID, [
+        $resource = VerifyProfile::update(self::TEST_RESOURCE_ID, [
             "name" => "Test Profile",
             "default_timeout_secs" => 300
         ]);
         $this->assertInstanceOf(\Telnyx\VerifyProfile::class, $resource);
     }
-    */
 }