-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTogglProject.php
50 lines (46 loc) · 2.22 KB
/
TogglProject.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
<?php
class TogglProject extends Toggl{
public static $fields = array(
"name", // The name of the project (string, required, unique for client and workspace)
"wid", // workspace ID, where the project will be saved (integer, required)
"cid", // client ID(integer, not required)
"active", // whether the project is archived or not (boolean, by default true)
"is_private", // whether project is accessible for only project users or for all workspace users (boolean, default true)
"template", // whether the project can be used as a template (boolean, not required)
"template_id", // id of the template project used on current project's creation
"billable", // whether the project is billable or not (boolean, default true, available only for pro workspaces)
"at", // timestamp that is sent in the response for PUT, indicates the time task was last updated
);
public static function createProject(array $params = array()){
foreach ($params as $name => $param){
if (array_search($name, self::$fields) === false){
return "Invalid Parameter: $name";
}
$params["project"][$name] = $param;
unset($params[$name]);
}
$params['method'] = "POST";
$params['url'] = "https://www.toggl.com/api/v8/projects";
return self::send($params);
}
public static function getProjectData($project_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/projects/$project_id";
return self::send($params);
}
public static function getProjectUsers($project_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/projects/$project_id/project_users";
return self::send($params);
}
}