Skip to content

Commit

Permalink
CardsV1 is deprecated we must use cardsV2 instead.
Browse files Browse the repository at this point in the history
Based on google developers api documentation.
https://developers.google.com/chat/api/reference/rest/v1/cards-v1
CardsV1 is deprecated we must use cardsV2 instead.
  • Loading branch information
daifma committed Dec 15, 2022
1 parent 233b9eb commit 4e69574
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function toArray(): array
*/
public function card(array $card): static
{
$this->options['cards'][] = $card;
$this->options['cardsV2'][] = $card;

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,48 @@

final class GoogleChatOptionsTest extends TestCase
{
public function testToArray()
public function testToArray(): void
{
$options = new GoogleChatOptions();

$cardV2 = [
'header' => [
'title' => 'Sasha',
'subtitle' => 'Software Engineer',
'imageUrl' => 'https://developers.google.com/chat/images/quickstart-app-avatar.png',
'imageType' => 'CIRCLE',
'imageAltText' => 'Avatar for Sasha'
],
'sections' => [
[
'header' => 'Contact Info',
"collapsible" => true,
'widgets' => [
'decoratedText' => [
'startIcon' => ['knownIcon' => 'EMAIL'],
'text' => 'sasha@example.com',
]
]
]
]
];

$options
->text('Pizza Bot')
->card(['header' => ['Pizza Bot Customer Support']]);
->text('Hello Bot')
->card($cardV2)
;

$expected = [
'text' => 'Pizza Bot',
'cards' => [
['header' => ['Pizza Bot Customer Support']],
'text' => 'Hello Bot',
'cardsV2' => [
$cardV2,
],
];

$this->assertSame($expected, $options->toArray());
}

public function testOptionsWithThread()
public function testOptionsWithThread(): void
{
$thread = 'fgh.ijk';
$options = new GoogleChatOptions();
Expand Down

0 comments on commit 4e69574

Please sign in to comment.