diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 3365ff0e..ff6973bd 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -23,6 +23,9 @@
test/Verify
+
+ test/Application
+
test/Verify2
diff --git a/src/Application/Application.php b/src/Application/Application.php
index 3f3eed30..ee12922a 100644
--- a/src/Application/Application.php
+++ b/src/Application/Application.php
@@ -230,7 +230,7 @@ public function toArray(): array
{
// Build up capabilities that are set
$availableCapabilities = [
- 'voice' => [VoiceConfig::ANSWER, VoiceConfig::EVENT],
+ 'voice' => [VoiceConfig::ANSWER, VoiceConfig::EVENT, VoiceConfig::FALLBACK_ANSWER_URL],
'messages' => [MessagesConfig::INBOUND, MessagesConfig::STATUS],
'rtc' => [RtcConfig::EVENT]
];
diff --git a/src/Application/VoiceConfig.php b/src/Application/VoiceConfig.php
index b957b317..47a83a46 100644
--- a/src/Application/VoiceConfig.php
+++ b/src/Application/VoiceConfig.php
@@ -10,6 +10,8 @@ class VoiceConfig
{
public const EVENT = 'event_url';
public const ANSWER = 'answer_url';
+ public const FALLBACK_ANSWER_URL = 'fallback_answer_url';
+
protected ?bool $signedCallbacks = null;
protected ?int $conversationsTtl = null;
protected ?string $region = null;
diff --git a/src/Application/Webhook.php b/src/Application/Webhook.php
index 88ab3457..e8f488e2 100644
--- a/src/Application/Webhook.php
+++ b/src/Application/Webhook.php
@@ -8,9 +8,7 @@ class Webhook implements \Stringable
{
public const METHOD_POST = 'POST';
public const METHOD_GET = 'GET';
-
public ?string $socketTimeout = null;
-
public ?string $connectionTimeout = null;
public function __construct(protected ?string $url, protected ?string $method = self::METHOD_POST)
diff --git a/src/Messages/Channel/MMS/MMSAudio.php b/src/Messages/Channel/MMS/MMSAudio.php
index c9a34c9e..2d1b6056 100644
--- a/src/Messages/Channel/MMS/MMSAudio.php
+++ b/src/Messages/Channel/MMS/MMSAudio.php
@@ -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,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/MMS/MMSImage.php b/src/Messages/Channel/MMS/MMSImage.php
index a92c76a3..47855f26 100644
--- a/src/Messages/Channel/MMS/MMSImage.php
+++ b/src/Messages/Channel/MMS/MMSImage.php
@@ -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,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/MMS/MMSVideo.php b/src/Messages/Channel/MMS/MMSVideo.php
index 5aaaa5cc..0d276609 100644
--- a/src/Messages/Channel/MMS/MMSVideo.php
+++ b/src/Messages/Channel/MMS/MMSVideo.php
@@ -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,
@@ -23,6 +24,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/MMS/MMSvCard.php b/src/Messages/Channel/MMS/MMSvCard.php
index 54e6e927..9124b428 100644
--- a/src/Messages/Channel/MMS/MMSvCard.php
+++ b/src/Messages/Channel/MMS/MMSvCard.php
@@ -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,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/Message.php b/src/Messages/Channel/Message.php
index 004370be..d5da6c0d 100644
--- a/src/Messages/Channel/Message.php
+++ b/src/Messages/Channel/Message.php
@@ -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.
diff --git a/src/Messages/Channel/Messenger/MessengerAudio.php b/src/Messages/Channel/Messenger/MessengerAudio.php
index d7f77812..6e3ab8f4 100644
--- a/src/Messages/Channel/Messenger/MessengerAudio.php
+++ b/src/Messages/Channel/Messenger/MessengerAudio.php
@@ -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,
@@ -25,6 +26,11 @@ public function __construct(
$this->tag = $tag;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/Messenger/MessengerFile.php b/src/Messages/Channel/Messenger/MessengerFile.php
index 00bb5fe6..8cad886e 100644
--- a/src/Messages/Channel/Messenger/MessengerFile.php
+++ b/src/Messages/Channel/Messenger/MessengerFile.php
@@ -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,
@@ -36,4 +37,9 @@ public function toArray(): array
return $returnArray;
}
+
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
}
diff --git a/src/Messages/Channel/Messenger/MessengerImage.php b/src/Messages/Channel/Messenger/MessengerImage.php
index 6aefb065..a17658f4 100644
--- a/src/Messages/Channel/Messenger/MessengerImage.php
+++ b/src/Messages/Channel/Messenger/MessengerImage.php
@@ -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,
@@ -36,4 +37,9 @@ public function toArray(): array
return $returnArray;
}
+
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
}
diff --git a/src/Messages/Channel/Messenger/MessengerObjectTrait.php b/src/Messages/Channel/Messenger/MessengerObjectTrait.php
index 66cefa24..288a9a92 100644
--- a/src/Messages/Channel/Messenger/MessengerObjectTrait.php
+++ b/src/Messages/Channel/Messenger/MessengerObjectTrait.php
@@ -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();
@@ -26,9 +22,6 @@ public function setCategory(string $category): void
$this->category = $category;
}
- /**
- * @return string
- */
public function getTag(): ?string
{
return $this->tag;
diff --git a/src/Messages/Channel/Messenger/MessengerText.php b/src/Messages/Channel/Messenger/MessengerText.php
index 53568572..584d3a1f 100644
--- a/src/Messages/Channel/Messenger/MessengerText.php
+++ b/src/Messages/Channel/Messenger/MessengerText.php
@@ -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,
@@ -27,6 +28,11 @@ public function __construct(
$this->tag = $tag;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/Messenger/MessengerVideo.php b/src/Messages/Channel/Messenger/MessengerVideo.php
index a88f4e6b..900ed3a7 100644
--- a/src/Messages/Channel/Messenger/MessengerVideo.php
+++ b/src/Messages/Channel/Messenger/MessengerVideo.php
@@ -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,
@@ -25,6 +26,11 @@ public function __construct(
$this->tag = $tag;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/RCS/RcsCustom.php b/src/Messages/Channel/RCS/RcsCustom.php
index b94c733d..2ac0ae40 100644
--- a/src/Messages/Channel/RCS/RcsCustom.php
+++ b/src/Messages/Channel/RCS/RcsCustom.php
@@ -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,
@@ -27,6 +28,11 @@ public function __construct(
$this->custom = $custom;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function getCustom(): array
{
return $this->custom;
diff --git a/src/Messages/Channel/RCS/RcsFile.php b/src/Messages/Channel/RCS/RcsFile.php
index 1dc575cb..f9d476bd 100644
--- a/src/Messages/Channel/RCS/RcsFile.php
+++ b/src/Messages/Channel/RCS/RcsFile.php
@@ -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,
@@ -27,6 +28,11 @@ public function __construct(
$this->file = $file;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function setTtl(?int $ttl): void
{
$range = [
diff --git a/src/Messages/Channel/RCS/RcsImage.php b/src/Messages/Channel/RCS/RcsImage.php
index 25031298..ffacd672 100644
--- a/src/Messages/Channel/RCS/RcsImage.php
+++ b/src/Messages/Channel/RCS/RcsImage.php
@@ -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,
@@ -27,6 +28,11 @@ public function __construct(
$this->image = $image;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function setTtl(?int $ttl): void
{
$range = [
diff --git a/src/Messages/Channel/RCS/RcsText.php b/src/Messages/Channel/RCS/RcsText.php
index f907d22e..22a74d00 100644
--- a/src/Messages/Channel/RCS/RcsText.php
+++ b/src/Messages/Channel/RCS/RcsText.php
@@ -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,
@@ -27,6 +28,11 @@ public function __construct(
$this->text = $message;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function setTtl(?int $ttl): void
{
$range = [
diff --git a/src/Messages/Channel/RCS/RcsVideo.php b/src/Messages/Channel/RCS/RcsVideo.php
index 254fba31..b9976424 100644
--- a/src/Messages/Channel/RCS/RcsVideo.php
+++ b/src/Messages/Channel/RCS/RcsVideo.php
@@ -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,
@@ -27,6 +28,11 @@ public function __construct(
$this->video = $videoObject;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function setTtl(?int $ttl): void
{
$range = [
diff --git a/src/Messages/Channel/SMS/SMSText.php b/src/Messages/Channel/SMS/SMSText.php
index c25c7c9b..bf137d71 100644
--- a/src/Messages/Channel/SMS/SMSText.php
+++ b/src/Messages/Channel/SMS/SMSText.php
@@ -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,
@@ -32,6 +33,11 @@ public function __construct(
$this->text = $message;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function getEncodingType(): ?string
{
return $this->encodingType;
diff --git a/src/Messages/Channel/Viber/ViberFile.php b/src/Messages/Channel/Viber/ViberFile.php
index 56cbe206..4dbd42e2 100644
--- a/src/Messages/Channel/Viber/ViberFile.php
+++ b/src/Messages/Channel/Viber/ViberFile.php
@@ -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,
@@ -21,6 +22,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/Viber/ViberImage.php b/src/Messages/Channel/Viber/ViberImage.php
index f231a7b9..f01d8bc7 100644
--- a/src/Messages/Channel/Viber/ViberImage.php
+++ b/src/Messages/Channel/Viber/ViberImage.php
@@ -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,
@@ -30,6 +31,11 @@ public function __construct(
$this->action = $viberActionObject;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/Viber/ViberText.php b/src/Messages/Channel/Viber/ViberText.php
index 0313eb3b..760bd090 100644
--- a/src/Messages/Channel/Viber/ViberText.php
+++ b/src/Messages/Channel/Viber/ViberText.php
@@ -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,
@@ -32,6 +33,11 @@ public function __construct(
$this->action = $viberActionObject;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/Viber/ViberVideo.php b/src/Messages/Channel/Viber/ViberVideo.php
index ff73dc38..d8e09880 100644
--- a/src/Messages/Channel/Viber/ViberVideo.php
+++ b/src/Messages/Channel/Viber/ViberVideo.php
@@ -13,6 +13,7 @@ class ViberVideo extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VIDEO;
protected string $channel = 'viber_service';
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -28,6 +29,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppAudio.php b/src/Messages/Channel/WhatsApp/WhatsAppAudio.php
index 0b8575ab..6975891a 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppAudio.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppAudio.php
@@ -12,6 +12,7 @@ class WhatsAppAudio extends BaseMessage
protected string $channel = 'whatsapp';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_AUDIO;
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppCustom.php b/src/Messages/Channel/WhatsApp/WhatsAppCustom.php
index 7a1489d5..e6c8b649 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppCustom.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppCustom.php
@@ -11,6 +11,7 @@ class WhatsAppCustom extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_CUSTOM;
protected string $channel = 'whatsapp';
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -21,6 +22,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function setCustom(array $custom): void
{
$this->custom = $custom;
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppFile.php b/src/Messages/Channel/WhatsApp/WhatsAppFile.php
index 7f9274c1..1f68ea34 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppFile.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppFile.php
@@ -12,6 +12,7 @@ class WhatsAppFile extends BaseMessage
protected string $channel = 'whatsapp';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_FILE;
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppImage.php b/src/Messages/Channel/WhatsApp/WhatsAppImage.php
index 8a702daa..a96bbef0 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppImage.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppImage.php
@@ -12,6 +12,7 @@ class WhatsAppImage extends BaseMessage
protected string $channel = 'whatsapp';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_IMAGE;
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppSticker.php b/src/Messages/Channel/WhatsApp/WhatsAppSticker.php
index d547e7ee..0d5d3d34 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppSticker.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppSticker.php
@@ -12,6 +12,7 @@ class WhatsAppSticker extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_STICKER;
protected string $channel = 'whatsapp';
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function getSticker(): StickerObject
{
return $this->sticker;
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php b/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php
index 186b8f5f..27ce9470 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppTemplate.php
@@ -13,6 +13,7 @@ class WhatsAppTemplate extends BaseMessage
protected string $channel = 'whatsapp';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_TEMPLATE;
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -24,6 +25,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = [
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppText.php b/src/Messages/Channel/WhatsApp/WhatsAppText.php
index 7a00c3ee..34e2c324 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppText.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppText.php
@@ -13,6 +13,7 @@ class WhatsAppText extends BaseMessage
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_TEXT;
protected string $channel = 'whatsapp';
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -24,6 +25,11 @@ public function __construct(
$this->text = $text;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Channel/WhatsApp/WhatsAppVideo.php b/src/Messages/Channel/WhatsApp/WhatsAppVideo.php
index 6d92d06f..f7604086 100644
--- a/src/Messages/Channel/WhatsApp/WhatsAppVideo.php
+++ b/src/Messages/Channel/WhatsApp/WhatsAppVideo.php
@@ -12,6 +12,7 @@ class WhatsAppVideo extends BaseMessage
protected string $channel = 'whatsapp';
protected string $subType = BaseMessage::MESSAGES_SUBTYPE_VIDEO;
+ protected bool $validatesE164 = true;
public function __construct(
string $to,
@@ -22,6 +23,11 @@ public function __construct(
$this->from = $from;
}
+ public function validatesE164(): bool
+ {
+ return $this->validatesE164;
+ }
+
public function toArray(): array
{
$returnArray = $this->getBaseMessageUniversalOutputArray();
diff --git a/src/Messages/Client.php b/src/Messages/Client.php
index fe710dc3..1446f4cb 100644
--- a/src/Messages/Client.php
+++ b/src/Messages/Client.php
@@ -25,12 +25,16 @@ public function send(BaseMessage $message): ?array
{
$messageArray = $message->toArray();
- if ($this->isValidE164($messageArray['to'])) {
- $messageArray['to'] = $this->stripLeadingPlus($messageArray['to']);
- return $this->getAPIResource()->create($messageArray);
- };
+ if ($message->validatesE164()) {
+ if ($this->isValidE164($messageArray['to'])) {
+ $messageArray['to'] = $this->stripLeadingPlus($messageArray['to']);
+ return $this->getAPIResource()->create($messageArray);
+ } else {
+ throw new \InvalidArgumentException('Number provided is not a valid E164 number');
+ }
+ }
- throw new \InvalidArgumentException('Number provided is not a valid E164 number');
+ return $this->getAPIResource()->create($messageArray);
}
public function updateRcsStatus(string $messageUuid, string $status): bool
diff --git a/test/Application/ApplicationTest.php b/test/Application/ApplicationTest.php
index 7ad7b39d..d840886e 100644
--- a/test/Application/ApplicationTest.php
+++ b/test/Application/ApplicationTest.php
@@ -9,6 +9,7 @@
use Vonage\Application\MessagesConfig;
use Vonage\Application\RtcConfig;
use Vonage\Application\VoiceConfig;
+use Vonage\Application\Webhook;
use Vonage\Client\Exception\Exception as ClientException;
use VonageTest\Traits\HTTPTestTrait;
use VonageTest\VonageTestCase;
@@ -164,4 +165,17 @@ public function testConfigCanBeCopied(): void
$webhook = $otherapp->getVoiceConfig()->getWebhook(VoiceConfig::ANSWER);
$this->assertEquals('https://example.com/webhooks/answer', $webhook);
}
+
+ public function testCanSetFallbackUrlWebhook(): void
+ {
+ $application = new Application();
+ $application->setName('my application');
+ $application->getVoiceConfig()->setRegion('eu-west');
+
+ $webhook = new Webhook('https://example.com/fallbackUrl', 'GET');
+ $application->getVoiceConfig()->setWebhook(\Vonage\Application\VoiceConfig::FALLBACK_ANSWER_URL, $webhook);
+
+ $output = $application->toArray();
+ $this->assertEquals('https://example.com/fallbackUrl', $output['capabilities']['voice']['webhooks']['fallback_answer_url']['address']);
+ }
}
diff --git a/test/Messages/ClientTest.php b/test/Messages/ClientTest.php
index fbc9ff98..ea549ddc 100644
--- a/test/Messages/ClientTest.php
+++ b/test/Messages/ClientTest.php
@@ -572,7 +572,7 @@ public function testCanSendWhatsAppCustom(): void
public function testCanSendMessengerText(): void
{
$payload = [
- 'to' => '447700900000',
+ 'to' => '10152368852405295',
'from' => '16105551212',
'text' => 'This is a messenger response',
'category' => 'response'