8000 [Notifier] GoogleChat CardsV1 is deprecated we must use cardsV2 instead by daifma · Pull Request #48616 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Notifier] GoogleChat CardsV1 is deprecated we must use cardsV2 instead #48616

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.3
---

* Deprecate `GoogleChatOptions::card()` in favor of `cardV2()`

5.3
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,29 @@ public function toArray(): array
}

/**
* @deprecated since Symfony 6.3, use "cardV2()" instead
*
* @return $this
*/
public function card(array $card): static
{
trigger_deprecation('symfony/google-chat-notifier', '6.3', '"%s()" is deprecated, use "cardV2()" instead.', __METHOD__);

$this->options['cards'][] = $card;

return $this;
}

/**
* @return $this
*/
public function cardV2(array $card): static
{
$this->options['cardsV2'][] = $card;

return $this;
}

/**
* @return $this
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

final class GoogleChatOptionsTest extends TestCase
{
/**
* @group legacy
*/
public function testToArray()
{
$options = new GoogleChatOptions();
Expand All @@ -34,6 +37,47 @@ public function testToArray()
$this->assertSame($expected, $options->toArray());
}

public function testToArrayWithCardV2()
{
$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('Hello Bot')
->cardV2($cardV2)
;

$expected = [
'text' => 'Hello Bot',
'cardsV2' => [
$cardV2,
],
];

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

public function testOptionsWithThread()
{
$thread = 'fgh.ijk';
Expand Down
0