1 | <?php |
||
7 | trait CanBeShared |
||
8 | { |
||
9 | use HandlesRequest, ResolvesCurrentUser; |
||
10 | |||
11 | /** |
||
12 | * @return array |
||
13 | */ |
||
14 | protected function requiresLoginForCanBeShared() |
||
22 | |||
23 | /** |
||
24 | * @param int $pinId |
||
25 | * @return string |
||
26 | */ |
||
27 | public function shareViaTwitter($pinId) |
||
31 | |||
32 | /** |
||
33 | * @param string $pinId |
||
34 | * @param int $channel By default uses 12 (share via link) |
||
35 | * @return string |
||
36 | */ |
||
37 | public function share($pinId, $channel = 12) |
||
38 | { |
||
39 | $request = [ |
||
40 | "invite_type" => [ |
||
41 | "invite_category" => 3, // magic numbers, but I have |
||
42 | "invite_object" => 1, // no idea what do they mean |
||
43 | "invite_channel" => $channel, |
||
44 | ], |
||
45 | "object_id" => $pinId, |
||
46 | ]; |
||
47 | |||
48 | $response = $this->post(UrlBuilder::RESOURCE_SHARE_VIA_SOCIAL, $request, true); |
||
49 | |||
50 | return isset($response['invite_url']) ? $response['invite_url'] : ''; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @param string $pinId |
||
55 | * @param $userId |
||
56 | * @return array|bool |
||
57 | */ |
||
58 | public function leaveGoodReaction($pinId, $userId) |
||
62 | |||
63 | /** |
||
64 | * @param string $pinId |
||
65 | * @param $userId |
||
66 | * @return array|bool |
||
67 | */ |
||
68 | public function leaveBadReaction($pinId, $userId) |
||
72 | |||
73 | /** |
||
74 | * @param string $pinId |
||
75 | * @param string $userId |
||
76 | * @param string $reaction |
||
77 | * @return array|bool |
||
78 | */ |
||
79 | protected function reactOnPinInConversation($pinId, $userId, $reaction) |
||
89 | } |
||
90 |