1 | <?php |
||
9 | class Pins extends Provider |
||
10 | { |
||
11 | use Searchable; |
||
12 | |||
13 | protected $loginRequired = [ |
||
14 | 'like', |
||
15 | 'unLike', |
||
16 | 'comment', |
||
17 | 'deleteComment', |
||
18 | 'create', |
||
19 | 'repin', |
||
20 | 'delete', |
||
21 | ]; |
||
22 | |||
23 | /** |
||
24 | * Likes pin with current ID. |
||
25 | * |
||
26 | * @param int $pinId |
||
27 | * |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function like($pinId) |
||
34 | |||
35 | /** |
||
36 | * Removes your like from pin with current ID. |
||
37 | * |
||
38 | * @param int $pinId |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | public function unLike($pinId) |
||
46 | |||
47 | /** |
||
48 | * Calls Pinterest API to like or unlike Pin by ID. |
||
49 | * |
||
50 | * @param int $pinId |
||
51 | * @param string $resourceUrl |
||
52 | * |
||
53 | * @return bool |
||
54 | */ |
||
55 | protected function likePinMethodCall($pinId, $resourceUrl) |
||
56 | { |
||
57 | return $this->callPostRequest(['pin_id' => $pinId], $resourceUrl); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Write a comment for a pin with current id. |
||
62 | * |
||
63 | * @param int $pinId |
||
64 | * @param string $text Comment |
||
65 | * |
||
66 | * @return array|bool |
||
67 | */ |
||
68 | public function comment($pinId, $text) |
||
69 | { |
||
70 | $requestOptions = ['pin_id' => $pinId, 'test' => $text]; |
||
71 | |||
72 | return $this->callPostRequest($requestOptions, UrlHelper::RESOURCE_COMMENT_PIN, true); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Delete a comment for a pin with current id. |
||
77 | * |
||
78 | * @param int $pinId |
||
79 | * @param int $commentId |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | public function deleteComment($pinId, $commentId) |
||
84 | { |
||
85 | $requestOptions = ['pin_id' => $pinId, 'comment_id' => $commentId]; |
||
86 | |||
87 | return $this->callPostRequest($requestOptions, UrlHelper::RESOURCE_COMMENT_DELETE_PIN); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Create a pin. Returns created pin ID. |
||
92 | * |
||
93 | * @param string $imageUrl |
||
94 | * @param int $boardId |
||
95 | * @param string $description |
||
96 | * @param string $link |
||
97 | * |
||
98 | * @return bool|int |
||
99 | */ |
||
100 | public function create($imageUrl, $boardId, $description = '', $link = '') |
||
101 | { |
||
102 | $requestOptions = [ |
||
103 | 'method' => 'scraped', |
||
104 | 'description' => $description, |
||
105 | 'link' => empty($link) ? $imageUrl : $link, |
||
106 | 'image_url' => $imageUrl, |
||
107 | 'board_id' => $boardId, |
||
108 | ]; |
||
109 | |||
110 | return $this->callPostRequest($requestOptions, UrlHelper::RESOURCE_CREATE_PIN, true); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Edit pin by ID. You can move pin to a new board by setting this board id. |
||
115 | * |
||
116 | * @param int $pindId |
||
117 | * @param string $description |
||
118 | * @param string $link |
||
119 | * @param int|null $boardId |
||
120 | * @return mixed |
||
121 | */ |
||
122 | public function edit($pindId, $description = '', $link = '', $boardId = null) |
||
133 | |||
134 | /** |
||
135 | * Moves pin to a new board |
||
136 | * |
||
137 | * @param int $pindId |
||
138 | * @param int $boardId |
||
139 | * @return mixed |
||
140 | */ |
||
141 | public function moveToBoard($pindId, $boardId) |
||
145 | |||
146 | /** |
||
147 | * Make a repin. |
||
148 | * |
||
149 | * @param int $repinId |
||
150 | * @param int $boardId |
||
151 | * @param string $description |
||
152 | * |
||
153 | * @return bool|int |
||
154 | */ |
||
155 | public function repin($repinId, $boardId, $description = '') |
||
167 | |||
168 | /** |
||
169 | * Delete a pin. |
||
170 | * |
||
171 | * @param int $pinId |
||
172 | * |
||
173 | * @return bool |
||
174 | */ |
||
175 | public function delete($pinId) |
||
179 | |||
180 | /** |
||
181 | * Get information of a pin by PinID. |
||
182 | * |
||
183 | * @param int $pinId |
||
184 | * |
||
185 | * @return array|bool |
||
186 | */ |
||
187 | public function info($pinId) |
||
202 | |||
203 | /** |
||
204 | * @return string |
||
205 | */ |
||
206 | protected function getScope() |
||
210 | } |
||
211 |