PHP code example of cadulis / sdk
1. Go to this page and download the library: Download cadulis/sdk 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/ */
cadulis / sdk example snippets
$autoconfigUrl = 'https://api.cadulis.com/connectors/XXX/YYYYYYYYY';
$cadulisAPI = \Cadulis\Sdk\InterventionApi::init($autoconfigUrl);
$cadulisSdkService = $cadulisAPI->services->newServiceIntervention();
$searchInput = $cadulisSdkService->newSearchInput();
$searchInput->status = \Cadulis\Sdk\Model\Intervention::STATUS_PENDING;
$result = $interventionService->search($searchInput);
echo $results->pagination->returned . " results returned\n";
foreach ($results->interventions as $intervention) {
echo "Intervention cref : " . $intervention->cref . "\n";
}
// initialize api
$autoconfigUrl = 'https://api.cadulis.com/connectors/XXX/YYYYYYYYY';
$cadulisAPI = \Cadulis\Sdk\InterventionApi::init($autoconfigUrl);
// get service
$cadulisSdkService = $cadulisAPI->services->newServiceIntervention();
// get input
$searchInput = $cadulisSdkService->newSearchInput();
$searchInput->status = \Cadulis\Sdk\Model\Intervention::STATUS_PENDING;
// call method
$result = $cadulisSdkService->search($searchInput);
// process results
echo $results->pagination->returned . " results returned\n";
foreach ($results->interventions as $intervention) {
echo "Intervention cref : " . $intervention->cref . "\n";
}
$intervention = $cadulisAPI->models->newModelIntervention();
$intervention->cref = 'myCustomInterventionReference';
$result = $interventionService->read($intervention);
$intervention->customer = $cadulisAPI->models->newModelCustomer();
$intervention->customer->type = \Cadulis\Sdk\Model\Customer::CUSTOMER_TYPE_COMPANY;
$intervention->customer->reference = 'customerReference';
$result = $interventionService->create($intervention);
$result = $interventionService->update($intervention);
$interventionTypeService = $cadulisAPI->services->newServiceInterventionType();
$result = $interventionTypeService->getAvailable();
$scheduleWizardService = $cadulisAPI->services->newServiceScheduleWizard();
$scheduleWizardInput = $scheduleWizardService->newWizardInput();
$scheduleWizardInput->address = '7 rue de la Dordogne Toulouse';
$result = $scheduleWizardService->getSlots($scheduleWizardInput);
echo count($result) . ' dates returned' . "\n";
echo 'best slot : ';
$bestSlot = $result->getBestSlot();
if ($bestSlot === null) {
echo "No slot available";
} else {
echo "Best slot : " . $bestSlot->date;
}
$scheduleWizardInput->address
$scheduleWizardInput->date_min // ISO 8601 format, can be set by $intervention->setDateMin($date)
$scheduleWizardInput->date_max // ISO 8601 format, can be set by $intervention->setDateMax($date)
class MyLogger implements \Bixev\LightLogger\LoggerInterface
{
public function log($log)
{
print_r($log);
}
}
$logger = new MyLogger;
$cadulisAPI = \Cadulis\Sdk\InterventionApi::init($autoconfigUrl, $logger);
$client = $cadulisAPI->getClient();
$routes = $client->getRoutes();
$route = new \Cadulis\Sdk\Model\Routes\Route;
$route->identifier = \Cadulis\Sdk\Model\Routes\Route::IDENTIFIER_INTERVENTION_LIST;
$route->method = \Cadulis\Sdk\Client\Curl::METHOD_GET;
$route->url = 'http://mycutomdomain/mycutomroute';
$routes[] = $route;
$intervention->cref // unique identifier
$intervention->reference
$intervention->address
$intervention->address_additional
$intervention->comment
$intervention->duration // seconds
$intervention->scheduled_start_at // ISO 8601 format, can be set by $intervention->setScheduledStart($date)
$intervention->custom_fields // associative array of $key => $value additional fields
$customer->reference
$customer->type
$customer->name
$customer->address
$customer->address_additional
$customer->phone
$customer->mobile
$customer->email
$customer->comment