Skip to content

Commit

Permalink
Fix messaging logic and add means to message Nomis directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverearl committed Nov 27, 2024
1 parent e661e81 commit 8bafd9c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Actions/ManagesChats.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Nomiai\PhpSdk\Actions;

use Nomiai\PhpSdk\Resources\MessageSet;
use Nomiai\PhpSdk\Resources\Nomi;

/** @mixin \Nomiai\PhpSdk\Traits\MakesHttpRequests */
trait ManagesChats
Expand All @@ -15,9 +16,20 @@ trait ManagesChats
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \JsonException
*/
public function sendMessageToNomi(Nomi $nomi, string $message): MessageSet
{
return $this->sendMessage($nomi->uuid, $message);
}

/**
* Send a message to a given ID.
*
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \JsonException
*/
public function sendMessage(string $id, string $message): MessageSet
{
$response = $this->post("/v1/chats/{$id}", ['messageText' => $message]);
$response = $this->post("/v1/nomis/{$id}/chat", ['messageText' => $message]);

return MessageSet::make($response);
}
Expand Down

0 comments on commit 8bafd9c

Please sign in to comment.