This package provides a convenient way to interact with the Studizz API in Laravel applications.
You can install the package via composer:
composer require amphibee/studizz
Publish the configuration file:
php artisan vendor:publish --provider="AmphiBee\Studizz\Providers\StudizzServiceProvider"
Add your Studizz API credentials to your .env
file:
STUDIZZ_API_KEY=your_api_key
STUDIZZ_BASE_URL=https://sandbox.studizz.fr/api
This package provides several services: ContactService
, FormationService
, and CampusService
. You can access these services through their respective facades.
Each service provides a getRawResponse()
method that returns the raw API response for debugging purposes:
use AmphiBee\Studizz\Facades\Contact;
use Illuminate\Support\Facades\Log;
try {
$contactData = [
'firstname' => 'John',
'lastname' => 'Doe',
// ... autres données
];
$contactDto = new ContactDto($contactData);
$newContact = Contact::create($contactDto);
// Log the raw response
Log::channel('api')->info('Studizz API Response', [
'response' => Contact::getRawResponse()
]);
} catch (\Exception $e) {
Log::channel('api')->error('Studizz API Error', [
'message' => $e->getMessage(),
'trace' => $e->getTraceAsString()
]);
}
To enable API logging, add this to your config/logging.php
:
'channels' => [
// ... autres canaux
'api' => [
'driver' => 'daily',
'path' => storage_path('logs/api.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
],
The logs will be stored in storage/logs/api.log
with this format:
[2024-03-14 10:30:00] local.INFO: Studizz API - Données d'entrée {"data":{"firstname":"John","lastname":"Doe",...}}
[2024-03-14 10:30:01] local.INFO: Studizz API - Réponse {"response":{"id":"123",...}}
use AmphiBee\Studizz\Facades\Studizz;
use AmphiBee\Studizz\Dto\ContactDto;
$contactData = [
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'phone' => '+33612345678',
'degreeLevel' => 0,
'teamAssigned' => '63e26d24383062596b949cff',
'interestedFormations' => ['5bdeb73136da49690e78c510'],
'rgpd' => true,
'cV' => [
'file' => file_get_contents('/path/to/file.pdf'),
'filename' => 'file.pdf',
];
];
$contactDto = new AmphiBee\Studizz\Dto\ContactDto($contactData);
$newContact = AmphiBee\Studizz\Facades\Contact::create($contactDto);
$fields = AmphiBee\Studizz\Facades\Contact::getFields();
$formations = AmphiBee\Studizz\Facades\Formation::getAll();
$formation = AmphiBee\Studizz\Facades\Campus::getAll();
To run the tests for this package, use the following command:
./vendor/bin/pest
Please see CONTRIBUTING.md for details.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.