amaizing-company / cannaleo-client-laravel
Cannaleo api client package for laravel.
Fund package maintenance!
amaizing-company
Requires
- php: ^8.3||^8.4
- illuminate/contracts: ^11.0||^12.0
- prinsfrank/standards: ^3.12
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2025-05-13 14:30:54 UTC
README
This package allows laravel applications to communicate with cannaleo's api services.
Installation
You can install the package via composer:
composer require amaizing-company/cannaleo-client-laravel
You can publish and run the migrations with:
php artisan vendor:publish --tag="cannaleo-client-laravel-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="cannaleo-client-laravel-config"
This is the contents of the published config file:
return [ 'base_url' => 'https://api.curobo.de/api/v1', 'api_key' => env('CANNALEO_API_KEY'), 'default_currency' => CurrencyAlpha3::Euro, 'table_prefix' => 'cannaleo_', ];
Configuration
Set your Cannaleo API Key inside your .env file:
CANNALEO_API_KEY=YOUR_API_KEY
Prepare models
If you want to use the package database feature, you need to define some models they will interact with package services.
Customer model
use AmaizingCompany\CannaleoClient\Api\DataObjects\RequestObjects\AddressObject; use AmaizingCompany\CannaleoClient\Contracts\Models\CannaleoCustomer; use AmaizingCompany\CannaleoClient\Concerns\IsCannaleoCustomer; class CustomerModel extends Model implements CannaleoCustomer { use IsCannaleoCustomer; public function getFirstName(): string { // Return first name of the customer. } public function getLastName(): string { // Return last name of the customer. } public function getEmail(): string { // Return the email address of the customer. } public function getPhone(): string { // Return the phone number of the customer. } public function getHomeAddress(): AddressObject { // Return the customer's address as an AddressObject. } public function getDeliveryAddress(): AddressObject { // Return the customer's address as an AddressObject. } }
Doctor model
use AmaizingCompany\CannaleoClient\Contracts\Models\CannaleoDoctor; use AmaizingCompany\CannaleoClient\Concerns\IsCannaleoDoctor; class DoctorModel extends Model implements CannaleoDoctor { use IsCannaleoDoctor; public function getName(): string { // Return the full name of the doctor. } public function getEmail(): string { // Return the email address of the doctor. } public function getPhone(): string { // Return the phone number of the doctor. } }
Order model
use AmaizingCompany\CannaleoClient\Contracts\Models\CannaleoOrder; use AmaizingCompany\CannaleoClient\Concerns\IsCannaleoOrder; class OrderModel extends Model implements CannaleoOrder { use IsCannaleoOrder; }
Prescription model
use AmaizingCompany\CannaleoClient\Contracts\Models\CannaleoPrescription; use AmaizingCompany\CannaleoClient\Concerns\IsCannaleoPrescription; use Illuminate\Support\Carbon; class OrderModel extends Model implements CannaleoPrescription { use IsCannaleoPrescription; public function getFileContents(): string { // Return the file contents as raw string. } public function getSignatureCity(): string { // Return the city where the prescription was signed. } public function getSignatureDate(): Carbon { // Return the date of the signature. } }
Usage
Synchronizing data
To synchronize data from the api with your applications database, you need to call the sync services. Before sync the product catalog, always run the pharmacies sync service. Otherwise some products could maybe not related to pharmacies.
Pharmacies
use AmaizingCompany\CannaleoClient\Facades\CannaleoClient CannaleoClient::syncPharmacies();
Product Catalog
use AmaizingCompany\CannaleoClient\Facades\CannaleoClient CannaleoClient::syncCatalog();
Transferring a prescription to a pharmacy
use AmaizingCompany\CannaleoClient\Facades\CannaleoClient use AmaizingCompany\CannaleoClient\Models\Product; use AmaizingCompany\CannaleoClient\Services\PrescriptionTransactionService; $productModel = Product::query()->first(); // Build the products collection $products = \Illuminate\Support\Collection::make(); $products->add($productModel->getProductObject(quantity: 1)) CannaleoClient::sendPrescription( $pharmacy, // Pharmacy Model $prescription, // Prescription Model $customer, // Customer Model $doctor, // Doctor Model $order, // Order Model $products );
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.