1 | <?php |
||
8 | class SlashCommandResponse |
||
9 | { |
||
10 | /** @var \Spatie\SlashCommand\SlashCommandData */ |
||
11 | protected $slashCommandData; |
||
12 | |||
13 | /** @var string */ |
||
14 | protected $text; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $responseType = 'ephemeral'; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $attachments = ''; |
||
21 | |||
22 | /** @var \GuzzleHttp\Client */ |
||
23 | protected $client; |
||
24 | |||
25 | public static function create(SlashCommandData $slashCommandData): SlashCommandResponse |
||
26 | { |
||
27 | $client = app(Client::class); |
||
28 | |||
29 | return (new static($client, $slashCommandData)) |
||
30 | ->displayResponseOnlyToUserWhoTypedCommand(); |
||
31 | } |
||
32 | |||
33 | public function __construct(Client $client, SlashCommandData $slashCommandData) |
||
34 | { |
||
35 | $this->client = $client; |
||
36 | |||
37 | $this->slashCommandData = $slashCommandData; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param string $text |
||
42 | * @return $this |
||
43 | */ |
||
44 | public function setText(string $text) |
||
50 | |||
51 | /** |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function displayResponseOnlyToUserWhoTypedCommand() |
||
60 | |||
61 | /** |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function displayResponseToEveryoneOnChannel() |
||
70 | |||
71 | /** |
||
72 | * Send the response to Slack |
||
73 | */ |
||
74 | public function send() |
||
78 | |||
79 | /* |
||
80 | * Get the http response |
||
81 | */ |
||
82 | public function getHttpResponse(): Response |
||
86 | |||
87 | protected function getPayload(): array |
||
99 | } |
||
100 |