Skip to content
 
 

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ingle Insurance PHP API

Usage

Setup

  1. Run composer install

Initialization (required)

Set Base URL to be used:

IngleInsurance::setUrl($baseUrl);

Set source to be used:

IngleInsurance::setSource('ingle');

Authenticate client with API key:

IngleInsurance::setApiKey('...');

Application

$application = new Application();

Set application fields:

$application->setEffectiveDate('yyyy-mm-dd');
$application->setExpiryDate('yyyy-mm-dd');
$application->setLocale('en');

Set additional data fields:

$application->addAdditionalData(['eligibility' => true]);
$application->addAdditionalData(['additional_applicants_number' => 1])
$application->addAdditionalData([
    'dates_of_births' => [
        [
            'yyyy-mm-dd',
            'primary'
        ],
        [
            'yyyy-mm-dd',
            'dependent'
        ]
    ]
]);

// ----- or -------

$application->addAdditionalData([
    'eligibility' => true,
    'additional_applicants_number' => 1,
    'dates_of_births' => [
        [
            'yyyy-mm-dd',
            'primary'
        ],
        [
            'yyyy-mm-dd',
            'dependent'
        ]
    ]
]);

Save application as new:

// Don't set Application ID

$applicationId = $application->save();

Update an existing application:

// Set Applicant ID first

$application->setId($id);
$application->save();

Get application premium:

// Make sure applicants are created first.

$quote = $application->getQuote();

Get quote for an application:

$quote = $application->getQuote();

Pay for an application (returns a Confirmation, see below):

// Make sure application and applicants have been created and saved first

$confirmation = $application->pay('stripe', ['token' => 'XXXXX']);

Cancel a policy:

$application->setId('02b22412-7818-48e1-a460-080bbeebcca3');
$refundAmount = $application->cancel();

Load applicants from an application:

$applicantList = $application->getApplicants();

Load an existing application:

$application = Application::load($id);

Get a list of applications for a specified source:

$applications = Application::getApplications('ingle');

// or

$applications = Application::getApplications(
    'ingle',
    $options = [
        'page' = 1,
        'limit' = 10
]);

Applicant

$applicant = new Applicant();

Set applicant fields:

$applicant->setPrimary(true);
$applicant->setFirstName('Joe');
$applicant->setLastName('Smith');
$applicant->setSex('male');
$applicant->setDateOfBirth('1980-01-01');
$applicant->setAddressLine1('123 Fake St');
$applicant->setCity('Toronto');
$applicant->setState('ON');
$applicant->setCountry('CA');
$applicant->setPostalCode('A1A A1A');
$applicant->setPhoneNumber('(416) 123 4567');
$applicant->setEmail('joe@smith.com');

Set additional data fields:

$applicant->addAdditionalData([
    'school_name' => 'University of Waterloo',
    'eligibility' => true,
    'country_of_origin' => 'US',
    'beneficiary' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'address' => '100 Bay',
        'country_code' => 'CA',
        'city' => 'Toronto',
        'relationship_to_insured' => 'stranger'
    ]
]);

// ----- or -------

$applicant->addAdditionalData([
    'school_name' => 'University of Waterloo',
    'eligibility' => true,
    'country_of_origin' => 'US',
    'beneficiary' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'address' => '100 Bay',
        'country_code' => 'CA',
        'city' => 'Toronto',
        'relationship_to_insured' => 'stranger'
    ]
]);

Save applicant as new:

// Set Application ID first

$applicant->setApplication($applicationId);
$applicant->save();

Update an existing applicant:

// Set Applicant ID and Application ID first

$applicant->setApplication($applicationId);
$applicant->setId($applicantId);
$applicant->save();

Load an existing applicant:

$applicant = Applicant::load($applicantId);

Payment Confirmation

Access confirmation details:

$confirmation = $application->pay(...);

$title = $confirmation->getTitle();
$header = $confirmation->getHeader();
$body = $confirmation->getBody();
$legalText = $confirmation->getBody()

Access confirmation body sections:

$firstSection = $body[0];

$firstSectionHeader = $firstSection['header'];

$firstItem = firstSection['items'][0];
$itemText = $firstItem['text'];
$itemValue= $firstItem['value'];

Quote

Get quote for an application:

$quote = new Quote($applicationId);

// ----- or -------

$quote = $application->getQuote();

Get quote price:

$price = $quote->getPrice();

Get quote information:

$price = $quote->getInformation();

Get list of quote content items:

$price = $quote->getContent();

Get list of quote links:

$price = $quote->getLinks();

Premium Update

Make an application with the changes:

$applicationChanges = new Application();
$applicationChanges->setId($id);   // id of application to change
$applicationChanges->setExpiryDate($newDate);

Make applicants with changes (optional):

$applicant1Changes = new Application();
$applicant1Changes->setId($id);     // id of applicant to change
$applicant1Changes->setDateOfBirth($newDate);

$applicant2Changes = new Application();
$applicant2Changes->setId($id);     // id of applicant to change
$applicant2Changes->addAdditionalData($newData);

Form premium update:

$update = new PremiumUpdate();

$update->setApplication($applicationChanges);
$update->addApplicant($applicant1Changes);
$update->addApplicant($applicant2Changes);

Submit changes:

$costChange = $premium->requestUpdate();

Charge

if ($costChange->getType() == 'charge')

Get charge amount:

$amount = $costChange->getAmount();

Set payment provider:

$costChange->setProvider('stripe');

Add additional data (e.g. payment token):

$costChange->addAdditionalData(['token' => 'XXXXX']);

Make payment:

$costChange->applyChange();

Refund

if ($costChange->getType() == 'refund')

Get refund amount:

$amount = $costChange->getAmount();

Get list of past charges:

$charges = $costChange->getPastCharges();

Set payment provider:

$costChange->setProvider('stripe');

Set refund amounts for individual past charges:

$costChange->addRefundAmount($paymentProvider, $charge1Id, $amountToRefund);
$costChange->addRefundAmount($paymentProvider, $charge2Id, $amountToRefund);

Apply Refund:

$costChange->applyChange();

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages