diff --git a/src/Utopia/Messaging/Adapters/SMS/Clickatell.php b/src/Utopia/Messaging/Adapters/SMS/Clickatell.php index 4e302b32..1d004713 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Clickatell.php +++ b/src/Utopia/Messaging/Adapters/SMS/Clickatell.php @@ -14,6 +14,7 @@ class Clickatell extends SMSAdapter */ public function __construct( private string $apiKey, + private ?string $from = null ) { } @@ -43,7 +44,7 @@ protected function process(SMS $message): string ], body: \json_encode([ 'content' => $message->getContent(), - 'from' => $message->getFrom(), + 'from' => $this->from ?? $message->getFrom(), 'to' => $message->getTo(), ]), ); diff --git a/src/Utopia/Messaging/Adapters/SMS/Infobip.php b/src/Utopia/Messaging/Adapters/SMS/Infobip.php index 9d1a584b..f18a62f2 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Infobip.php +++ b/src/Utopia/Messaging/Adapters/SMS/Infobip.php @@ -15,7 +15,8 @@ class Infobip extends SMSAdapter */ public function __construct( private string $apiBaseUrl, - private string $apiKey + private string $apiKey, + private ?string $from = null ) { } @@ -48,7 +49,7 @@ protected function process(SMS $message): string body: \json_encode([ 'messages' => [ 'text' => $message->getContent(), - 'from' => $message->getFrom(), + 'from' => $this->from ?? $message->getFrom(), 'destinations' => $to, ], ]), diff --git a/src/Utopia/Messaging/Adapters/SMS/Plivo.php b/src/Utopia/Messaging/Adapters/SMS/Plivo.php index 4f923fdf..b16642a2 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Plivo.php +++ b/src/Utopia/Messaging/Adapters/SMS/Plivo.php @@ -15,7 +15,8 @@ class Plivo extends SMSAdapter */ public function __construct( private string $authId, - private string $authToken + private string $authToken, + private ?string $from = null ) { } @@ -44,7 +45,7 @@ protected function process(SMS $message): string ], body: \http_build_query([ 'text' => $message->getContent(), - 'src' => $message->getFrom() ?? 'Plivo', + 'src' => $this->from ?? $message->getFrom() ?? 'Plivo', 'dst' => \implode('<', $message->getTo()), ]), ); diff --git a/src/Utopia/Messaging/Adapters/SMS/Seven.php b/src/Utopia/Messaging/Adapters/SMS/Seven.php index 383bdf94..2b3af28e 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Seven.php +++ b/src/Utopia/Messaging/Adapters/SMS/Seven.php @@ -13,7 +13,8 @@ class Seven extends SMSAdapter * @param string $apiKey Seven API token */ public function __construct( - private string $apiKey + private string $apiKey, + private ?string $from = null ) { } @@ -42,7 +43,7 @@ protected function process(SMS $message): string 'content-type: application/json', ], body: \json_encode([ - 'from' => $message->getFrom(), + 'from' => $this->from ?? $message->getFrom(), 'to' => \implode(',', $message->getTo()), 'text' => $message->getContent(), ]), diff --git a/src/Utopia/Messaging/Adapters/SMS/Sinch.php b/src/Utopia/Messaging/Adapters/SMS/Sinch.php index ac0dc0b3..7c30b363 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Sinch.php +++ b/src/Utopia/Messaging/Adapters/SMS/Sinch.php @@ -15,7 +15,8 @@ class Sinch extends SMSAdapter */ public function __construct( private string $servicePlanId, - private string $apiToken + private string $apiToken, + private ?string $from = null ) { } @@ -46,7 +47,7 @@ protected function process(SMS $message): string 'content-type: application/json', ], body: \json_encode([ - 'from' => $message->getFrom(), + 'from' => $this->from ?? $message->getFrom(), 'to' => $to, 'body' => $message->getContent(), ]), diff --git a/src/Utopia/Messaging/Adapters/SMS/Telnyx.php b/src/Utopia/Messaging/Adapters/SMS/Telnyx.php index 431736b5..06b262d2 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Telnyx.php +++ b/src/Utopia/Messaging/Adapters/SMS/Telnyx.php @@ -12,6 +12,7 @@ class Telnyx extends SMSAdapter */ public function __construct( private string $apiKey, + private ?string $from = null ) { } @@ -41,7 +42,7 @@ protected function process(SMS $message): string ], body: \json_encode([ 'text' => $message->getContent(), - 'from' => $message->getFrom(), + 'from' => $this->from ?? $message->getFrom(), 'to' => $message->getTo()[0], ]), ); diff --git a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php index 68fb4e37..bd74102c 100644 --- a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php +++ b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php @@ -16,7 +16,8 @@ class TextMagic extends SMSAdapter */ public function __construct( private string $username, - private string $apiKey + private string $apiKey, + private ?string $from = null ) { } @@ -51,7 +52,7 @@ protected function process(SMS $message): string ], body: \http_build_query([ 'text' => $message->getContent(), - 'from' => \ltrim($message->getFrom(), '+'), + 'from' => \ltrim($this->from ?? $message->getFrom(), '+'), 'phones' => \implode(',', $to), ]), ); diff --git a/src/Utopia/Messaging/Adapters/SMS/Twilio.php b/src/Utopia/Messaging/Adapters/SMS/Twilio.php index 9f28ff2c..bbcdd854 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Twilio.php +++ b/src/Utopia/Messaging/Adapters/SMS/Twilio.php @@ -13,7 +13,8 @@ class Twilio extends SMSAdapter */ public function __construct( private string $accountSid, - private string $authToken + private string $authToken, + private ?string $from = null ) { } @@ -42,7 +43,7 @@ protected function process(SMS $message): string ], body: \http_build_query([ 'Body' => $message->getContent(), - 'From' => $message->getFrom(), + 'From' => $this->from ?? $message->getFrom(), 'To' => $message->getTo()[0], ]), ); diff --git a/src/Utopia/Messaging/Adapters/SMS/Vonage.php b/src/Utopia/Messaging/Adapters/SMS/Vonage.php index 7ed16714..cdb58c42 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Vonage.php +++ b/src/Utopia/Messaging/Adapters/SMS/Vonage.php @@ -16,7 +16,8 @@ class Vonage extends SMSAdapter */ public function __construct( private string $apiKey, - private string $apiSecret + private string $apiSecret, + private ?string $from = null ) { } @@ -47,7 +48,7 @@ protected function process(SMS $message): string url: 'https://rest.nexmo.com/sms/json', body: \http_build_query([ 'text' => $message->getContent(), - 'from' => $message->getFrom(), + 'from' => $this->from ?? $message->getFrom(), 'to' => $to[0], //\implode(',', $to), 'api_key' => $this->apiKey, 'api_secret' => $this->apiSecret,