function testGet() { $http = m::mock(new Services_Twilio_TinyHttp()); $http->shouldReceive('get')->once()->with('/v1/Workspaces/WS123/Statistics?Minutes=60')->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array('account_sid' => 'AC123')))); $taskrouterClient = new TaskRouter_Services_Twilio('AC123', '123', 'WS123', 'v1', $http); $stats = $taskrouterClient->getWorkspaceStatistics(array('Minutes' => 60)); $this->assertNotNull($stats); $this->assertEquals('AC123', $stats->account_sid); }
<?php // Get the PHP helper library from twilio.com/docs/php/install require_once '/path/to/twilio-php/Services/Twilio.php'; // Loads the library // Your Account Sid and Auth Token from twilio.com/user/account $accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $authToken = "your_auth_token"; $workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $workerSid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid); $statistics = $client->getWorkerStatistics($workerSid, array('Minutes' => 60)); echo $statistics->cumulative->reservations_accepted;
function testCreateWorkspace() { $http = m::mock(new Services_Twilio_TinyHttp()); $http->shouldReceive('post')->once()->with('/v1/Workspaces', array('Content-Type' => 'application/x-www-form-urlencoded'), 'FriendlyName=Test+Workspace')->andReturn(array(200, array('Content-Type' => 'application/json'), json_encode(array('sid' => 'WS123')))); $workspace = TaskRouter_Services_Twilio::createWorkspace('AC123', '123', 'Test Workspace', array(), $http); $this->assertNotNull($workspace); }
<?php // Get the PHP helper library from twilio.com/docs/php/install require_once '/path/to/twilio-php/Services/Twilio.php'; // Loads the library // Your Account Sid and Auth Token from twilio.com/user/account $accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $authToken = "your_auth_token"; $workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $taskQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid); $statistics = $client->getTaskQueueStatistics($taskQueueSid, array('Minutes' => 60)); echo $statistics->cumulative->reservations_accepted;
public function __construct($sid, $authToken, $workspaceSid, $retryattempts) { parent::__construct($sid, $authToken, $workspaceSid, null, null, $retryattempts); }
<?php // Get the PHP helper library from twilio.com/docs/php/install require_once '/path/to/twilio-php/Services/Twilio.php'; // Loads the library // Your Account Sid and Auth Token from twilio.com/user/account $accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $authToken = "your_auth_token"; $workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; $client = new TaskRouter_Services_Twilio($accountSid, $authToken, $workspaceSid); $statistics = $client->getWorkspaceStatistics(array('Minutes' => 60)); echo $statistics->cumulative->avg_task_acceptance_time; echo $statistics->realtime->tasks_by_status->pending; echo $statistics->realtime->tasks_by_status->assigned;