Skip to content

Commit

Permalink
Added validation logic for e164 (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondeJK authored Oct 31, 2024
1 parent 394213c commit b1399d3
Show file tree
Hide file tree
Showing 31 changed files with 173 additions and 13 deletions.
6 changes: 6 additions & 0 deletions src/Messages/Channel/MMS/MMSAudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MMSAudio extends BaseMessage

protected string $channel = 'mms';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_AUDIO;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/MMS/MMSImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MMSImage extends BaseMessage

protected string $channel = 'mms';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/MMS/MMSVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MMSVideo extends BaseMessage

protected string $channel = 'mms';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VIDEO;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -23,6 +24,11 @@ public function __construct(
$this->from = $from;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/MMS/MMSvCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MMSvCard extends BaseMessage

protected string $channel = 'mms';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VCARD;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
1 change: 1 addition & 0 deletions src/Messages/Channel/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function getWebhookUrl(): ?string;
public function setWebhookUrl(string $url): void;
public function getWebhookVersion(): ?string;
public function setWebhookVersion(string $version): void;
public function validatesE164(): bool;

/**
* All message types have shared outputs required by the endpoint.
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Messenger/MessengerAudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MessengerAudio extends BaseMessage

protected string $channel = 'messenger';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_AUDIO;
protected bool $validatesE164 = false;

public function __construct(
string $to,
Expand All @@ -25,6 +26,11 @@ public function __construct(
$this->tag = $tag;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Messenger/MessengerFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MessengerFile extends BaseMessage

protected string $channel = 'messenger';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_FILE;
protected bool $validatesE164 = false;

public function __construct(
string $to,
Expand All @@ -36,4 +37,9 @@ public function toArray(): array

return $returnArray;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}
}
6 changes: 6 additions & 0 deletions src/Messages/Channel/Messenger/MessengerImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MessengerImage extends BaseMessage

protected string $channel = 'messenger';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
protected bool $validatesE164 = false;

public function __construct(
string $to,
Expand All @@ -36,4 +37,9 @@ public function toArray(): array

return $returnArray;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}
}
7 changes: 0 additions & 7 deletions src/Messages/Channel/Messenger/MessengerObjectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ trait MessengerObjectTrait
private ?string $category;
private ?string $tag;

/**
* @return string
*/
public function getCategory(): ?string
{
return $this->category;
}


public function requiresMessengerObject(): bool
{
return $this->getTag() || $this->getCategory();
Expand All @@ -26,9 +22,6 @@ public function setCategory(string $category): void
$this->category = $category;
}

/**
* @return string
*/
public function getTag(): ?string
{
return $this->tag;
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Messenger/MessengerText.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MessengerText extends BaseMessage

protected string $subType = BaseMessage::MESSAGES_SUBTYPE_TEXT;
protected string $channel = 'messenger';
protected bool $validatesE164 = false;

public function __construct(
string $to,
Expand All @@ -27,6 +28,11 @@ public function __construct(
$this->tag = $tag;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Messenger/MessengerVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MessengerVideo extends BaseMessage

protected string $channel = 'messenger';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VIDEO;
protected bool $validatesE164 = false;

public function __construct(
string $to,
Expand All @@ -25,6 +26,11 @@ public function __construct(
$this->tag = $tag;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/RCS/RcsCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RcsCustom extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_FILE;
protected string $channel = 'rcs';
protected array $custom;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -27,6 +28,11 @@ public function __construct(
$this->custom = $custom;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function getCustom(): array
{
return $this->custom;
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/RCS/RcsFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RcsFile extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_FILE;
protected string $channel = 'rcs';
protected FileObject $file;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -27,6 +28,11 @@ public function __construct(
$this->file = $file;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function setTtl(?int $ttl): void
{
$range = [
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/RCS/RcsImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RcsImage extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
protected string $channel = 'rcs';
protected ImageObject $image;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -27,6 +28,11 @@ public function __construct(
$this->image = $image;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function setTtl(?int $ttl): void
{
$range = [
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/RCS/RcsText.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RcsText extends BaseMessage

protected string $subType = BaseMessage::MESSAGES_SUBTYPE_TEXT;
protected string $channel = 'rcs';
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -27,6 +28,11 @@ public function __construct(
$this->text = $message;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function setTtl(?int $ttl): void
{
$range = [
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/RCS/RcsVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RcsVideo extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VIDEO;
protected string $channel = 'rcs';
protected VideoObject $video;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -27,6 +28,11 @@ public function __construct(
$this->video = $videoObject;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function setTtl(?int $ttl): void
{
$range = [
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/SMS/SMSText.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SMSText extends BaseMessage
protected ?string $encodingType = null;
protected ?string $contentId = null;
protected ?string $entityId = null;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -32,6 +33,11 @@ public function __construct(
$this->text = $message;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function getEncodingType(): ?string
{
return $this->encodingType;
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Viber/ViberFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ViberFile extends BaseMessage

protected string $channel = 'viber_service';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_FILE;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -21,6 +22,11 @@ public function __construct(
$this->from = $from;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Viber/ViberImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ViberImage extends BaseMessage

protected string $channel = 'viber_service';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -30,6 +31,11 @@ public function __construct(
$this->action = $viberActionObject;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Channel/Viber/ViberText.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ViberText extends BaseMessage

protected string $subType = BaseMessage::MESSAGES_SUBTYPE_TEXT;
protected string $channel = 'viber_service';
protected bool $validatesE164 = true;

public function __construct(
string $to,
Expand All @@ -32,6 +33,11 @@ public function __construct(
$this->action = $viberActionObject;
}

public function validatesE164(): bool
{
return $this->validatesE164;
}

public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
Expand Down
Loading

0 comments on commit b1399d3

Please sign in to comment.