mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
Added "complaints" to TotalResponse (#509)
This commit is contained in:
parent
02e3191bc9
commit
09113482ea
@ -34,6 +34,11 @@ class TotalResponseItem
|
||||
*/
|
||||
private $failed;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $complained;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
@ -45,7 +50,8 @@ class TotalResponseItem
|
||||
isset($data['time']) ? new \DateTime($data['time']) : null,
|
||||
isset($data['accepted']) ? $data['accepted'] : [],
|
||||
isset($data['delivered']) ? $data['delivered'] : [],
|
||||
isset($data['failed']) ? $data['failed'] : []
|
||||
isset($data['failed']) ? $data['failed'] : [],
|
||||
isset($data['complained']) ? $data['complained'] : []
|
||||
);
|
||||
}
|
||||
|
||||
@ -54,13 +60,15 @@ class TotalResponseItem
|
||||
* @param array $accepted
|
||||
* @param array $delivered
|
||||
* @param array $failed
|
||||
* @param array $complained
|
||||
*/
|
||||
private function __construct(\DateTime $time, array $accepted, array $delivered, array $failed)
|
||||
private function __construct(\DateTime $time, array $accepted, array $delivered, array $failed, array $complained)
|
||||
{
|
||||
$this->time = $time;
|
||||
$this->accepted = $accepted;
|
||||
$this->delivered = $delivered;
|
||||
$this->failed = $failed;
|
||||
$this->complained = $complained;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,4 +102,12 @@ class TotalResponseItem
|
||||
{
|
||||
return $this->failed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getComplained()
|
||||
{
|
||||
return $this->complained;
|
||||
}
|
||||
}
|
||||
|
66
tests/Model/Stats/TotalResponseTest.php
Normal file
66
tests/Model/Stats/TotalResponseTest.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Stats;
|
||||
|
||||
use Mailgun\Model\Stats\TotalResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class TotalResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"end": "Fri, 01 Apr 2012 00:00:00 UTC",
|
||||
"resolution": "month",
|
||||
"start": "Tue, 14 Feb 2012 00:00:00 UTC",
|
||||
"stats": [
|
||||
{
|
||||
"time": "Tue, 14 Feb 2012 00:00:00 UTC",
|
||||
"accepted": {
|
||||
"outgoing": 10,
|
||||
"incoming": 5,
|
||||
"total": 15
|
||||
},
|
||||
"delivered": {
|
||||
"smtp": 15,
|
||||
"http": 5,
|
||||
"total": 20
|
||||
},
|
||||
"failed": {
|
||||
"permanent": {
|
||||
"bounce": 4,
|
||||
"delayed-bounce": 1,
|
||||
"suppress-bounce": 1,
|
||||
"suppress-unsubscribe": 2,
|
||||
"suppress-complaint": 3,
|
||||
"total": 10
|
||||
},
|
||||
"temporary": {
|
||||
"espblock": 1
|
||||
}
|
||||
},
|
||||
"complained": {
|
||||
"total": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON;
|
||||
$model = TotalResponse::create(json_decode($json, true));
|
||||
$this->assertEquals('2012-02-14', $model->getStart()->format('Y-m-d'));
|
||||
$this->assertCount(1, $model->getStats());
|
||||
$stats = $model->getStats();
|
||||
$stats = $stats[0];
|
||||
$this->assertEquals('2012-02-14', $stats->getTime()->format('Y-m-d'));
|
||||
$this->assertEquals('1', $stats->getComplained()['total']);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user