1 | <?php |
||
8 | class Response |
||
9 | { |
||
10 | /** @var \Spatie\SlashCommand\Request */ |
||
11 | protected $request; |
||
12 | |||
13 | /** @var string */ |
||
14 | protected $text; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $responseType; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $channel; |
||
21 | |||
22 | /** @var string */ |
||
23 | protected $icon = ''; |
||
24 | |||
25 | /** @var \Illuminate\Support\Collection */ |
||
26 | protected $attachments; |
||
27 | |||
28 | /** @var \GuzzleHttp\Client */ |
||
29 | protected $client; |
||
30 | |||
31 | public static function create(Request $request): Response |
||
37 | |||
38 | public function __construct(Client $client, Request $request) |
||
50 | |||
51 | /** |
||
52 | * @param string $text |
||
53 | * |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function withText(string $text) |
||
62 | |||
63 | public function onChannel(string $channelName) |
||
69 | |||
70 | /** |
||
71 | * @return $this |
||
72 | */ |
||
73 | public function displayResponseToUserWhoTypedCommand() |
||
79 | |||
80 | /** |
||
81 | * @param \Spatie\SlashCommand\Attachment $attachment |
||
82 | * |
||
83 | * @return $this |
||
84 | */ |
||
85 | public function withAttachment(Attachment $attachment) |
||
91 | |||
92 | /** |
||
93 | * @param array $attachments |
||
94 | * |
||
95 | * @return $this |
||
96 | */ |
||
97 | public function withAttachments(array $attachments) |
||
98 | { |
||
99 | foreach ($attachments as $attachment) { |
||
100 | $this->attachments->push($attachment); |
||
101 | } |
||
102 | |||
103 | return $this; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * @param string $channelName |
||
108 | * |
||
109 | * @return $this |
||
110 | */ |
||
111 | public function displayResponseToEveryoneOnChannel(string $channelName = '') |
||
121 | |||
122 | /** |
||
123 | * Set the icon (either URL or emoji) we will post as. |
||
124 | * |
||
125 | * @param string $icon |
||
126 | * |
||
127 | * @return this |
||
128 | */ |
||
129 | public function useIcon(string $icon) |
||
135 | |||
136 | public function getIconType(): string |
||
148 | |||
149 | /** |
||
150 | * Send the response to Slack. |
||
151 | */ |
||
152 | public function send() |
||
156 | |||
157 | public function getIlluminateResponse(): IlluminateResponse |
||
161 | |||
162 | protected function getPayload(): array |
||
183 | } |
||
184 |