client = new Client([ 'base_uri' => rtrim(config('scheduler.mattermost.server_url'), '/') . '/api/v4/', 'headers' => [ 'Authorization' => 'Bearer ' . config('scheduler.mattermost.access_token'), 'Accept' => 'application/json', 'Content-Type' => 'application/json', ], ]); } public function run(): void { try { $request = new \GuzzleHttp\Psr7\Request( $this->config['method'] ?? 'POST', $this->config['endpoint'], ['Content-Type' => 'application/json'], json_encode($this->config['body'] ?? []) ); $res = $this->client->send($request); // $res = $this->client->put('users/me/status/custom', [ // 'json' => [ // 'emoji' => 'house', // 'text' => 'Working Home', // 'status' => 'online', // ] // ]); if ($res->getStatusCode() === 200) { Log::info("Mattermost home status updated successfully."); } else { Log::error("Failed to update Mattermost status. HTTP Status: " . $res->getStatusCode()); } } catch (\Exception $e) { Log::error("Error updating Mattermost status: " . $e->getMessage()); } } public static function configSchema(): array { return [ 'endpoint' => ['type' => 'string', 'label' => 'API Endpoint', 'rules' => [ 'required', 'string', 'max:255', ]], 'method' => ['type' => 'string', 'label' => 'HTTP Method', 'default' => 'POST', 'rules' => [ 'required', 'in:GET,POST,PUT,DELETE,PATCH', ]], 'body' => ['type' => 'array', 'label' => 'Request Body (JSON)', 'rules' => [ 'nullable', 'array', ]], ]; } }