8000 CardsV1 is deprecated we must use cardsV2 instead. · symfony/symfony@514840a · GitHub
[go: up one dir, main page]

Skip to content

Commit 514840a

Browse files
committed
CardsV1 is deprecated we must use cardsV2 instead.
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.
1 parent 233b9eb commit 514840a

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

src/Symfony/Component/Notifier/Bridge/GoogleChat/GoogleChatOptions.php

Lines changed: 12 additions & 0 deletions
66
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public function toArray(): array
6262
}
6363

6464
/**
65+
* @deprecated google chat cards-v1 deprecated, use "cardV2()" instead.
66+
*
6567
* @return $this
68
*/
6769
public function card(array $card): static
@@ -71,6 +73,16 @@ public function card(array $card): static
7173
return $this;
7274
}
7375

76+
/**
77+
* @return $this
78+
*/
79+
public function cardV2(array $card): static
80+
{
81+
$this->options['cardsV2'][] = $card;
82+
83+
return $this;
84+
}
85+
7486
/**
7587
* @return $this
7688
*/

src/Symfony/Component/Notifier/Bridge/GoogleChat/Tests/GoogleChatOptionsTest.php

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
final class GoogleChatOptionsTest extends TestCase
1818
{
19-
public function testToArray()
19+
public function testToArray(): void
2020
{
2121
$options = new GoogleChatOptions();
2222

@@ -34,7 +34,48 @@ public function testToArray()
3434
$this->assertSame($expected, $options->toArray());
3535
}
3636

37-
public function testOptionsWithThread()
37+
public function testToArrayWithCardV2(): void
38+
{
39+
$options = new GoogleChatOptions();
40+
41+
$cardV2 = [
42+
'header' => [
43+
'title' => 'Sasha',
44+
'subtitle' => 'Software Engineer',
45+
'imageUrl' => 'https://developers.google.com/chat/images/quickstart-app-avatar.png',
46+
'imageType' => 'CIRCLE',
47+
'imageAltText' => 'Avatar for Sasha'
48+
],
49+
'sections' => [
50+
[
51+
'header' => 'Contact Info',
52+
"collapsible" => true,
53+
'widgets' => [
54+
'decoratedText' => [
55+
'startIcon' => ['knownIcon' => 'EMAIL'],
56+
'text' => 'sasha@example.com',
57+
]
58+
]
59+
]
60+
]
61+
];
62+
63+
$options
64+
->text('Hello Bot')
65+
->cardV2($cardV2)
66+
;
67+
68+
$expected = [
69+
'text' => 'Hello Bot',
70+
'cardsV2' => [
71+
$cardV2,
72+
],
73+
];
74+
75+
$this->assertSame($expected, $options->toArray());
76+
}
77+
78+
public function testOptionsWithThread(): void
3879
{
3980
$thread = 'fgh.ijk';
4081
$options = new GoogleChatOptions();

0 commit comments

Comments
 (0)
0