forked from loduis/teamwork.com-project-management
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Link.php
98 lines (93 loc) · 2.77 KB
/
Link.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
namespace TeamWorkPm;
class Link extends Model
{
protected function init()
{
$this->fields = array(
// {link name}
'name' =>true,
// {link display code: Embed code, Iframe code, URL}
'code' => true,
// {link description}
'description' =>false,
// {1|0}
'private' =>array(
'required'=> false,
'type'=>'integer',
'validate'=> array(0, 1)
),
// {width of window in Teamwork (integer)}
'width' => array(
'required'=> false,
'type'=>'integer'
),
// {height of window in Teamwork (integer)}
'height' => array(
'required'=> false,
'type'=>'integer'
),
// {link category id}
'category_id' => array(
'required'=> false,
'type'=>'integer'
),
// {New link category name. category-id must be passed as 0}
'category_name' => false,
// {Comma separated list of users to notify OR (YES|NO|ALL)}
'notify' => false,
// {Force link to open in new window (boolean)}
'open_in_new_window' => array(
'required'=> false,
'type'=>'boolean'
)
);
}
/**
* List All Links
* GET /links
* Lists all links on projects that the authenticated user is associated with.
*
*/
public function getAll()
{
return $this->rest->get($this->action);
}
/**
* List Links on a Project
*
* GET /projects/#{project_id}/links
*
* This lets you query the list of links for a project.
*
* @param int $id This is a project id
*
* @return TeamWorkPm\Response\Model
*/
public function getByProject($project_id)
{
$project_id = (int) $project_id;
if ($project_id <= 0) {
throw new \TeamWorkPm\Exception('Invalid param project_id');
}
return $this->rest->get("/projects/$project_id/$this->action");
}
/**
* Create a Single Link
*
* POST /projects/#{project_id}/links
* This command will create a single link.
* Code must be valid Embed Code, IFrame Code or a URL
* @param array $data
*
* @return int
*/
public function insert(array $data)
{
$project_id = empty($data['project_id']) ? 0: (int) $data['project_id'];
if ($project_id <= 0) {
throw new Exception('Required field project_id');
}
return $this->rest->post("projects/$project_id/$this->action", $data);
}
}