1. Go to this page and download the library: Download anteris-dev/autotask-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/ */
anteris-dev / autotask-client example snippets
$client = new Anteris\Autotask\Client($apiUser, $apiSecret, $integrationCode, $baseUrl);
$client->contacts();
// Note that we are using the HttpClient, not the wrapper Client.
$client = new Anteris\Autotask\HttpClient($apiUser, $apiSecret, $integrationCode, $baseUrl);
$contactEndpoint = new Anteris\Autotask\API\Contacts\ContactService($client);
$ticketEndpoint = new Anteris\Autotask\API\Tickets\TicketService($client);
$contact = new Anteris\Autotask\API\Contacts\ContactEntity([
'id' => 0, // Autotask 1,
]);
// This sends the create request
$client->contacts()->create( $contact );
$client->contacts()->deleteById(1);
// Looks finds a contact with the ID of 1.
// Alternatively use $contactEndpoint->findById(1);
$contact = $client->contacts()->findById(1);
// This returns an object with all the properties of a contact
echo $contact->firstName;
// Basic Comparison
$client->contacts()->query()->where('firstName', 'eq', 'Foo');
// Make sure the field exists
$client->contacts()->query()->where('emailAddress', 'exist'); // OR notexist
// Make a sub-query (these are grouped with the AND conjunction by default)
// This query means: firstName equals Foo AND emailAddress exists
$client->contacts()->query()->where(function ($q) {
return $q->where('firstName', 'eq', 'Foo')
->where('emailAddress', 'exist');
});
// Make a sub-query (these are grouped with the OR conjunction by default)
// This query means: firstName equals Foo OR emailAddress exists
$client->contacts()->query()->orWhere(function ($q) {
return $q->where('firstName', 'eq', 'Foo')
->where('emailAddress', 'exist');
});
$client->contacts()->query()->records(20);
// This returns an integer specifying how many records will be returned
$result = $client->contacts()->query()->where('firstName', 'contains', 'Foo')->count();
if ($result > 0) {
echo 'Records exist!';
}
// Let's get the first page
$page = $client->contacts()->query()->where('firstName', 'exist')->paginate();
// We are going to do this until we run out of pages
while(true) {
// For every contact, print their name and a new line
foreach ($page->collection as $contact) {
echo $contact->firstName . PHP_EOL;
}
// If a next page doesn't exist, stop the loop
if(! $page->hasNextPage() ) {
break;
}
// Otherwise retrieve the next page and do it again!
$page = $page->nextPage();
}
use Anteris\Autotask\API\Contacts\ContactEntity;
$query = $client->contacts()->query()->where('id', 'exist');
// Get all the contacts from Autotask and echo their name
$query->loop(function (ContactEntity $contact) {
echo $contact->firstName . PHP_EOL;
});