.NET SDK

Installation

The SDK is distributed as a NuGet package which targets .NET Standard 2.0 and can be installed like any other package.

IDE

You can install the SDK using the NuGet Package Manager in an IDE like Visual Studio or JetBrains Rider.

.NET CLI

Using the .NET CLI, the SDK can be installed with the following command:

dotnet add package Covertier.Sdk

Initializing the Client

First, you need to initialize the client by providing a ClientSettings object, which contains the access token (also referred to as API key) and the base URL of the API server as a ClientBaseUrl object:

using Covertier.Sdk;
using Covertier.Sdk.Enums;

var client = new Client(
    new ClientSettings
    {
        AccessToken = "{API_KEY}",
        BaseUrl = ClientBaseUrl.FromEnvironment(ClientEnvironment.Sandbox)
    }
);

Getting Vehicle Makes

To retrieve a list of vehicle makes, use the following code:

var makes = await client.GetVehicleMakesAsync();

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:

var models = await client.GetVehicleModelsByMakeIdAndYearAsync({VEHICLE_MAKE_ID}, {VEHICLE_YEAR});

Replace {VEHICLE_MAKE_ID} with the ID of the desired make, and {VEHICLE_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:

var trims = await client.GetVehicleTrimsByModelIdAndYearAsync({VEHICLE_MODEL_ID}, {VEHICLE_YEAR});

Replace {VEHICLE_MODEL_ID} with the ID of the desired model, and {VEHICLE_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):

var trim = await client.GetVehicleTrimByVinAsync({VEHICLE_VIN});

Replace {VEHICLE_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 Vehicle resource documentation.

Getting Packages

A list of packages can be retrieved for a specific insurance company and policy type as shown below:

var packages = await client.GetPackagesByInsuranceCompanyIdAndPolicyTypeAsync(
    InsuranceCompanyId.QUALITAS,
    PolicyType.MX_TOURIST
);

The insurance company and policy type shown in the example are values from the InsuranceCompanyId and PolicyType enums.

For more detailed documentation and examples, please refer to the Policy Package resource documentation.

Generating Tourist Quotes

Tourist policy quotes may be generated with a package and a trim ID as shown below:

var packageData = new TouristPolicyQuoteRequestPackage
{
    Id = {PACKAGE_ID}
};

var vehicleData = new TouristPolicyQuoteRequestVehicle { TrimId = {TRIM_ID} };

var quoteData = new CreateTouristPolicyQuoteRequestBody
{
    StartDate = DateTime.Now,
    EndDate = DateTime.Now.AddYears(1),
    InsuranceCompanyId = InsuranceCompanyId.QUALITAS,
    Package = packageData,
    Vehicle = vehicleData
};

var quote = await client.CreateTouristPolicyQuoteAsync(quoteData);

Replace {PACKAGE_ID} with the desired package ID and {TRIM_ID} with the ID of the desired trim.

In the vehicle data, the vehicle's value and year can be provided instead of the trim ID:

var vehicleData = new TouristPolicyQuoteRequestVehicle { Value = {VALUE}, Year = {YEAR} };

Issuing Tourist Policies

A tourist policy with an American address can be issued as shown in the following example:

var packageData = new TouristPolicyRequestPackage
{
    Id = {PACKAGE_ID}
};


var vehicleData = new TouristPolicyRequestVehicle {
    TrimId = {TRIM_ID},
    Description = {DESCRIPTION},
    Vin = {VIN},
};

var addressData = new TouristPolicyRequestAddress
{
    Line1 = {LINE_1},
    District = {DISTRICT},
    City = {CITY},
    ZipCode = {ZIP_CODE},
    State = {STATE}
};

var policyHolderData = new TouristPolicyRequestPolicyHolder
{
    FirstName = {FIRST_NAME},
    LastName = {LAST_NAME},
    Birthdate = {BIRTHDATE},
    Address = addressData,
    MobileNumber = {MOBILE_NUMBER},
    PersonalIdType = {PERSONAL_ID_TYPE},
    IdentificationNumber = {IDENTIFICATION_NUMBER}
};

var touristPolicyData = new CreateTouristPolicyRequestBody
{
    StartDate = {START_DATE},
    EndDate = {END_DATE},
    InsuranceCompanyId = {INSURANCE_COMPANY_ID},
    Package = packageData,
    Vehicle = vehicleData,
    PolicyHolder = policyHolderData,
    IsMultiEntry = {IS_MULTI_ENTRY}
};

var touristPolicy = await client.CreateTouristPolicyAsync(touristPolicyData);

In the vehicle data, the vehicle's value and year can be provided instead of the trim ID:

var vehicleData = new TouristPolicyRequestVehicle {
    Value = {VALUE},
    Year = {YEAR},
    Vin = {VIN},
    Description = {DESCRIPTION},
};

Getting Policy Document

The PDF document of a given policy can be retrieved as shown below.

var document = await client.GetTouristPolicyDocumentByInsuranceCompanyIdAndPolicyNumberAsync(
    {INSURANCE_COMPANY_ID},
    {POLICY_NUMBER}
);

General Notes

For more detailed documentation and examples, please refer to each of the resources in the SDK.

Was this page helpful?