Skip to content

Commit

Permalink
Added Updates Notification Features.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiten14 committed Nov 16, 2024
1 parent 2a268ee commit 73b9fbd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ All notable changes to `jitone-ai` will be documented in this file.
## v0.1.5 - 2024-10-21

- Added support for openai-php/laravel 0.10 & above.

## v0.1.6 - 2024-11-16

- Added Updates Notification Features.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
## Support Me

Fuel the future of JitoneAI with your support! By joining as a subscriber, you’re not only backing an open-source tool that brings AI magic to Filament forms but also unlocking exclusive benefits just for you. Get priority, personalized support whenever you need it and access a developer’s guide filled with insights to customize and extend the package for your unique projects. Your subscription, starting at just $15/month or $150/year, helps keep JitoneAI evolving and accessible to all. Let’s build powerful tools together—thank you for supporting innovation!

[Join Now](https://buymeacoffee.com/jitendriyan/membership)

## Installation
Expand Down Expand Up @@ -174,6 +175,7 @@ AIFileUpload::make('image')
Jitone AI follows semantic versioning:

- **v0.1.5**: Added support for openai-php/laravel 0.10 & above.
- **v0.1.6**: Added Updates Notification Features.

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Expand Down
58 changes: 58 additions & 0 deletions src/Commands/JitoneAiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
namespace Jiten14\JitoneAi\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Validator;

class JitoneAiCommand extends Command
{
public $signature = 'jitone-ai:install';

public $description = 'Install and set up JitoneAi package';

private $apiEndpoint = 'https://support.jiten.one/api/subscribe';

public function handle(): int
{
$this->info('Setting up JitoneAi package...');
Expand All @@ -26,6 +30,11 @@ public function handle(): int
// Create storage link
$this->call('storage:link');

// Email subscription section
if ($this->confirm('Would you like to receive free package updates and notifications via email?', false)) {
$this->handleEmailSubscription();
}

$this->info('JitoneAi package has been set up successfully!');
$this->info('Please review the configuration file at config/jitone-ai.php');

Expand All @@ -45,4 +54,53 @@ public function handle(): int

return self::SUCCESS;
}

private function handleEmailSubscription(): void
{
$this->info('📧 Email Subscription Information:');
$this->line('- Your email will only be used for package updates and important notifications');
$this->line('- We will never share your email with third parties');
$this->line('- You can unsubscribe at any time');

$name = $this->ask('Please enter your name:');
$email = $this->ask('Please enter your email address:');

if (empty($email)) {
$this->info('No email provided. Skipping subscription.');
return;
}

// Validate email
$validator = Validator::make(['email' => $email], [
'email' => 'required|email'
]);

if ($validator->fails()) {
$this->error('Invalid email format. Skipping subscription.');
return;
}

// Confirm subscription with explicit consent
if (!$this->confirm("Do you consent to receive package updates and notifications at {$email}?", true)) {
$this->info('Subscription cancelled.');
return;
}

try {
// Send email to your API or storage system
$response = Http::post($this->apiEndpoint, [
'name' => $name,
'email' => $email,
]);

if ($response->successful()) {
$this->info('✅ Successfully subscribed to package updates!');
$this->line('You can unsubscribe at any time by visiting: https://support.jiten.one/unsubscribe');
} else {
$this->error('Failed to subscribe. Please try again later or contact support.');
}
} catch (\Exception $e) {
$this->error('An error occurred while processing your subscription.');
}
}
}

0 comments on commit 73b9fbd

Please sign in to comment.