yii2 unisender extension
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist matperez/yii2unisender "~1.0"
or add
"matperez/yii2unisender": "~1.0"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
'components' => [
'unisender' => [
'class' => \matperez\yii2unisender\UniSender::class,
'apiConfig' => [
'apiKey' => '...'
],
]
5DE0
You can also use it with the dependency container:
Yii::$container->setSingleton(\matperez\yii2unisender\UniSenderInterface::class, function() {
return Yii::$app->unisender;
});
For now it's supports the following operations:
Get a user fields array:
$fields = $unisender->getFields()->getResult;
Get an available subscriptions list:
$list = $unisender->getLists()->getResult();
Create a new subscription:
$sub = new Subscriber($name, $email, $phone);
$sub->addTag('something');
$response = $unisender->subscribe($sub, [12315, 14333]);
if ($response->isSuccess()) {
$personId = $response->getResult()['person_id'];
// .... do something with the person id
}
Get the "native" API instance:
$api = $unisender->getApi();
$api->doSomethingViaMagicCall();
Just run phpunit