public function testProfileArray()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $data = json_decode(self::JSON_DATA, true);
     $response = $client->updateByProfileId(self::PROFILE_ID, $data, self::PLATFORM_ACCOUNT_ID);
     $this->assertEquals($response, null);
 }
 public function testCreatePlatformAccount()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $data = json_decode(self::DATA);
     $result = $client->createPlatformAccount($data);
     $this->assertEquals($result, self::RESPONSE_STR);
 }
 public function testUpdatePlatformAccount()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $data = json_decode(self::DATA);
     $result = $client->updatePlatformAccount(self::PLATFORM_ACCOUNT_ID, $data);
     $this->assertEquals($result, self::RESPONSE_STR);
 }
 public function testGetByNameAddress()
 {
     $nameAddressData = array('first_name' => 'Jerry', 'last_name' => 'Seinfeld', 'address' => '129 West 81st Street', 'city' => 'New York', 'state' => 'NY', 'zip_code' => '10024');
     $client = new NextCallerPlatformClient(null, null, true);
     $profiles = $client->getByNameAddress($nameAddressData, self::PLATFORM_ACCOUNT_ID);
     $this->assertEquals($profiles, json_decode(self::JSON_RESPONSE, true));
 }
 public static function setUpBeforeClass()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $mocker = new \Guzzle\Plugin\Mock\MockPlugin();
     $mocker->addResponse(new \Guzzle\Http\Message\Response(200, array(), self::JSON_RESPONSE));
     $client->addSubscriber($mocker);
     self::$client = $client;
     self::$mock = $mocker;
 }
 public function testGetPlatformAccount()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $data = $client->getPlatformAccount(self::PLATFORM_ACCOUNT_ID);
     $this->assertTrue(!empty($data));
 }
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$sandbox = true;
$data = array('email' => 'xxx', 'id' => 'user1');
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $client->createPlatformAccount($data);
} catch (\NextCaller\Exception\RateLimitException $e) {
    var_dump($e->getRateLimit());
    var_dump($e->getResetTime());
} catch (\NextCaller\Exception\BadResponseException $e) {
    // Example
    // 422
    var_dump($e->getCode());
    // Validation Error
    var_dump($e->getMessage());
    /*
     array(
        'message' => 'Validation Error',
        'code' => '422',
        'type' => 'Unprocessable Entity',
        'description' => array(
            'email' => array('Invalid email address')
        )
    );
    */
    var_dump($e->getError());
 public function testGetFraudLevel()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $profile = $client->getFraudLevel(self::PROFILE_PHONE, self::PLATFORM_ACCOUNT_ID);
     $this->assertEquals($profile, json_decode(self::JSON_RESPONSE, true));
 }
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$nameAddressData = array('first_name' => 'Jerry', 'last_name' => 'Seinfeld', 'address' => '129 West 81st Street', 'city' => 'New York', 'state' => 'NY', 'zip_code' => '10024');
$platformUsername = '******';
$sandbox = false;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $records = $client->getProfileByNameAndAddress($nameAddressData, $platformUsername);
    /* array(
            'id' => '97d949a413f4ea8b85e9586e1f2d9a',
            'first_name' => 'Jerry',
            'middle_name' => 'Allen',
            'last_name' => 'Seinfeld',
            'name' => 'Jerry Allen Seinfeld',
            'language' => 'English',
            'phone' => array(
                array(
                    'number' => '2125558383',
                    'resource_uri' => '/v2/records/2125558383/',
                )
            ),
            'carrier' => 'Verizon Wireless',
            'line_type' => 'Mobile',
            'address' => array(
                array(
                    'city' => 'New York',
                    'extended_zip' => '2344',
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$id = "c7c17736128033c92771b7f33fead7";
$phone = '6925558386';
$accountId = 'user1';
$sandbox = true;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $fraudLevel = $client->getFraudLevel($phone, $accountId);
    /*
    array(
        'spoofed' => 'unknown',
        'fraud_risk' => 'medium'
    );
    */
    var_dump($fraudLevel);
} catch (\NextCaller\Exception\RateLimitException $e) {
    var_dump($e->getRateLimit());
    var_dump($e->getResetTime());
} catch (\NextCaller\Exception\BadResponseException $e) {
    // Example
    // 555
    var_dump($e->getCode());
    // The number you have entered is invalid. Please ensure your number contains 10 digits.
    var_dump($e->getMessage());
    /* array(
     *      "message" => "The number you have entered is invalid. Please ensure your number contains 10 digits.",
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$accountId = 'user1';
$sandbox = true;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $platformUser = $client->getPlatformAccount($accountId);
    /*
    array(
        'username' => 'user1',
        'first_name' => 'user1_fname',
        'last_name' => 'user1_lname',
        'company_name' => 'company1_name',
        'email' => '*****@*****.**',
        'number_of_operations' => '15',
        'total_operations' => array('2014 - 11' => '15'),
        'billed_operations' => array('2014 - 11' => '15'),
        'resource_uri' => '/v2/platform_users/user1/'
    );
    */
    var_dump($platformUser);
} catch (\NextCaller\Exception\RateLimitException $e) {
    var_dump($e->getRateLimit());
    var_dump($e->getResetTime());
} catch (\NextCaller\Exception\BadResponseException $e) {
    // Example
    // 558
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$nameAddressData = array('first_name' => 'Jerry', 'last_name' => 'Seinfeld', 'address' => '129 West 81st Street', 'city' => 'New York', 'state' => 'NY', 'zip_code' => '10024');
$accountId = 'user1';
$sandbox = false;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $records = $client->getByNameAddress($nameAddressData, $accountId);
    /* array(
            'id' => '97d949a413f4ea8b85e9586e1f2d9a',
            'first_name' => 'Jerry',
            'middle_name' => 'Allen',
            'last_name' => 'Seinfeld',
            'name' => 'Jerry Allen Seinfeld',
            'language' => 'English',
            'phone' => array(
                array(
                    'number' => '2125558383',
                    'resource_uri' => '/v2/records/2125558383/',
                )
            ),
            'carrier' => 'Verizon Wireless',
            'line_type' => 'Mobile',
            'address' => array(
                array(
                    'city' => 'New York',
                    'extended_zip' => '2344',
 public function testProfileJson()
 {
     $client = new NextCallerPlatformClient(null, null, true);
     $client->getPlatformStatistics();
     $this->assertTrue(true);
 }
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$sandbox = true;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $statistic = $client->getPlatformStatistics();
    /*
    array(
        array(
            array
            (
                'id' => 'user1',
                'first_name' => 'user1_fname',
                'last_name' => 'user1_lname',
                'company_name' => 'company1_name',
                'email' => '*****@*****.**',
                'number_of_operations' => '15',
                'total_operations' => array('2014-11' => '15'),
                'billed_operations' => array('2014-11' => '15'),
                'resource_uri' => '/v2/platform_users/user1/',
            ),
            array(
                'id' => 'user2',
                'first_name' => '',
                'last_name' => '',
                'company_name' => '',
                'email' => '',
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$accountId = 'user1';
$sandbox = true;
$data = array('email' => 'xxx');
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $client->updatePlatformAccount($accountId, $data);
} catch (\NextCaller\Exception\RateLimitException $e) {
    var_dump($e->getRateLimit());
    var_dump($e->getResetTime());
} catch (\NextCaller\Exception\BadResponseException $e) {
    // Example
    // 422
    var_dump($e->getCode());
    // Validation Error
    var_dump($e->getMessage());
    /*
     array(
        'message' => 'Validation Error',
        'code' => '422',
        'type' => 'Unprocessable Entity',
        'description' => array(
            'email' => array('Invalid email address')
        )
    );
    */
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$phoneNumber = "6925558386";
$accountId = 'user1';
$sandbox = true;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $records = $client->getByPhone($phoneNumber, $accountId);
    /*
    array(
        'records' => array(
            array(
                'id' => 'e79ba4dab9cdd3da41c95ef734ec5b',
                'first_name' => 'Miguel',
                'middle_name' => '',
                'last_name' => 'Meneses',
                'name' => 'Miguel Meneses',
                'language' => 'English',
                'phone' => array(
                    array(
                        'number' => '6925558386',
                        'resource_uri' => '/v2/records/6925558386/'
                    )
                ),
                'carrier' => 'AT & T',
                'address' => array(
                    array(
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$id = 'e79ba4dab9cdd3da41c95efd734ec5b';
$accountId = 'user1';
$sandbox = true;
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $profile = $client->getByProfileId($id, $accountId);
    /*
    array(
        'id' => 'e79ba4dab9cdd3da41c95ef734ec5b',
        'first_name' => 'Miguel',
        'middle_name' => '',
        'last_name' => 'Meneses',
        'name' => 'Miguel Meneses',
        'language' => 'English',
        'phone' => array(
            array(
                'number' => '6925558386',
                'resource_uri' => '/v2/records/6925558386/',
            )
        ),
    
        'carrier' => 'AT & T',
        'address' => array(
            array(
                'city' => 'Winnetka',
<?php

require __DIR__ . '/vendor/autoload.php';
use NextCaller\NextCallerPlatformClient;
$user = "";
$password = "";
$id = "c7c17736128033c92771b7f33fead7";
$sandbox = true;
$data = array("email" => 'xxx');
$accountId = 'user1';
$client = new NextCallerPlatformClient($user, $password, $sandbox);
try {
    $client->updateByProfileId($id, $data, $accountId);
} catch (\NextCaller\Exception\RateLimitException $e) {
    var_dump($e->getRateLimit());
    var_dump($e->getResetTime());
} catch (\NextCaller\Exception\BadResponseException $e) {
    // Example
    // 422
    var_dump($e->getCode());
    // Validation Error
    var_dump($e->getMessage());
    /*
     array(
        'message' => 'Validation Error',
        'code' => '422',
        'type' => 'Unprocessable Entity',
        'description' => array(
            'email' => array('Invalid email address')
        )
    );