From 65f6c23a7518fa4facfca5a39e9734da95d77833 Mon Sep 17 00:00:00 2001 From: omarabdelaziz Date: Mon, 3 Aug 2026 12:55:59 +0300 Subject: [PATCH 1/4] chore: update package docs --- README.md | 38 +++++++++++++++++-- .../PublishProviderEnvVariablesCommand.php | 4 ++ stubs/gateway_sa.env.stub | 7 ++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 stubs/gateway_sa.env.stub diff --git a/README.md b/README.md index 586d697..c891121 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,16 @@ [![Latest Version on Packagist](https://img.shields.io/packagist/v/robust-tools/resala.svg?style=flat-square)](https://packagist.org/packages/robust-tools/resala) [![Total Downloads](https://img.shields.io/packagist/dt/robust-tools/resala.svg?style=flat-square)](https://packagist.org/packages/robust-tools/resala) -**Resala** is a PHP & Laravel Package, (Designed to add support to your laravel or just native php app for sending SMS using local operators in the MENA region Like `Vodafone`, `Infopib`, `Conneckio`, `VectoryLink`). +**Resala** is a PHP & Laravel Package, (Designed to add support to your laravel or just native php app for sending SMS using local operators in the MENA region Like `Vodafone`, `Infobip`, `Connekio`, `VectoryLink`, `Gateway SA`, `BrandEncode`). **Resala** not just tied to use inside Laravel you can hook it up in any php code ## Supported Providers - Vodafone SMS Gateway - Connekio SMS Gateway -- InfoPib SMS Gateway +- Infobip SMS Gateway - Vectory Link SMS Gateway +- Gateway SA SMS Gateway +- BrandEncode SMS Gateway ## Installation @@ -82,6 +84,24 @@ return [ 'sender_name' => env('VECTORY_LINK_SENDER_NAME', 'Vectory Link'), 'lang' => env('VECTORY_LINK_LANG', 'E') ], + + 'gateway_sa' => [ + 'end_point' => env('GATEWAYSA_END_POINT', 'http://REST.GATEWAY.SA/api/SendSMS'), + 'api_id' => env('GATEWAYSA_API_ID'), + 'api_password' => env('GATEWAYSA_API_PASSWORD'), + 'sms_type' => env('GATEWAYSA_SMS_TYPE', 'T'), + 'encoding' => env('GATEWAYSA_ENCODING', 'T'), + 'sender_id' => env('GATEWAYSA_SENDER_ID'), + 'templateid' => env('GATEWAYSA_TEMPLATE_ID'), + ], + + 'brandencode' => [ + 'end_point' => env('BRANDENCODE_END_POINT'), + 'username' => env('BRANDENCODE_USERNAME'), + 'password' => env('BRANDENCODE_PASSWORD'), + 'sender_name' => env('BRANDENCODE_SENDER_NAME', 'Brandencode'), + 'lang' => env('BRANDENCODE_LANG', 'E') + ], ], /* @@ -96,7 +116,9 @@ return [ 'vodafone' => VodafoneDriver::class, 'connekio' => ConnekioDriver::class, 'infobip' => InfobipDriver::class, - 'vectory_link' => VectoryLink::class + 'vectory_link' => VectoryLinkDriver::class, + 'gateway_sa' => GatewaySA::class, + 'brandencode' => BrandEncodeDriver::class ], ]; ``` @@ -122,6 +144,16 @@ This adds `vectory_link` environment variables to your .env file. php artisan resala:make vectory_link ``` +This adds `brandencode` environment variables to your .env file. +```bash +php artisan resala:make brandencode +``` + +This adds `gateway_sa` environment variables to your .env file. +```bash +php artisan resala:make gateway_sa +``` + ## Usage ``` php diff --git a/src/Console/PublishProviderEnvVariablesCommand.php b/src/Console/PublishProviderEnvVariablesCommand.php index a5edf96..074375f 100644 --- a/src/Console/PublishProviderEnvVariablesCommand.php +++ b/src/Console/PublishProviderEnvVariablesCommand.php @@ -86,5 +86,9 @@ private function getStubContent(): string if ($this->argument('driver') == "brandencode") { return File::get(__DIR__ . "/../../stubs/brandencode.env.stub"); } + + if ($this->argument('driver') == "gateway_sa") { + return File::get(__DIR__ . "/../../stubs/gateway_sa.env.stub"); + } } } diff --git a/stubs/gateway_sa.env.stub b/stubs/gateway_sa.env.stub new file mode 100644 index 0000000..0a5b51d --- /dev/null +++ b/stubs/gateway_sa.env.stub @@ -0,0 +1,7 @@ +GATEWAYSA_END_POINT=http://REST.GATEWAY.SA/api/SendSMS +GATEWAYSA_API_ID= +GATEWAYSA_API_PASSWORD= +GATEWAYSA_SMS_TYPE=T +GATEWAYSA_ENCODING=T +GATEWAYSA_SENDER_ID= +GATEWAYSA_TEMPLATE_ID= From 5f12ce2d3ebe546c0c8201dd8088ea988b3fe3bd Mon Sep 17 00:00:00 2001 From: omarabdelaziz Date: Mon, 3 Aug 2026 12:56:24 +0300 Subject: [PATCH 2/4] chore: bump php + illuminate versions to support php8.3 and laravel 12 --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 66700b9..08e7214 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,16 @@ } ], "require": { - "php": "^8.1|8.2", + "php": "^8.1|^8.2|^8.3", "ext-dom": "*", "ext-json": "*", "ext-simplexml": "*", "guzzlehttp/guzzle": "^7.5", - "illuminate/support": "^9.0|^10|^11.0" + "illuminate/support": "^9.0|^10.0|^11.0|^12.0" }, "require-dev": { - "orchestra/testbench": "^8.0.8", - "phpunit/phpunit": "^10.0" + "orchestra/testbench": "^8.0|^9.0|^10.0", + "phpunit/phpunit": "^10.0|^11.0" }, "autoload": { "psr-4": { From 4b6e66079011bb5ddc3eefd780de0bdbcb05fa67 Mon Sep 17 00:00:00 2001 From: omarabdelaziz Date: Mon, 3 Aug 2026 12:57:44 +0300 Subject: [PATCH 3/4] lint: comply with PSR12 --- tests/SMSDriverFactoryTest.php | 4 +++- tests/SMSTest.php | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/SMSDriverFactoryTest.php b/tests/SMSDriverFactoryTest.php index 7d4d882..2296949 100644 --- a/tests/SMSDriverFactoryTest.php +++ b/tests/SMSDriverFactoryTest.php @@ -1,4 +1,5 @@ shouldReceive('create') ->once() - ->andReturn(\Mockery::mock(SMSDriverInterface::class));; + ->andReturn(\Mockery::mock(SMSDriverInterface::class)); + ; SMSDriverFactory::create(); } diff --git a/tests/SMSTest.php b/tests/SMSTest.php index 68ee801..db42ae9 100644 --- a/tests/SMSTest.php +++ b/tests/SMSTest.php @@ -1,4 +1,5 @@ sendSMS(); $this->assertInstanceOf(SMSDriverResponseInterface::class, $sms); - } private function createMockXMLResponse(): self From 2582ee13e98db9a060dc9ebfa55e5609a2009e47 Mon Sep 17 00:00:00 2001 From: omarabdelaziz Date: Mon, 3 Aug 2026 13:27:15 +0300 Subject: [PATCH 4/4] fix: apply php-cs-fixer style fixes --- src/Abstracts/Driver.php | 1 - .../PublishProviderEnvVariablesCommand.php | 1 - src/Contracts/SMSDriverInterface.php | 1 - src/Contracts/SMSDriverResponseInterface.php | 1 - src/Drivers/BrandEncodeDriver.php | 4 +--- src/Drivers/ConnekioDriver.php | 20 +++++++++---------- src/Drivers/GatewaySA.php | 4 +--- src/Drivers/InfobipDriver.php | 4 +--- src/Drivers/VectoryLinkDriver.php | 15 +++++++------- src/Drivers/VodafoneDriver.php | 8 ++------ src/Facades/SMS.php | 1 - src/Factories/SMSDriverFactory.php | 1 - src/Response/BrandEncodeResponse.php | 1 - src/Response/ConnekioResponse.php | 1 - src/Response/GatewaySAResponse.php | 1 - src/Response/InfobipResponse.php | 1 - src/Response/VectoryLinkResponse.php | 18 ++++++++--------- src/Response/VodafoneResponse.php | 1 - src/SMS.php | 4 +--- src/SMSServiceProvider.php | 1 - src/Support/Config.php | 1 - src/Support/ConfigRepository.php | 1 - src/Support/HTTP.php | 1 - src/Support/VodafonePayloadBuilder.php | 1 - 24 files changed, 31 insertions(+), 62 deletions(-) diff --git a/src/Abstracts/Driver.php b/src/Abstracts/Driver.php index 348fcc4..1873068 100644 --- a/src/Abstracts/Driver.php +++ b/src/Abstracts/Driver.php @@ -1,5 +1,4 @@ toMultiple($this->recipients) ? $payload['mobile_list'] = array_map( - fn($recipient) => ['msisdn' => $this->formatPhoneNumber($recipient)], + fn ($recipient) => ['msisdn' => $this->formatPhoneNumber($recipient)], $this->recipients ) : $payload["msisdn"] = $this->formatPhoneNumber($this->recipients); @@ -86,13 +84,6 @@ protected function headers(): array ]; } - private function endpoint(): string - { - return $this->toMultiple($this->recipients) - ? $this->batchSmsEndPoint - : $this->singleSmsEndPoint; - } - protected function formatPhoneNumber($phoneNumber): string { if (substr($phoneNumber, 0, 1) == '0') { @@ -101,4 +92,11 @@ protected function formatPhoneNumber($phoneNumber): string return $phoneNumber; } + + private function endpoint(): string + { + return $this->toMultiple($this->recipients) + ? $this->batchSmsEndPoint + : $this->singleSmsEndPoint; + } } diff --git a/src/Drivers/GatewaySA.php b/src/Drivers/GatewaySA.php index 7197aa2..5e363c4 100644 --- a/src/Drivers/GatewaySA.php +++ b/src/Drivers/GatewaySA.php @@ -1,10 +1,8 @@ 'application/json', + ]; + } + private function generateGuid(): string { $data = random_bytes(16); @@ -80,11 +86,4 @@ private function generateGuid(): string return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } - - protected function headers(): array - { - return [ - 'Content-Type' => 'application/json', - ]; - } } diff --git a/src/Drivers/VodafoneDriver.php b/src/Drivers/VodafoneDriver.php index aa88e17..7c9e917 100644 --- a/src/Drivers/VodafoneDriver.php +++ b/src/Drivers/VodafoneDriver.php @@ -1,14 +1,10 @@ status = $this->parseStatus($contents); } - private function parseStatus(string $contents): int - { - if ($contents === '' || !is_numeric($contents)) { - return self::STATUS_OTHER_ERROR; - } - return (int) $contents; - } - public function success(): bool { return $this->status === self::STATUS_SUCCESS; @@ -76,4 +67,13 @@ public function body(): string return $messages[$this->status] ?? 'Something wrong happened'; } + + private function parseStatus(string $contents): int + { + if ($contents === '' || !is_numeric($contents)) { + return self::STATUS_OTHER_ERROR; + } + + return (int) $contents; + } } diff --git a/src/Response/VodafoneResponse.php b/src/Response/VodafoneResponse.php index e62c5f6..aa427d1 100644 --- a/src/Response/VodafoneResponse.php +++ b/src/Response/VodafoneResponse.php @@ -1,5 +1,4 @@