mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-12-01 17:36:05 +03:00
Changed variable case, new webhooks return empty array if no hooks installed
This commit is contained in:
parent
379cd2a36e
commit
de8b1b175a
@ -18,20 +18,19 @@ use Mailgun\Model\ApiResponse;
|
|||||||
*/
|
*/
|
||||||
final class IndexResponse implements ApiResponse
|
final class IndexResponse implements ApiResponse
|
||||||
{
|
{
|
||||||
private $legacy_bounce = [];
|
private $legacyBounce = null;
|
||||||
private $legacy_deliver = [];
|
private $legacyDeliver = null;
|
||||||
private $legacy_drop = [];
|
private $legacyDrop = null;
|
||||||
private $legacy_spam = [];
|
private $legacySpam = null;
|
||||||
private $legacy_unsubscribe = [];
|
private $legacyUnsubscribe = null;
|
||||||
private $legacy_click = [];
|
private $legacyClick = null;
|
||||||
private $legacy_open = [];
|
private $legacyOpen = null;
|
||||||
|
|
||||||
private $clicked = [];
|
private $clicked = [];
|
||||||
private $complained = [];
|
private $complained = [];
|
||||||
private $delivered = [];
|
private $delivered = [];
|
||||||
private $opened = [];
|
private $opened = [];
|
||||||
private $permanent_fail = [];
|
private $permanentFail = [];
|
||||||
private $temporary_fail = [];
|
private $temporaryFail = [];
|
||||||
private $unsubscribed = [];
|
private $unsubscribed = [];
|
||||||
|
|
||||||
private function __construct()
|
private function __construct()
|
||||||
@ -44,92 +43,92 @@ final class IndexResponse implements ApiResponse
|
|||||||
|
|
||||||
$data = $data['webhooks'] ?? $data;
|
$data = $data['webhooks'] ?? $data;
|
||||||
|
|
||||||
$model->legacy_bounce = $data['bounce'] ?? [];
|
$model->legacyBounce = $data['bounce']['url'] ?? null;
|
||||||
$model->legacy_deliver = $data['deliver'] ?? [];
|
$model->legacyDeliver = $data['deliver']['url'] ?? null;
|
||||||
$model->legacy_drop = $data['drop'] ?? [];
|
$model->legacyDrop = $data['drop']['url'] ?? null;
|
||||||
$model->legacy_spam = $data['spam'] ?? [];
|
$model->legacySpam = $data['spam']['url'] ?? null;
|
||||||
$model->legacy_unsubscribe = $data['unsubscribe'] ?? [];
|
$model->legacyUnsubscribe = $data['unsubscribe']['url'] ?? null;
|
||||||
$model->legacy_click = $data['click'] ?? [];
|
$model->legacyClick = $data['click']['url'] ?? null;
|
||||||
$model->legacy_open = $data['open'] ?? [];
|
$model->legacyOpen = $data['open']['url'] ?? null;
|
||||||
|
|
||||||
$model->clicked = $data['clicked'] ?? [];
|
$model->clicked = $data['clicked']['urls'] ?? [];
|
||||||
$model->complained = $data['complained'] ?? [];
|
$model->complained = $data['complained']['urls'] ?? [];
|
||||||
$model->delivered = $data['delivered'] ?? [];
|
$model->delivered = $data['delivered']['urls'] ?? [];
|
||||||
$model->opened = $data['opened'] ?? [];
|
$model->opened = $data['opened']['urls'] ?? [];
|
||||||
$model->permanent_fail = $data['permanent_fail'] ?? [];
|
$model->permanentFail = $data['permanent_fail']['urls'] ?? [];
|
||||||
$model->temporary_fail = $data['temporary_fail'] ?? [];
|
$model->temporaryFail = $data['temporary_fail']['urls'] ?? [];
|
||||||
$model->unsubscribed = $data['unsubscribed'] ?? [];
|
$model->unsubscribed = $data['unsubscribed']['urls'] ?? [];
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBounceUrl(): ?string
|
public function getBounceUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_bounce['url'] ?? null;
|
return $this->legacyBounce;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDeliverUrl(): ?string
|
public function getDeliverUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_deliver['url'] ?? null;
|
return $this->legacyDeliver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDropUrl(): ?string
|
public function getDropUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_drop['url'] ?? null;
|
return $this->legacyDrop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpamUrl(): ?string
|
public function getSpamUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_spam['url'] ?? null;
|
return $this->legacySpam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnsubscribeUrl()
|
public function getUnsubscribeUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_unsubscribe['url'] ?? null;
|
return $this->legacyUnsubscribe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClickUrl(): ?string
|
public function getClickUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_click['url'] ?? null;
|
return $this->legacyClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOpenUrl(): ?string
|
public function getOpenUrl(): ?string
|
||||||
{
|
{
|
||||||
return $this->legacy_open['url'] ?? null;
|
return $this->legacyOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClickedUrls(): ?array
|
public function getClickedUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->clicked['urls'] ?? null;
|
return $this->clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getComplainedUrls(): ?array
|
public function getComplainedUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->complained['urls'] ?? null;
|
return $this->complained;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDeliveredUrls(): ?array
|
public function getDeliveredUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->delivered['urls'] ?? null;
|
return $this->delivered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOpenedUrls(): ?array
|
public function getOpenedUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->opened['urls'] ?? null;
|
return $this->opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPermanentFailUrls(): ?array
|
public function getPermanentFailUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->permanent_fail['urls'] ?? null;
|
return $this->permanentFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemporaryFailUrls(): ?array
|
public function getTemporaryFailUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->temporary_fail['urls'] ?? null;
|
return $this->temporaryFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnsubscribeUrls(): ?array
|
public function getUnsubscribeUrls(): ?array
|
||||||
{
|
{
|
||||||
return $this->unsubscribed['urls'] ?? null;
|
return $this->unsubscribed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,19 @@ JSON;
|
|||||||
$this->assertEquals('http://example.com/open_1', $model->getOpenUrl());
|
$this->assertEquals('http://example.com/open_1', $model->getOpenUrl());
|
||||||
$this->assertEquals('http://example.com/spam_1', $model->getSpamUrl());
|
$this->assertEquals('http://example.com/spam_1', $model->getSpamUrl());
|
||||||
$this->assertEquals('http://example.com/unsubscribe_1', $model->getUnsubscribeUrl());
|
$this->assertEquals('http://example.com/unsubscribe_1', $model->getUnsubscribeUrl());
|
||||||
$this->assertNull($model->getClickedUrls());
|
$this->assertInternalType('array', $model->getClickedUrls());
|
||||||
$this->assertNull($model->getComplainedUrls());
|
$this->assertInternalType('array', $model->getComplainedUrls());
|
||||||
$this->assertNull($model->getDeliveredUrls());
|
$this->assertInternalType('array', $model->getDeliveredUrls());
|
||||||
$this->assertNull($model->getOpenedUrls());
|
$this->assertInternalType('array', $model->getOpenedUrls());
|
||||||
$this->assertNull($model->getPermanentFailUrls());
|
$this->assertInternalType('array', $model->getPermanentFailUrls());
|
||||||
$this->assertNull($model->getTemporaryFailUrls());
|
$this->assertInternalType('array', $model->getTemporaryFailUrls());
|
||||||
$this->assertNull($model->getUnsubscribeUrls());
|
$this->assertInternalType('array', $model->getUnsubscribeUrls());
|
||||||
|
$this->assertCount(0, $model->getClickedUrls());
|
||||||
|
$this->assertCount(0, $model->getComplainedUrls());
|
||||||
|
$this->assertCount(0, $model->getDeliveredUrls());
|
||||||
|
$this->assertCount(0, $model->getOpenedUrls());
|
||||||
|
$this->assertCount(0, $model->getPermanentFailUrls());
|
||||||
|
$this->assertCount(0, $model->getTemporaryFailUrls());
|
||||||
|
$this->assertCount(0, $model->getUnsubscribeUrls());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user