PHP SDK to work with Covie's API
NOTE: This is pre-release software and is subject to change as we develop it.
We recommend that you use Composer to bring the Covie PHP SDK into your project.
$ composer require covie/sdk-php
Firstly, create a client using your own client-id
and client-secret
:
use Covie\SDK\Client;
$client = Client::createFromCredentials('client-id', 'client-secret');
Now that you have a client, you can interact with Covie.
To create a new integration named test
:
$integration = $sdk->integrations()->create('test');
You can then access the new integration's key using:
$key = $integration->getIntegrationKey();
The key can then be used with the SDK and other integration level API calls.
To retrieve a policy, you need to know its ID which is of the form po_xxxxxxxxxxxxxxxx
and can then use:
$policy = $sdk->policies()->get($policyId);
Now that we have a policy, we can obtain the policy data in JSON format:
echo json_encode($policy->jsonSerialize(), JSON_PRETTY_PRINT) . PHP_EOL;
We can also retrieve its documents. For example to retrieve the declaration PDF and write to disk:
use Covie\SDK\Model\DocumentType;
$pdfContent = $sdk->policies()->getLatestDocumentOfType($policy, DocumentType::DECLARATION);
file_put_contents('declaration.pdf', $pdfContent);
The available types are listed in the DocumentType class.
We are not accepting contributions to the Covie PHP SDK at this time.