Search by

dompie / keila-php-api

dompie

This package is abandoned and no longer maintained. No replacement package was suggested.

Keila newsletter API HTTP client

This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.

Package info

github.com/dompie/keila-php-api

pkg:composer/dompie/keila-php-api

Statistics

Installs: 4 480

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 1

0.10.2 2024-07-04 07:40 UTC

This package is auto-updated.

Last update: 2026-01-28 08:41:46 UTC


README

A PHP HTTP client for the Keila newsletter API with Guzzle as single dependency.

Install

composer require dompie/keila-http-api

How to use

require_once 'vendor/autoload.php';

$httpClient = new \GuzzleHttp\Client();
$client = new \Dompie\KeilaApiClient\ApiClientV1($httpClientInterface, 'https://keila-installation.url', 'my-secret-keila-api-key');
$responseInterface = $client->createContact([
    'first_name' => 'First',
    'last_name' => 'Last',
    'email' => 'first.last@example.com',
]);

$campaign = new \Dompie\KeilaApiClient\Campaign();
$campaign->withName('My test campaign')
    ->withTextEditor('Hello world!')
    ->withMarkdownEditor();
    
$responseInterface = $client->createCampaign($campaign);

Then you can pass the Guzzle ResponseInterface to your context.

Response helper

For testing purposes I've added also a KeilaResponse class to quickly access relevant items.

$response = \Dompie\KeilaApiClient\KeilaResponse::new($responseInterface);
$response->hasData();
$response->getDataItem(0); //First element from the data property
$response->getGuzzleResponse()->getStatusCode()

⚠️ Tests will trigger E-Mail sending. Use only with keila dev instance.

cp phpunit.xml.dist phpunit.xml

Put your Keila URI and Keila api key into phpunit.xml:

<env name="KEILA_BASE_URI" value="http://keila.local:4000" force="true"/>
<env name="KEILA_API_KEY" value="secret-api-key" force="true"/>

Finally tests

make test
or
XDEBUG_MODE=coverage make test-coverage