feat: add helper, clean up code, remove test route #29

Merged
benjamyn merged 2 commits from feat/request-quotes-from-fe into master 2023-10-28 10:43:14 -04:00
Showing only changes of commit dcf8c28f1a - Show all commits

View File

@ -3,22 +3,24 @@
namespace App\Helpers; namespace App\Helpers;
use App\Models\Quote; use App\Models\Quote;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
class Slack class Slack
{ {
private string $url; private string $url;
public function __construct() { public function __construct()
{
$this->url = config('bot.webhook'); $this->url = config('bot.webhook');
} }
private function send($text): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response private function send(string $text): Response
{ {
return Http::post($this->url, ['text' => $text]); return Http::post($this->url, ['text' => $text]);
} }
public function sendText(string $text): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response public function sendText(string $text): Response
{ {
activity() activity()
->event('send') ->event('send')
@ -27,7 +29,7 @@ class Slack
return $this->send($text); return $this->send($text);
} }
public function sendQuote(Quote $quote): \GuzzleHttp\Promise\PromiseInterface|\Illuminate\Http\Client\Response public function sendQuote(Quote $quote): Response
{ {
activity() activity()
->performedOn($quote) ->performedOn($quote)