-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
59 lines (48 loc) · 1.56 KB
/
example.php
File metadata and controls
59 lines (48 loc) · 1.56 KB
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
<?php
require_once __DIR__.'/vendor/autoload.php';
use Timatic\TimaticConnector;
// Initialize the Timatic SDK
$timatic = new TimaticConnector;
// Example 1: Get all users
echo "Fetching users...\n";
$response = $timatic->user()->getUsers();
if ($response->successful()) {
$users = $response->json();
echo 'Found '.count($users['data'] ?? [])." users\n\n";
}
// Example 2: Get all customers
echo "Fetching customers...\n";
$response = $timatic->customer()->getCustomers();
if ($response->successful()) {
$customers = $response->json();
echo 'Found '.count($customers['data'] ?? [])." customers\n\n";
}
// Example 3: Get budgets
echo "Fetching budgets...\n";
$response = $timatic->budget()->getBudgets();
if ($response->successful()) {
$budgets = $response->json();
echo 'Found '.count($budgets['data'] ?? [])." budgets\n\n";
}
// Example 4: Get current user info
echo "Fetching current user info...\n";
$response = $timatic->me()->getMes();
if ($response->successful()) {
$me = $response->json();
echo 'Current user: '.($me['data']['name'] ?? 'Unknown')."\n\n";
}
// Example 5: Create a new entry (commented out to prevent accidental execution)
echo "Creating a new entry...\n";
$response = $timatic->entry()->postEntries(new \Timatic\Dto\Entry([
'user_id' => 1,
'customer_id' => 1,
'date' => date('Y-m-d'),
'hours' => 2.5,
'description' => 'Working on SDK integration',
]));
if ($response->successful()) {
echo "Entry created successfully!\n";
$entry = $response->json();
var_dump($entry);
}
echo "Examples completed!\n";