PHP code example of bartlomiejbeta / lead-desk-api-client-lib

1. Go to this page and download the library: Download bartlomiejbeta/lead-desk-api-client-lib 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/ */

    

bartlomiejbeta / lead-desk-api-client-lib example snippets


$clientCredentials = new ClientCredentials($token);
$httpsClient       = HttpClientDiscovery::find();
$msg               = MessageFactoryDiscovery::find();
$stream            = StreamFactoryDiscovery::find();

$apiClient = new ApiClient($httpsClient, $clientCredentials, $msg, $stream);

/** apiClient can be used to send any lead desk api request. $request must be instace of Psr RequestInterface*/
$apiClient->sendRequest($request);

/** but also you can use some already implemented lead desk endpoints by using this */
$leadDeskApi = new LeadDeskApiClient($apiClient);

/** contact exists -> refere to lead desk api documentation */
$contactFilter       = new ContactFilter($phone, $listId);
$existRepresentation = $leadDeskApi->contactExists($contactFilter);// @see ExistsRepresentation

/** find contact -> refere to lead desk api documentation */
$contactFilter      = new ContactFilter($phone, $listId);
$findRepresentation = $leadDeskApi->findContact($contactFilter);// @see FindRepresentation

/** get contact -> refere to lead desk api documentation */
$contactIdFilter   = new ContactIdFilter($contactId);
$getRepresentation = $leadDeskApi->getContact($contactIdFilter);// @see GetRepresentation

/** delete contact -> refere to lead desk api documentation */
$contactIdFilter     = new ContactIdFilter($contactId);
$existRepresentation = $leadDeskApi->deleteContact($contactFilter);// @see ExistsRepresentation

/** create contact -> refere to lead desk api documentation */
$contactRepresentation = (new ContactRepresentation())
				->setPhone($phone)
				...;
							
$createRepresentation   = $leadDeskApi->createContact($contactRepresentation);// @see CreateRepresentation