-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
81 lines (53 loc) · 2.45 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
// ASSUMING COMPOSER AUTOLOADING IS USED HERE
// (no need to require anything by hand)
// API INIT
$autoconfigUrl = 'https://api.intervention.bixev.com/connectors/XXX/YYYYYYYYY';
$bixevInterventionAPI = \Bixev\InterventionSdk\InterventionApi::init($autoconfigUrl);
// SEARCH INTERVENTIONS
// get service
$interventionService = $bixevInterventionAPI->services->newServiceIntervention();
// get input
$searchInput = $interventionService->newSearchInput();
$searchInput->status = \Bixev\InterventionSdk\Model\Intervention::STATUS_PENDING;
// call method
$result = $interventionService->search($searchInput);
// process results
echo $results->pagination->returned . " results returned\n";
foreach ($results->interventions as $intervention) {
echo "Intervention cref : " . $intervention->cref . "\n";
}
// CREATE INTERVENTION
$intervention = $bixevInterventionAPI->models->newModelIntervention();
$intervention->cref = 'myNewCustomInterventionReference';
$intervention->address = 'Toulouse';
$intervention->customer = $bixevInterventionAPI->models->newModelCustomer();
$intervention->customer->type = \Bixev\InterventionSdk\Model\Customer::CUSTOMER_TYPE_COMPANY;
$intervention->customer->name = 'my best customer';
$intervention->customer->reference = 'customerReference';
$result = $interventionService->create($intervention);
// UPDATE INTERVENTION
$intervention = $bixevInterventionAPI->models->newModelIntervention();
$intervention->cref = 'myNewCustomInterventionReference';
$intervention->address = 'Paris';
$result = $interventionService->update($intervention);
// GET INTERVENTION
$intervention = $bixevInterventionAPI->models->newModelIntervention();
$intervention->cref = 'myCustomInterventionReference';
$result = $interventionService->read($intervention);
// GET AVAILABLE INTERVENTION TYPES
$interventionTypeService = $bixevInterventionAPI->services->newServiceInterventionType();
$result = $interventionTypeService->getAvailable();
// GET AVAILABLE ASSIGNMENT SLOTS
$scheduleWizardService = $bixevInterventionAPI->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;
}