diff options
Diffstat (limited to 'Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php')
-rw-r--r-- | Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php new file mode 100644 index 0000000..3d4caff --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php @@ -0,0 +1,105 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Stats; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class TotalResponse implements ApiResponse +{ + /** + * @var \DateTime + */ + private $start; + + /** + * @var \DateTime + */ + private $end; + + /** + * @var string + */ + private $resolution; + + /** + * @var TotalResponseItem[] + */ + private $stats; + + /** + * @param \DateTime $start + * @param \DateTime $end + * @param string $resolution + * @param TotalResponseItem[] $stats + */ + private function __construct(\DateTime $start, \DateTime $end, $resolution, array $stats) + { + $this->start = $start; + $this->end = $end; + $this->resolution = $resolution; + $this->stats = $stats; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $stats = []; + if (isset($data['status'])) { + foreach ($data['stats'] as $s) { + $stats[] = TotalResponseItem::create($s); + } + } + + $start = isset($data['start']) ? new \DateTime($data['start']) : null; + $end = isset($data['end']) ? new \DateTime($data['end']) : null; + $resolution = isset($data['resolution']) ? $data['resolution'] : null; + + return new self($start, $end, $resolution, $stats); + } + + /** + * @return \DateTime + */ + public function getStart() + { + return $this->start; + } + + /** + * @return \DateTime + */ + public function getEnd() + { + return $this->end; + } + + /** + * @return string + */ + public function getResolution() + { + return $this->resolution; + } + + /** + * @return TotalResponseItem[] + */ + public function getStats() + { + return $this->stats; + } +} |