dompie/keila-php-api
最新稳定版本:0.10.2
Composer 安装命令:
composer require dompie/keila-php-api
包简介
Keila newsletter API HTTP client
README 文档
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
统计信息
- 总下载量: 4.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause-Clear
- 更新时间: 2024-03-19