PHP code example of pipelinersales / pipeliner-api-client

1. Go to this page and download the library: Download pipelinersales/pipeliner-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pipelinersales / pipeliner-api-client example snippets


use PipelinerSales\ApiClient\PipelinerClient;

$url        = 'https://eu.pipelinersales.com';
$pipelineId = 'eu_myPipeline';
$token      = 'api token';
$password   = 'api password';

$pipeliner = PipelinerClient::create($url, $pipelineId, $token, $password);

try {
    // load all accounts (up to a maximum of 25)
    $pipeliner->accounts->get();

    // load a specified account by id
    $pipeliner->accounts->getById('ID-219034053254');

}catch (PipelinerHttpException $e) {
    // something went wrong
}

// load up to 10 accounts and sort them by the organization name
$pipeliner->accounts->get(array('limit' => 10, 'sort' => 'ORGANIZATION'));

// load up to 5 accounts which were modified in the last week
$criteria = new Criteria();
$criteria->limit(5)->after(new DateTime('-7 days midnight'));
$pipeliner->accounts->get($criteria);

// load accounts whose organization name contains the string 'co'
$pipeliner->accounts->get(Filter::contains('ORGANIZATION', 'co'));

// load up to 10 accounts whose name starts with the letter A ordered by name in an ascending order
$pipeliner->accounts->get(
    Criteria::limit(10)->filter(Filter::startsWith('A'))->sort('NAME')
);

$account = $pipeliner->accounts->getById('ID-219034053254');
echo $account->getOrganization() . "\n";
echo $account->getEmail1() . "\n";

$account->setPhone1('+100000000000')
        ->setOwnerId(1534);

$account = $pipeliner->accounts->getById('ID-219034053254');
$account->setEmail1('[email protected]')
        ->setPhone1('+100000000');
$pipeliner->accounts->save($account);

$salesUnit = $pipeliner->salesUnits->create();
$salesUnit->setSalesUnitName('Aq');
$pipeliner->salesUnits->save($salesUnit);

$response = $pipeliner->salesUnits->save(
    array( 'SALES_UNIT_NAME' => 'Aq' )
);

$pipeliner->salesUnits->deleteById('ID-219034053254');

$account = $pipeliner->accounts->getById('ID-342534523462');
$pipeliner->accounts->delete($account);

$pipeliner->accounts->deleteById(
    array('ID-219034053254', 'ID-3456134218434', 'ID-0186703160934')
);

$collection = $pipeliner->accounts->get();

// entity collections can be accessed like arrays
$firstAccount = $collection[0];

foreach ($collection as $account) {
    // do something with each account
}

$accounts = $pipeliner->accounts->get();

// this is allowed
$accounts[0]->setEmail1('[email protected]');

// this throws an exception
$accounts[0] = $pipeliner->accounts->getById('ID-3452134134');

// default limit 25 items
$accounts = $client->accounts->get();

$accountIterator = $client->accounts->getEntireRangeIterator($accounts);

$emails = array();
// this will iterate over ALL of the results (even beyond the 25)
foreach ($accountIterator as $account) {
    $emails[] = $account->getEmail1();

    if (!$accountIterator->nextDataAvailable() and !$accountIterator->atEnd()) {
        // next iteration will issue a HTTP request
    }
}

try {
    $account = $pipeliner->accounts->create();
    
    // mandatory fields in the account are empty, so the server will refuse to save it
    $pipeliner->accounts->save($account);
}catch (PipelinerHttpException $e) {
    echo $e->getErrorMessage();
}