Skip to content

Commit

Permalink
Added Outbound Voice Profiles (#24)
Browse files Browse the repository at this point in the history
* Update ApiRequestor.php

Fixed params for isset()

* Added OutboundVoiceProfile

Added OutboundVoiceProfile

* Create OutboundVoiceProfileTest.php

Create OutboundVoiceProfileTest.php
  • Loading branch information
weroh committed Mar 16, 2020
1 parent 807873c commit 52a5d19
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
require(dirname(__FILE__) . '/lib/MessagingPhoneNumber.php');
require(dirname(__FILE__) . '/lib/AlphanumericSenderID.php');
require(dirname(__FILE__) . '/lib/ShortCode.php');
require(dirname(__FILE__) . '/lib/OutboundVoiceProfile.php');

// Telnyx API: Billing
require(dirname(__FILE__) . '/lib/BillingGroup.php');
Expand Down
20 changes: 20 additions & 0 deletions lib/OutboundVoiceProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Telnyx;

/**
* Class OutboundVoiceProfile
*
* @package Telnyx
*/
class OutboundVoiceProfile extends ApiResource
{
const OBJECT_NAME = "outbound_voice_profile";

use ApiOperations\All;
use ApiOperations\Create;
use ApiOperations\Delete;
use ApiOperations\Retrieve;
use ApiOperations\Update;

}
1 change: 1 addition & 0 deletions lib/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static function convertToTelnyxObject($resp, $opts)
\Telnyx\MessagingPhoneNumber::OBJECT_NAME => 'Telnyx\\MessagingPhoneNumber',
\Telnyx\AlphanumericSenderID::OBJECT_NAME => 'Telnyx\\AlphanumericSenderID',
\Telnyx\ShortCode::OBJECT_NAME => 'Telnyx\\ShortCode',
\Telnyx\OutboundVoiceProfile::OBJECT_NAME => 'Telnyx\\OutboundVoiceProfile',

// Telnyx API: Billing
\Telnyx\BillingGroup::OBJECT_NAME => 'Telnyx\\BillingGroup',
Expand Down
63 changes: 63 additions & 0 deletions tests/api_resources/OutboundVoiceProfileTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Telnyx;

class OutboundVoiceProfileTest extends TestCase
{
const TEST_RESOURCE_ID = '123';

public function testIsListable()
{
$this->expectsRequest(
'get',
'/v2/outbound_voice_profiles'
);
$resources = OutboundVoiceProfile::all();
$this->assertInstanceOf(\Telnyx\Collection::class, $resources);
$this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resources[0]);
}

public function testIsCreatable()
{
$this->expectsRequest(
'post',
'/v2/outbound_voice_profiles'
);
$resource = OutboundVoiceProfile::create(["daily_spend_limit" => "1"]);
$this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resource);
}

public function testIsDeletable()
{
$resource = OutboundVoiceProfile::retrieve(self::TEST_RESOURCE_ID);
$this->expectsRequest(
'delete',
'/v2/outbound_voice_profiles/' . urlencode(self::TEST_RESOURCE_ID)
);
$resource->delete();
$this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resource);
}

public function testIsRetrievable()
{
$this->expectsRequest(
'get',
'/v2/outbound_voice_profiles/' . urlencode(self::TEST_RESOURCE_ID)
);
$resource = OutboundVoiceProfile::retrieve(self::TEST_RESOURCE_ID);
$this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resource);
}

public function testIsUpdatable()
{
$this->expectsRequest(
'patch',
'/v2/outbound_voice_profiles/' . urlencode(self::TEST_RESOURCE_ID)
);
$resource = OutboundVoiceProfile::update(self::TEST_RESOURCE_ID, [
"daily_spend_limit" => "1"
]);
$this->assertInstanceOf(\Telnyx\OutboundVoiceProfile::class, $resource);
}

}

0 comments on commit 52a5d19

Please sign in to comment.