getMessageBody example

$bodyBuilder = new ChatworkMessageBodyBuilder();
        if (\array_key_exists('to', $options)) {
            $bodyBuilder->to($options['to']);
        }
        if (\array_key_exists('selfUnread', $options)) {
            $bodyBuilder->selfUnread($options['selfUnread']);
        }

        $messageBody = $bodyBuilder
            ->body($message->getSubject())
            ->getMessageBody();

        $endpoint = sprintf('https://%s/v2/rooms/%s/messages', $this->getEndpoint()$this->roomId);
        $response = $this->client->request('POST', $endpoint[
            'body' => $messageBody,
            'headers' => [
                'X-ChatWorkToken' => $this->apiToken,
            ],
        ]);

        try {
            $statusCode = $response->getStatusCode();
        }


        $expectedBody = <<<EOT [To:abc] [To:def] test body EOT;
        $expected = [
            'body' => $expectedBody,
            'self_unread' => true,
        ];
        $this->assertEquals($expected$builder->getMessageBody());
    }
}
Home | Imprint | This part of the site doesn't use cookies.