ahid-technologies / leopards-courier
Laravel package for integrating with Leopards Courier API
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ahid-technologies/leopards-courier
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0|^10.0
README
A Laravel package for integrating with Leopards Courier API services.
Installation
You can install the package via composer:
composer require ahid/leopards-courier
Changelog
Version 1.1.0
- Validation Improvements: Eased validation for track_numbers and cn_numbers to be more flexible
- Track numbers now accept any string between 3-20 characters (previously required exactly 10 alphanumeric characters)
- CN numbers now accept any string between 3-20 characters (previously required specific format patterns)
- This change provides better compatibility with various tracking number formats
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="Ahid\LeopardsCourier\AhidLeopardsServiceProvider"
Add your Leopards Courier API credentials to your .env file:
LEOPARDS_API_KEY=your_api_key
LEOPARDS_API_PASSWORD=your_api_password
LEOPARDS_API_ENVIRONMENT=staging # or production
Usage
Get All Cities
use Ahid\LeopardsCourier\Facades\LeopardsCourier; // Get all cities $cities = LeopardsCourier::getAllCities();
Book a Packet
use Ahid\LeopardsCourier\Facades\LeopardsCourier; // Book a packet $bookingData = [ 'booked_packet_weight' => 2000, // Weight in grams 'booked_packet_no_piece' => 1, 'booked_packet_collect_amount' => 2500, 'booked_packet_order_id' => 'ORD-12345', 'origin_city' => 'self', // or city ID 'destination_city' => 789, // City ID from getAllCities 'shipment_name_eng' => 'self', 'shipment_email' => 'self', 'shipment_phone' => 'self', 'shipment_address' => 'self', 'consignment_name_eng' => 'John Doe', 'consignment_email' => 'john@example.com', 'consignment_phone' => '03001234567', 'consignment_address' => '123 Main St, Lahore', 'special_instructions' => 'Handle with care' ]; $booking = LeopardsCourier::bookPacket($bookingData);
Available Methods
getAllCities(): Get a list of all available cities with origin and destination statusbookPacket(array $data): Book a new shipment
Error Handling
The package throws LeopardsApiException when the API returns an error. You can catch this exception to handle API errors:
use Ahid\LeopardsCourier\Exceptions\LeopardsApiException; try { $cities = LeopardsCourier::getAllCities(); } catch (LeopardsApiException $e) { // Handle API error echo $e->getMessage(); }
License
The MIT License (MIT). Please see License File for more information.