Skip to content

Commit

Permalink
implement RcsParams.fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiez committed Dec 3, 2024
1 parent 8784c85 commit 5848345
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/Resource/Rcs/RcsFallbackType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

enum RcsFallbackType: string
{
case SMS = 'sms';
case WebView = 'webview';
}
11 changes: 11 additions & 0 deletions src/Resource/Rcs/RcsParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class RcsParams implements ParamsInterface
protected string $text;
protected string $to;
protected ?int $ttl = null;
protected ?RcsFallbackType $fallback = null;

public function __construct(string $text, string $to)
{
Expand Down Expand Up @@ -108,6 +109,16 @@ public function toArray(): array
{
$arr = get_object_vars($this);
if ($this->delay) $arr['delay'] = $this->delay->format('Y-m-d h:i');
if ($this->fallback) $arr['fallback'] = $this->fallback->value;
return $arr;
}

public function getFallback(): ?RcsFallbackType {
return $this->fallback;
}

public function setFallback(?RcsFallbackType $fallback): self {
$this->fallback = $fallback;
return $this;
}
}
6 changes: 5 additions & 1 deletion tests/RcsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
use DateTime;
use Seven\Api\Resource\Rcs\RcsEvent;
use Seven\Api\Resource\Rcs\RcsEventParams;
use Seven\Api\Resource\Rcs\RcsFallbackType;
use Seven\Api\Resource\Rcs\RcsParams;

final class RcsTest extends BaseTest
{
public function testText(): void
{
$params = new RcsParams('HI2U! The UNIX time is ' . time() . '.', '491716992343');
$params = (new RcsParams('HI2U! The UNIX time is ' . time() . '.', '491716992343'))
->setDelay(new DateTime('12-12-2050'))
->setFallback(RcsFallbackType::SMS)
;
$res = $this->resources->rcs->dispatch($params);

$this->assertCount(1, $res->getMessages());
Expand Down

0 comments on commit 5848345

Please sign in to comment.