### Install laravel-demio with Composer Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Install the package via Composer. Run this in your Laravel project root. ```bash composer require jeffersongoncalves/laravel-demio ``` -------------------------------- ### DemioClient usage examples Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Basic usage of the DemioClient static methods: ping, events, event, eventDate, register, and participants. The events method accepts 'upcoming', 'past', or 'all' as a filter. ```php use JeffersonGoncalves\Demio\DemioClient; // Health check DemioClient::ping(); // List events $events = DemioClient::events(); $upcoming = DemioClient::events('upcoming'); // upcoming|past|all // Fetch a single event / date $event = DemioClient::event('event-id'); $date = DemioClient::eventDate('event-id', 'date-id'); // Register a participant DemioClient::register('event-id', 'Jane Doe', 'jane@example.com', dateId: 'date-id', refUrl: 'https://example.com'); // List participants for a date $participants = DemioClient::participants('date-id'); ``` -------------------------------- ### Run static analysis with composer analyse Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Run static analysis. ```bash composer analyse ``` -------------------------------- ### Run tests, static analysis, and formatting Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Development commands: run Pest tests, PHPStan static analysis at level 5 with Larastan, and Pint code formatting with the Laravel preset. ```bash # Run tests vendor/bin/pest # Run static analysis (PHPStan level 5 + Larastan) vendor/bin/phpstan analyse # Format code (Pint, Laravel preset) vendor/bin/pint ``` -------------------------------- ### Format code with composer format Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Run code formatting. ```bash composer format ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Run the test suite. ```bash composer test ``` -------------------------------- ### Configure Demio API credentials in .env Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Add these environment variables to your .env file. Obtain both values from my.demio.com/integrations/api. ```env DEMIO_API_KEY=your-api-key DEMIO_API_SECRET=your-api-secret ``` -------------------------------- ### Publish demio-config file Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Optionally publish the package's config file to your application's config directory. ```bash php artisan vendor:publish --tag="demio-config" ``` -------------------------------- ### Demio config options Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Default configuration file. The base_url defaults to the Demio API v1 endpoint and timeout defaults to 8 seconds. ```php // config/demio.php return [ 'api_key' => env('DEMIO_API_KEY'), 'api_secret' => env('DEMIO_API_SECRET'), 'base_url' => env('DEMIO_BASE_URL', 'https://my.demio.com/api/v1'), 'timeout' => (int) env('DEMIO_TIMEOUT', 8), ]; ``` -------------------------------- ### Publish demio-config with Artisan Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Publish the package configuration file to config/demio.php. The publish tag is demio-config. ```bash php artisan vendor:publish --tag=demio-config ``` -------------------------------- ### Demio package namespace structure Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Namespace structure of the package. DemioServiceProvider registers the config file only, DemioClient is the static REST client, and DemioAuthenticationException is thrown on a 401. ```text JeffersonGoncalves\Demio\ DemioServiceProvider # Registers the config file only DemioClient # Static REST client Exceptions\ DemioAuthenticationException # Thrown on a 401 ``` -------------------------------- ### Configure Demio package with spatie/laravel-package-tools Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Minimal service provider using spatie/laravel-package-tools. The package short name is 'demio', so the published config lives at config/demio.php and the publish tag is demio-config. ```php public function configurePackage(Package $package): void { $package ->name('demio') ->hasConfigFile(); } ``` -------------------------------- ### Set Demio environment variables Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Environment variables for the Demio client. The base URL defaults to https://my.demio.com/api/v1 and timeout to 8 seconds. ```env DEMIO_API_KEY=your-api-key DEMIO_API_SECRET=your-api-secret DEMIO_BASE_URL=https://my.demio.com/api/v1 DEMIO_TIMEOUT=8 ``` -------------------------------- ### DemioClient public API methods Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Public API of DemioClient. Methods include ping, events (with optional 'upcoming'|'past'|'all' filter), event, eventDate, register (with named dateId and refUrl parameters), and participants. Return types are annotated in comments. ```php use JeffersonGoncalves\Demio\DemioClient; DemioClient::ping(); // array|null DemioClient::events(); // list> DemioClient::events('upcoming'); // 'upcoming'|'past'|'all' DemioClient::event('event-id'); // array|null DemioClient::eventDate('event-id', 'date-id'); // array|null DemioClient::register('event-id', 'Jane Doe', 'jane@example.com', dateId: 'date-id', refUrl: 'https://example.com'); DemioClient::participants('date-id'); // list> ``` -------------------------------- ### Handle DemioAuthenticationException Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/README.md Handles authentication failures. Catch DemioAuthenticationException when the API key or secret is missing, wrong, or revoked. ```php use JeffersonGoncalves\Demio\Exceptions\DemioAuthenticationException; try { $events = DemioClient::events(); } catch (DemioAuthenticationException $e) { // Api-Key/Api-Secret is missing, wrong, or revoked. } ``` -------------------------------- ### Assert DemioAuthenticationException on 401 Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Pest test that asserts a 401 response from the ping endpoint throws DemioAuthenticationException. Use this to verify authentication detection. ```php use JeffersonGoncalves\Demio\Exceptions\DemioAuthenticationException; it('throws on a 401', function () { Http::fake([ 'my.demio.com/api/v1/ping' => Http::response('', 401), ]); expect(fn () => DemioClient::ping())->toThrow(DemioAuthenticationException::class); }); ``` -------------------------------- ### Throw DemioAuthenticationException on 401 Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Authentication detection inside the shared request() helper, outside the network try/catch. The exception propagates to the caller instead of being swallowed and logged as a generic fetch failure. ```php if ($response->status() === 401) { throw new DemioAuthenticationException; } ``` -------------------------------- ### Mock Demio events response with Http::fake() Source: https://github.com/jeffersongoncalves/laravel-demio/blob/master/resources/boost/skills/demio-development/SKILL.md Pest test that mocks the Demio events endpoint with Http::fake() and asserts the client returns the expected array. Use this pattern for testing Demio API interactions. ```php use Illuminate\Support\Facades\Http; use JeffersonGoncalves\Demio\DemioClient; it('lists events', function () { Http::fake([ 'my.demio.com/api/v1/events*' => Http::response([ ['id' => '1', 'name' => 'Webinar A'], ], 200), ]); expect(DemioClient::events())->toBe([ ['id' => '1', 'name' => 'Webinar A'], ]); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.