forked from freezey/php-togglSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTogglClient.php
More file actions
74 lines (68 loc) · 2.87 KB
/
Copy pathTogglClient.php
File metadata and controls
74 lines (68 loc) · 2.87 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
class TogglClient extends Toggl{
public static $fields = array(
"name", // The name of the client (string, required, unique in workspace)
"wid", // workspace ID, where the client will be used (integer, required)
"notes", // Notes for the client (string, not required)
"hrate", // The hourly rate for this client (float, not required, available only for pro workspaces)
"cur", // The name of the client's currency (string, not required, available only for pro workspaces)
"at", // timestamp that is sent in the response, indicates the time client was last updated
);
public static function createAClient(array $params = array()){
foreach ($params as $name => $param){
if (array_search($name, self::$fields) === false){
return "Invalid Parameter: $name";
}
$params["client"][$name] = $param;
unset($params[$name]);
}
$params['method'] = "POST";
$params['url'] = "https://www.toggl.com/api/v8/clients";
return self::send($params);
}
public static function updateAClient($id,array $params = array()){
if (!is_numeric($id)) {
return 'Invalid Client ID';
}
foreach ($params as $name => $param){
if (array_search($name, self::$fields) === false){
return "Invalid Parameter: $name";
}
$params["client"][$name] = $param;
unset($params[$name]);
}
$params['method'] = "PUT";
$params['url'] = "https://www.toggl.com/api/v8/clients/".(string)$id;
return self::send($params);
}
public static function getClientDetails($client_id, array $params = array()){
foreach ($params as $name => $param){
if (array_search($name, self::$fields) === false){
return "Invalid Parameter: $name";
}
}
$params['method'] = "GET";
$params['url'] = "https://www.toggl.com/api/v8/clients/$client_id";
return self::send($params);
}
public static function getClientsVisibleToUser(array $params = array()){
foreach ($params as $name => $param){
if (array_search($name, self::$fields) === false){
return "Invalid Parameter: $name";
}
}
$params['method'] = "GET";
$params['url'] = "https://www.toggl.com/api/v8/clients";
return self::send($params);
}
public static function getClientProjects($client_id, array $params = array()){
foreach ($params as $name => $param){
if (array_search($name, self::$fields) === false){
return "Invalid Parameter: $name";
}
}
$params['method'] = "GET";
$params['url'] = "https://www.toggl.com/api/v8/clients/$client_id/projects";
return self::send($params);
}
}