diff --git a/app/Http/Controllers/Welcome.php b/app/Http/Controllers/Welcome.php index 2311485..b7da562 100644 --- a/app/Http/Controllers/Welcome.php +++ b/app/Http/Controllers/Welcome.php @@ -3,7 +3,6 @@ use Illuminate\Support\Facades\Cache; use Livewire\Component; -use Rstacode\Otpiq\DTOs\SmsData; use Rstacode\Otpiq\Facades\Otpiq; use WireUi\Traits\WireUiActions; @@ -19,12 +18,18 @@ public function setApiKey() $this->validate([ 'apiKey' => 'required|string|min:20', ]); + + if (strpos($this->apiKey, 'sk_live_') !== 0) { + $this->addError('apiKey', 'API Key is invalid!'); + return; + } Cache::put('otpiq_api_key', $this->apiKey, now()->addHours(24)); $this->reset('apiKey'); $this->dispatch('notify', [ 'message' => 'API Key set successfully!', 'type' => 'success', ]); + } public function removeApiKey() @@ -59,12 +64,13 @@ public function save() { $this->callApiKey(); try { - $response = Otpiq::sendSms(new SmsData( - phoneNumber: $this->phoneNumber, - smsType: 'verification', - provider: $this->provider, - verificationCode: $this->verificationCode - )); + $response = Otpiq::sendSms([ + 'phoneNumber' => $this->phoneNumber, + 'smsType' => 'verification', + 'verificationCode' => $this->verificationCode, + 'provider' => $this->provider, + ]); + return dd($response); } catch (\Exception $exception) { return dd($exception->getMessage()); @@ -74,12 +80,15 @@ public function save2() { $this->callApiKey(); try { - $response = Otpiq::sendSms(new SmsData( - phoneNumber: $this->phoneNumber, - smsType: 'custom', - customMessage: $this->customMessage, - senderId: $this->senderId, - )); + $response = Otpiq::sendSms([ + 'phoneNumber' => $this->phoneNumber, + 'smsType' => 'custom', + 'customMessage' => $this->customMessage, + 'senderId' => $this->senderId, + 'provider' => 'sms', // Required for custom messages + ]); + + return dd($response); } catch (\Exception $exception) { return dd($exception->getMessage()); } diff --git a/composer.json b/composer.json index 474f7ed..40cc82c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "laravel/framework": "^11.31", "laravel/tinker": "^2.9", "livewire/livewire": "^3.5", - "rstacode/otpiq": "^1.0", + "rstacode/otpiq": "^1.2", "wireui/wireui": "^2.2" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 4f000b5..b66afab 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5169248da8246a4174fa7e8b0d526e1c", + "content-hash": "6d47c8005ba068e1d256dcccbf9e7247", "packages": [ { "name": "blade-ui-kit/blade-icons", @@ -3529,16 +3529,16 @@ }, { "name": "rstacode/otpiq", - "version": "v1.0.3", + "version": "v1.2", "source": { "type": "git", "url": "https://github.com/Rstacode/otpiq.git", - "reference": "1faac3d576c4ed240fa98bc94280d84214505f7c" + "reference": "356ab1614a6995c49141869c9e7b3a739ae42568" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Rstacode/otpiq/zipball/1faac3d576c4ed240fa98bc94280d84214505f7c", - "reference": "1faac3d576c4ed240fa98bc94280d84214505f7c", + "url": "https://api.github.com/repos/Rstacode/otpiq/zipball/356ab1614a6995c49141869c9e7b3a739ae42568", + "reference": "356ab1614a6995c49141869c9e7b3a739ae42568", "shasum": "" }, "require": { @@ -3547,8 +3547,8 @@ "php": "^8.1" }, "require-dev": { - "orchestra/testbench": "^9.9", - "phpunit/phpunit": "^11.5" + "mockery/mockery": "^1.5", + "phpunit/phpunit": "^10.0" }, "type": "library", "extra": { @@ -3562,6 +3562,9 @@ } }, "autoload": { + "files": [ + "config/otpiq.php" + ], "psr-4": { "Rstacode\\Otpiq\\": "src/" } @@ -3593,7 +3596,7 @@ "issues": "https://github.com/rstacode/otpiq/issues", "source": "https://github.com/rstacode/otpiq" }, - "time": "2025-01-30T19:05:56+00:00" + "time": "2025-01-31T21:11:29+00:00" }, { "name": "symfony/clock", @@ -7305,16 +7308,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.5", + "version": "11.5.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "b9a975972f580c0491f834eb0818ad2b32fd8bba" + "reference": "3c3ae14c90f244cdda95028c3e469028e8d1c02c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b9a975972f580c0491f834eb0818ad2b32fd8bba", - "reference": "b9a975972f580c0491f834eb0818ad2b32fd8bba", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3c3ae14c90f244cdda95028c3e469028e8d1c02c", + "reference": "3c3ae14c90f244cdda95028c3e469028e8d1c02c", "shasum": "" }, "require": { @@ -7386,7 +7389,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.6" }, "funding": [ { @@ -7402,7 +7405,7 @@ "type": "tidelift" } ], - "time": "2025-01-29T14:01:11+00:00" + "time": "2025-01-31T07:03:30+00:00" }, { "name": "sebastian/cli-parser", diff --git a/config/otpiq.php b/config/otpiq.php index 92b383a..046551b 100644 --- a/config/otpiq.php +++ b/config/otpiq.php @@ -1,15 +1,6 @@ env('OTPIQ_API_KEY'), + 'api_key' => env('OTPIQ_API_KEY', ''), + 'base_url' => env('OTPIQ_BASE_URL', 'https://api.otpiq.com/api/'), ];