PHP SDK
This PHP SDK fully adheres to PHP PSR-7 standards, undergoes rigorous testing with Pest, and successfully clears PHPStan level 9 checks. JSON responses are seamlessly hydrated into strongly-typed PHP objects. Additionally, we integrate the Illuminate Collections package for improved data interaction. If you're acquainted with Laravel, Symfony or any other modern PHP framework, we're confident you'll find it a delightful experience to use.
Installation
To install the SDK, you can use Composer:
composer require covertier/sdk
Initializing the Client
First, you need to initialize the client with your API key:
use Covertier\Sdk\Client;
use Covertier\Sdk\Enums\Environment;
$client = Client::init([
'environment' => Environment::SANDBOX,
'apiKey' => 'YOUR_API_KEY_HERE'
]);
Replace 'YOUR_API_KEY_HERE' with your actual API key.
Getting Vehicle Makes
If you don't need to obtain a vehicle valuation or fetch listings of makes, models, and trims, you may skip to the Getting Packages section.
To retrieve a list of vehicle makes, use the following code:
$vehicleMakeResource = $client->vehicleMake();
$makes = $vehicleMakeResource->all();
The $makes variable will contain a collection of vehicle make objects.
Getting Vehicle Models
To retrieve a list of vehicle models for a specific make and year, use the following code:
$vehicleModelResource = $client->vehicleModelResource();
$models = $vehicleModelResource->getByMakeIdAndYear(MAKE_ID, YEAR);
Replace MAKE_ID with the ID of the desired make, and YEAR with the desired year. The $models variable will contain a collection of vehicle model objects for the specified make and year.
Getting Vehicle Trims
To retrieve a list of vehicle trims for a specific model and year, use the following code:
$vehicleTrimResource = $client->vehicleTrimResource();
$trims = $vehicleTrimResource->getByModelIdAndYear(MODEL_ID, YEAR);
Replace MODEL_ID with the ID of the desired model, and YEAR with the desired year. The $trims variable will contain a collection of vehicle trim objects for the specified model and year.
You can also retrieve a specific trim by its Vehicle Identification Number (VIN):
$trim = $vehicleTrimResource->getByVin(VIN);
Replace VIN with the desired VIN. The $trim variable will contain the trim object for the specified VIN.
For more detailed documentation and examples, please refer to the official Covertier SDK documentation.
Getting Packages
List of available packages and coverages from the selected insurance company.
use Covertier\Definitions\Enums\{
InsuranceCompany,
PolicyType
};
$packages = $client->packageResource()
->getByCompanyIdAndPolicyType(
InsuranceCompany::QUALITAS,
PolicyType::MX_TOURIST
);
Generating Tourist Quotes
Tourist policy quotes may be generated with a package ID and either a trim ID, or a value and year:
use Covertier\Definitions\DataObjects\Submitting\Policy\VehicleUS;
use Covertier\Sdk\DataObjects\Submitting\Policy\TouristQuote;
use Covertier\Definitions\Enums\InsuranceCompany;
// Example 1: Using a trim, so the server can estimate de valuation automatically.
$vehicle = new VehicleUS(
trimId: TRIM_ID_HERE
);
// Example 2: Providing manually the valuation of the vehicle.
$vehicle = new VehicleUS(
value: VALUE_HERE,
year: YEAR_HERE,
);
$touristQuoteData = new TouristQuote(
vehicle: $vehicle,
insuranceCompanyId: InsuranceCompany::QUALITAS,
packageId: PACKAGE_ID
);
$quote = $quoteResource->create($touristQuoteData);
Replace TRIM_ID with the ID of the desired trim, and PACKAGE_ID with the desired package id that you previously fetched.
Issuing Tourist Policies
A tourist policy can be issued as shown in the following example:
use Covertier\Sdk\DataObjects\Submitting\Policy\TouristPolicy;
use Covertier\Definitions\DataObjects\Submitting\Policy\{
AddressUS,
PolicyHolderUS,
VehicleUS,
Package
};
use Covertier\Definitions\Enums\{
InsuranceCompany,
PolicyType,
PersonalIdType,
ResidenceTypeInMexico,
StateUS
};
$address = new AddressUS(
line1: {ADDRESS},
district: {DISTRICT},
zipCode: {ZIP_CODE},
city: {CITY},
state: StateUS::CA
);
$policyHolder = new PolicyHolderUS(
name: {POLICY_HOLDER_NAME},
lastName: {POLICY_HOLDER_LAST_NAME},
birthdate: DateTimeImmutable::createFromFormat('d/m/Y', {POLICY_HOLDER_BIRTHDATE}),
identificationNumber: {POLICY_HOLDER_IDENTIFICATION_NUMBER},
personalIdType: PersonalIdType::NIC,
mobileNumber: {POLICY_HOLDER_MOBILE_NUMBER},
address: $address
);
$vehicle = new VehicleUS(
trimId: {TRIM_ID},
description: {VEHICLE_DESCRIPTION},
vin: {VEHICLE_VIN}
);
$now = new DateTimeImmutable();
$endDate = $now->modify('+1 year');
$touristPolicy = new TouristPolicy(
insuranceCompanyId: InsuranceCompany::QUALITAS,
package: new Package(id: {PACKAGE_ID}),
vehicle: $vehicle,
policyHolder: $policyHolder,
startDate: $now,
endDate: $endDate,
isMultiEntry: false
);
$policyResource = $client->touristPolicyResource();
$policy = $policyResource->create($touristPolicy);
Replace the placeholders {...} with the actual data.
Getting Policy Document
The PDF document of a given policy can be retrieved as shown below.
use Covertier\Definitions\Enums\InsuranceCompany;
$documentResource = $client->documentResource();
// This will return the official document (PDF) for the specified policy number
$document = $documentResource->getDocumentByPolicyNumber(InsuranceCompany::QUALITAS, {POLICY_NUMBER_HERE});
General Notes
For more detailed documentation and examples, please refer to each of the resources in the SDK.