Skip to content
Open
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
21 changes: 21 additions & 0 deletions src/Resource/Rcs/RcsCalendarEventParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

use Seven\Api\Library\ParamsInterface;

readonly class RcsCalendarEventParams implements ParamsInterface
{
public function __construct(
public string $startTime,
public string $endTime,
public string $title,
public string $description,
) {
}

public function toArray(): array
{
return get_object_vars($this);
}
}
9 changes: 9 additions & 0 deletions src/Resource/Rcs/RcsCardOrientation.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 RcsCardOrientation: string
{
case HORIZONTAL = 'horizontal';
case VERTICAL = 'vertical';
}
48 changes: 48 additions & 0 deletions src/Resource/Rcs/RcsCarouselParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

use Seven\Api\Library\ParamsInterface;

class RcsCarouselParams implements ParamsInterface
{
/** @var RcsRichcardParams[] */
protected array $richcards;

public function __construct(
protected RcsCarouselWidth $width,
RcsRichcardParams ...$richcards,
) {
$this->richcards = $richcards;
}

public function getWidth(): RcsCarouselWidth
{
return $this->width;
}

public function setWidth(RcsCarouselWidth $width): self
{
$this->width = $width;
return $this;
}

public function getRichcards(): array
{
return $this->richcards;
}

public function addRichcards(RcsRichcardParams ...$richcards): self
{
array_push($this->richcards, ...$richcards);
return $this;
}

public function toArray(): array
{
return [
'width' => $this->width->value,
'richcards' => array_map(fn(RcsRichcardParams $v) => $v->toArray(), $this->richcards),
];
}
}
9 changes: 9 additions & 0 deletions src/Resource/Rcs/RcsCarouselWidth.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 RcsCarouselWidth: string
{
case SMALL = 'SMALL';
case MEDIUM = 'MEDIUM';
}
51 changes: 51 additions & 0 deletions src/Resource/Rcs/RcsFallbackParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

use Seven\Api\Library\ParamsInterface;

class RcsFallbackParams implements ParamsInterface
{
protected ?string $text = null;
protected ?string $from = null;

public function __construct(protected RcsFallbackType $type)
{
}

public function toArray(): array
{
return [
'type' => $this->type->value,
'text' => $this->text,
'from' => $this->from,
];
}

public function getType(): RcsFallbackType
{
return $this->type;
}

public function getText(): ?string
{
return $this->text;
}

public function setText(?string $text): self
{
$this->text = $text;
return $this;
}

public function getFrom(): ?string
{
return $this->from;
}

public function setFrom(?string $from): self
{
$this->from = $from;
return $this;
}
}
10 changes: 10 additions & 0 deletions src/Resource/Rcs/RcsFileHeight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

enum RcsFileHeight: string
{
case SHORT = 'short';
case MEDIUM = 'medium';
case TALL = 'tall';
}
80 changes: 80 additions & 0 deletions src/Resource/Rcs/RcsFileParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

use Seven\Api\Library\ParamsInterface;

class RcsFileParams implements ParamsInterface
{
protected ?RcsFileHeight $height = null;
protected ?string $fileUrl = null;
protected ?string $fileContents = null;
protected ?string $thumbnailUrl = null;
protected ?string $thumbnailContents = null;

public function toArray(): array
{
$arr = get_object_vars($this);

if ($this->height) {
$arr['height'] = $this->height->value;
}

return $arr;
}

public function getHeight(): ?RcsFileHeight
{
return $this->height;
}

public function setHeight(?RcsFileHeight $height): self
{
$this->height = $height;
return $this;
}

public function getFileUrl(): ?string
{
return $this->fileUrl;
}

public function setFileUrl(?string $fileUrl): self
{
$this->fileUrl = $fileUrl;
return $this;
}

public function getFileContents(): ?string
{
return $this->fileContents;
}

public function setFileContents(?string $fileContents): self
{
$this->fileContents = $fileContents;
return $this;
}

public function getThumbnailUrl(): ?string
{
return $this->thumbnailUrl;
}

public function setThumbnailUrl(?string $thumbnailUrl): self
{
$this->thumbnailUrl = $thumbnailUrl;
return $this;
}

public function getThumbnailContents(): ?string
{
return $this->thumbnailContents;
}

public function setThumbnailContents(?string $thumbnailContents): self
{
$this->thumbnailContents = $thumbnailContents;
return $this;
}
}
20 changes: 20 additions & 0 deletions src/Resource/Rcs/RcsLocationParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);

namespace Seven\Api\Resource\Rcs;

use Seven\Api\Library\ParamsInterface;

readonly class RcsLocationParams implements ParamsInterface
{
public function __construct(
public float $latitude,
public float $longitude,
public ?string $label = null,
) {
}

public function toArray(): array
{
return get_object_vars($this);
}
}
105 changes: 100 additions & 5 deletions src/Resource/Rcs/RcsParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,34 @@ class RcsParams implements ParamsInterface
protected string $text;
protected string $to;
protected ?int $ttl = null;
protected ?RcsFallbackType $fallback = null;
protected RcsFallbackType|RcsFallbackParams|null $fallback = null;
protected ?RcsCarouselParams $carousel = null;
protected ?RcsRichcardParams $richcard = null;
protected ?RcsFileParams $file = null;
/** @var RcsSuggestionParams[]|null */
protected ?array $suggestions = null;

public function __construct(string $text, string $to)
{
$this->text = $text;
$this->to = $to;
}

public static function carousel(RcsCarouselParams $carousel, string $to): self
{
return (new self('', $to))->setCarousel($carousel);
}

public static function richcard(RcsRichcardParams $richcard, string $to): self
{
return (new self('', $to))->setRichcard($richcard);
}

public static function file(RcsFileParams $file, string $to): self
{
return (new self('', $to))->setFile($file);
}

public function getTo(): string
{
return $this->to;
Expand Down Expand Up @@ -108,17 +128,92 @@ public function setTTL(?int $ttl): self
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;

if ($this->delay) {
$arr['delay'] = $this->delay->format('Y-m-d h:i');
}

if ($this->fallback instanceof RcsFallbackType) {
$arr['fallback'] = $this->fallback->value;
}

if ($this->fallback instanceof RcsFallbackParams) {
$arr['fallback'] = $this->fallback->toArray();
}

if ($this->carousel) {
$arr['carousel'] = $this->carousel->toArray();
}

if ($this->richcard) {
$arr['richcard'] = $this->richcard->toArray();
}

if ($this->file) {
$arr['file'] = $this->file->toArray();
}

if (is_array($this->suggestions)) {
$arr['suggestions'] = array_map(fn(RcsSuggestionParams $v) => $v->toArray(), $this->suggestions);
}

if ('' === $this->text) {
unset($arr['text']);
}

return $arr;
}

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

public function setFallback(?RcsFallbackType $fallback): self {
public function setFallback(RcsFallbackType|RcsFallbackParams|null $fallback): self {
$this->fallback = $fallback;
return $this;
}

public function getCarousel(): ?RcsCarouselParams
{
return $this->carousel;
}

public function setCarousel(?RcsCarouselParams $carousel): self
{
$this->carousel = $carousel;
return $this;
}

public function getRichcard(): ?RcsRichcardParams
{
return $this->richcard;
}

public function setRichcard(?RcsRichcardParams $richcard): self
{
$this->richcard = $richcard;
return $this;
}

public function getFile(): ?RcsFileParams
{
return $this->file;
}

public function setFile(?RcsFileParams $file): self
{
$this->file = $file;
return $this;
}

public function getSuggestions(): ?array
{
return $this->suggestions;
}

public function setSuggestions(RcsSuggestionParams ...$suggestions): self
{
$this->suggestions = $suggestions;
return $this;
}
}
Loading