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 Users extends Endpoint { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Get the current user |
20
|
|
|
* |
21
|
|
|
* @access public |
22
|
|
|
* @param array $data |
23
|
|
|
* @throws Exceptions/PinterestExceptions |
24
|
|
|
* @return User |
25
|
|
|
*/ |
26
|
1 |
|
public function me(array $data = []) |
27
|
|
|
{ |
28
|
1 |
|
$response = $this->request->get("me/", $data); |
29
|
1 |
|
return new User($this->master, $response); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Get the provided user |
34
|
|
|
* |
35
|
|
|
* @access public |
36
|
|
|
* @param string $username |
37
|
|
|
* @param array $data |
38
|
|
|
* @throws Exceptions/PinterestExceptions |
39
|
|
|
* @return User |
40
|
|
|
*/ |
41
|
2 |
|
public function find($username, array $data = []) |
42
|
|
|
{ |
43
|
2 |
|
$response = $this->request->get(sprintf("users/%s/", $username), $data); |
44
|
1 |
|
return new User($this->master, $response); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get the authenticated user's pins |
49
|
|
|
* |
50
|
|
|
* @access public |
51
|
|
|
* @param array $data |
52
|
|
|
* @throws Exceptions/PinterestExceptions |
53
|
|
|
* @return Collection |
54
|
|
|
*/ |
55
|
2 |
|
public function getMePins(array $data = []) |
56
|
|
|
{ |
57
|
2 |
|
$response = $this->request->get("me/pins/", $data); |
58
|
2 |
|
return new Collection($this->master, $response, "Pin"); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Search in the user's pins |
63
|
|
|
* |
64
|
|
|
* @param string $query |
65
|
|
|
* @param array $data |
66
|
|
|
* @throws Exceptions/PinterestExceptions |
67
|
|
|
* @return Collection |
68
|
|
|
*/ |
69
|
1 |
|
public function searchMePins($query, array $data = []) |
70
|
|
|
{ |
71
|
1 |
|
$data["query"] = $query; |
72
|
1 |
|
$response = $this->request->get("me/search/pins/", $data); |
73
|
1 |
|
return new Collection($this->master, $response, "Pin"); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Search in the user's boards |
78
|
|
|
* |
79
|
|
|
* @param string $query |
80
|
|
|
* @param array $data |
81
|
|
|
* @throws Exceptions/PinterestExceptions |
82
|
|
|
* @return Collection |
83
|
|
|
*/ |
84
|
1 |
|
public function searchMeBoards($query, array $data = []) |
85
|
|
|
{ |
86
|
1 |
|
$data["query"] = $query; |
87
|
|
|
|
88
|
1 |
|
$response = $this->request->get("me/search/boards/", $data); |
89
|
1 |
|
return new Collection($this->master, $response, "Board"); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Get the authenticated user's boards |
94
|
|
|
* |
95
|
|
|
* @access public |
96
|
|
|
* @param array $data |
97
|
|
|
* @throws Exceptions/PinterestExceptions |
98
|
|
|
* @return Collection |
99
|
|
|
*/ |
100
|
1 |
|
public function getMeBoards(array $data = []) |
101
|
|
|
{ |
102
|
1 |
|
$response = $this->request->get("me/boards/", $data); |
103
|
1 |
|
return new Collection($this->master, $response, "Board"); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Get the authenticated user's likes |
108
|
|
|
* |
109
|
|
|
* @access public |
110
|
|
|
* @param array $data |
111
|
|
|
* @throws Exceptions/PinterestExceptions |
112
|
|
|
* @return Collection |
113
|
|
|
*/ |
114
|
1 |
|
public function getMeLikes(array $data = []) |
115
|
|
|
{ |
116
|
1 |
|
$response = $this->request->get("me/likes/", $data); |
117
|
1 |
|
return new Collection($this->master, $response, "Pin"); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get the authenticated user's followers |
122
|
|
|
* |
123
|
|
|
* @access public |
124
|
|
|
* @param array $data |
125
|
|
|
* @throws Exceptions\PinterestException |
126
|
|
|
* @return Collection |
127
|
|
|
*/ |
128
|
1 |
|
public function getMeFollowers(array $data = []) |
129
|
|
|
{ |
130
|
1 |
|
$response = $this->request->get("me/followers/", $data); |
131
|
1 |
|
return new Collection($this->master, $response, "User"); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
} |
135
|
|
|
|