<?php

namespace App\Services\Messenger;

use Illuminate\Support\Facades\Http;

class BaleApiClient
{
    public function sendMessage(string $chatId, string $text, ?array $keyboard = null): void
    {
        $payload = [
            'chat_id' => $chatId,
            'text' => $text,
        ];

        if ($keyboard !== null) {
            $payload['reply_markup'] = $keyboard;
        }

        Http::baseUrl((string) config('services.bale.base_url'))
            ->post('/bot'.config('services.bale.bot_token').'/sendMessage', $payload);
    }
}
