1 | <?php |
||
9 | class SlashCommandResponse |
||
10 | { |
||
11 | /** @var SlashCommandRequest */ |
||
12 | protected $request; |
||
13 | |||
14 | /** @var string */ |
||
15 | protected $text; |
||
16 | |||
17 | /** @var string */ |
||
18 | protected $responseType = 'ephemeral'; |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $attachments = ''; |
||
22 | |||
23 | /** @var \GuzzleHttp\Client */ |
||
24 | protected $client; |
||
25 | |||
26 | public static function createForRequest(Request $request): SlashCommandResponse |
||
32 | |||
33 | public function __construct(Client $client) |
||
37 | |||
38 | /** |
||
39 | * @param \Illuminate\Http\Request $request |
||
40 | * @return $this |
||
41 | */ |
||
42 | public function setRequest(Request $request) |
||
48 | |||
49 | /** |
||
50 | * @param string $text |
||
51 | * @return $this |
||
52 | */ |
||
53 | public function setText(string $text) |
||
54 | { |
||
55 | $this->text = $text; |
||
56 | |||
57 | return $this; |
||
58 | } |
||
59 | |||
60 | public function getResponseUrl() |
||
61 | { |
||
62 | return $this->request->get('response_url'); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return $this |
||
67 | */ |
||
68 | public function displayResponseOnlyToUserWhoTypedCommand() |
||
74 | |||
75 | /** |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function displayResponseToEveryoneOnChannel() |
||
84 | |||
85 | /** |
||
86 | * Send the response to Slack |
||
87 | */ |
||
88 | public function send() |
||
92 | |||
93 | /* |
||
94 | * Get the http response |
||
95 | */ |
||
96 | public function getHttpResponse(): Response |
||
100 | |||
101 | protected function getPayload(): array |
||
113 | } |
||
114 |