1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2015 Dirk Groenen |
4
|
|
|
* |
5
|
|
|
* (c) Dirk Groenen <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace DirkGroenen\Pinterest\Endpoints; |
12
|
|
|
|
13
|
|
|
use DirkGroenen\Pinterest\Models\User; |
14
|
|
|
use DirkGroenen\Pinterest\Models\Collection; |
15
|
|
|
|
16
|
|
|
class Following extends Endpoint { |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Get the authenticated user's following users |
21
|
|
|
* |
22
|
|
|
* @access public |
23
|
|
|
* @param array $data |
24
|
|
|
* @throws Exceptions/PinterestExceptions |
25
|
|
|
* @return Collection |
26
|
|
|
*/ |
27
|
1 |
|
public function users(array $data = []) |
28
|
|
|
{ |
29
|
1 |
|
$response = $this->request->get("me/following/users/", $data); |
30
|
1 |
|
return new Collection($this->master, $response, "User"); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get the authenticated user's following boards |
35
|
|
|
* |
36
|
|
|
* @access public |
37
|
|
|
* @param array $data |
38
|
|
|
* @throws Exceptions/PinterestExceptions |
39
|
|
|
* @return Collection |
40
|
|
|
*/ |
41
|
1 |
|
public function boards(array $data = []) |
42
|
|
|
{ |
43
|
1 |
|
$response = $this->request->get("me/following/boards/", $data); |
44
|
1 |
|
return new Collection($this->master, $response, "Board"); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get the authenticated user's following interest |
49
|
|
|
* |
50
|
|
|
* @access public |
51
|
|
|
* @param array $data |
52
|
|
|
* @throws Exceptions/PinterestExceptions |
53
|
|
|
* @return Collection |
54
|
|
|
*/ |
55
|
7 |
|
public function interests(array $data = []) |
56
|
|
|
{ |
57
|
7 |
|
$response = $this->request->get("me/following/interests/", $data); |
58
|
7 |
|
return new Collection($this->master, $response, "Interest"); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Follow a user |
63
|
|
|
* |
64
|
|
|
* @access public |
65
|
|
|
* @param string $user |
66
|
|
|
* @throws Exceptions/PinterestExceptions |
67
|
|
|
* @return boolean |
68
|
|
|
*/ |
69
|
1 |
|
public function followUser($user) |
70
|
|
|
{ |
71
|
1 |
|
$this->request->post("me/following/users/", array( |
72
|
1 |
|
"user" => $user |
73
|
|
|
)); |
74
|
1 |
|
return true; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Unfollow a user |
79
|
|
|
* |
80
|
|
|
* @access public |
81
|
|
|
* @param string $user |
82
|
|
|
* @throws Exceptions/PinterestExceptions |
83
|
|
|
* @return boolean |
84
|
|
|
*/ |
85
|
1 |
|
public function unfollowUser($user) |
86
|
|
|
{ |
87
|
1 |
|
$this->request->delete(sprintf("me/following/users/%s/", $user)); |
88
|
1 |
|
return true; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Follow a board |
93
|
|
|
* |
94
|
|
|
* @access public |
95
|
|
|
* @param string $board |
96
|
|
|
* @throws Exceptions/PinterestExceptions |
97
|
|
|
* @return boolean |
98
|
|
|
*/ |
99
|
|
|
public function followBoard($board) |
100
|
|
|
{ |
101
|
|
|
$this->request->post("me/following/boards/", array( |
102
|
|
|
"board" => $board |
103
|
|
|
)); |
104
|
|
|
return true; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Unfollow a board |
109
|
|
|
* |
110
|
|
|
* @access public |
111
|
|
|
* @param string $board_id |
112
|
|
|
* @throws Exceptions/PinterestExceptions |
113
|
|
|
* @return boolean |
114
|
|
|
*/ |
115
|
2 |
|
public function unfollowBoard($board_id) |
116
|
|
|
{ |
117
|
2 |
|
$this->request->delete(sprintf("me/following/boards/%s/", $board_id)); |
118
|
2 |
|
return true; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Follow a board |
123
|
|
|
* |
124
|
|
|
* @access public |
125
|
|
|
* @param string $interest |
126
|
|
|
* @throws Exceptions/PinterestExceptions |
127
|
|
|
* @return boolean |
128
|
|
|
*/ |
129
|
|
|
public function followInterest($interest) |
130
|
|
|
{ |
131
|
|
|
$this->request->post("me/following/interests/", array( |
132
|
|
|
"interest" => $interest |
133
|
|
|
)); |
134
|
|
|
return true; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Unfollow an interest |
139
|
|
|
* |
140
|
|
|
* @access public |
141
|
|
|
* @param string $interest_id |
142
|
|
|
* @throws Exceptions/PinterestExceptions |
143
|
|
|
* @return boolean |
144
|
|
|
*/ |
145
|
|
|
public function unfollowInterest($interest_id) |
146
|
|
|
{ |
147
|
|
|
$this->request->delete(sprintf("me/following/interests/%s/", $interest_id)); |
148
|
|
|
return true; |
149
|
|
|
} |
150
|
|
|
} |