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

Skip to content

Commit af80d06

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 af80d06

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,28 @@ public function toArray(): array
6262
}
6363

6464
/**
65+
* @deprecated since Symfony 6.3, use "cardV2()" instead.
66+
*
6567
* @return $this
6668
*/
6769
public function card(array $card): static
6870
{
71+
trigger_deprecation('symfony/google-chat-notifier', '6.3', '"card()" is deprecated and can be removed, use "cardV2()" instead.');
6972
$this->options['cards'][] = $card;
7073

7174
return $this;
7275
}
7376

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

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,47 @@ public function testToArray()
3434
$this->assertSame($expected, $options->toArray());
3535
}
3636

37+
public function testToArrayWithCardV2()
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+
3778
public function testOptionsWithThread()
3879
{
3980
$thread = 'fgh.ijk';

0 commit comments

Comments
 (0)
2A3A
0