-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.php
83 lines (63 loc) · 1.74 KB
/
client_test.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
82
83
<?php
/**
* HarvestappTimeExporter
*
* client_test.php created at ..
*
* Date: 20.11.13
* Time: 17:51
*
* .. with love by ..
*
* User: Marco Moscher
*
* MIT Licence
*/
require_once( "./lib/MyHarvest.php");
$api = new MyHarvest();
//query all clients
$clientResult = $api->getClients();
if( $clientResult->isSuccess() ) {
//print clients
foreach( $clientResult->data as $client ) {
echo "Client: " . $client->name . "<br/>";
echo "<pre>";
print_r($client);
echo "</pre>";
echo "<hr>";
//fetch project datat
$projects = $api->getClientProjects( $client->id );
//echo "<pre>";
// print_r($projects);
// echo "</pre>";
$projectsTimes = array();
$timerange = new Harvest_Range( date('Ym01'), date('Ymd') );
var_dump( $timerange );
foreach( $projects->data as $project ) {
$tmpProjectData = array();
$tmpProjectData["name"] = $project->name;
$tmpProjectData["id"] = $project->id;
$tmpProjectData["tracks"] = array();
$entries = $api->getProjectEntries( $project->id, $timerange );
// echo $entries->code;
//var_dump($entries);
//break;
if( $entries->isSuccess() ) {
foreach( $entries->data as $projectTimetrack ) {
$tmpProjectData["tracks"][] = $projectTimetrack;
}
}else{
echo "failure";
}
$projectsTimes[] = (object)$tmpProjectData;
//break;
}
echo "<pre>";
print_r($projectsTimes);
echo "</pre>";
break;
}
}else{
echo "something went wrong <br/>";
}
?>