-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
use Mailgun\Model\Tag\ProviderResponse; | ||
use Mailgun\Model\Tag\ShowResponse; | ||
use Mailgun\Model\Tag\StatisticsResponse; | ||
use Mailgun\Model\Tag\TagLimitResponse; | ||
use Mailgun\Model\Tag\UpdateResponse; | ||
use Psr\Http\Client\ClientExceptionInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
@@ -104,12 +105,13 @@ public function update(string $domain, string $tag, string $description, array $ | |
* @return StatisticsResponse|ResponseInterface | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function stats(string $domain, string $tag, array $params, array $requestHeaders = []) | ||
public function stats(string $domain, array $params, array $requestHeaders = []) | ||
Check failure on line 108 in src/Api/Tag.php
|
||
{ | ||
Assert::stringNotEmpty($domain); | ||
Assert::stringNotEmpty($tag); | ||
Assert::stringNotEmpty($params['event']); | ||
Assert::stringNotEmpty($params['tag']); | ||
|
||
$response = $this->httpGet(sprintf('/v3/%s/tags/%s/stats', $domain, $tag), $params, $requestHeaders); | ||
$response = $this->httpGet(sprintf('/v3/%s/tag/stats', $domain), $params, $requestHeaders); | ||
|
||
return $this->hydrateResponse($response, StatisticsResponse::class); | ||
} | ||
|
@@ -127,7 +129,7 @@ public function delete(string $domain, string $tag, array $requestHeaders = []) | |
Assert::stringNotEmpty($domain); | ||
Assert::stringNotEmpty($tag); | ||
|
||
$response = $this->httpDelete(sprintf('/v3/%s/tags/%s', $domain, $tag), [], $requestHeaders); | ||
$response = $this->httpDelete(sprintf('/v3/%s/tag', $domain), ['tag' => $tag], $requestHeaders); | ||
|
||
return $this->hydrateResponse($response, DeleteResponse::class); | ||
} | ||
|
@@ -182,4 +184,19 @@ public function devices(string $domain, string $tag, array $requestHeaders = []) | |
|
||
return $this->hydrateResponse($response, DeviceResponse::class); | ||
} | ||
|
||
/** | ||
* @param string $domain | ||
* @param array $requestHeaders | ||
* @return TagLimitResponse | ||
* @throws ClientExceptionInterface | ||
*/ | ||
public function getTagLimits(string $domain, array $requestHeaders = []): TagLimitResponse | ||
{ | ||
Assert::stringNotEmpty($domain); | ||
|
||
$response = $this->httpGet(sprintf('/v3/domains/%s/limits/tag', $domain), [], $requestHeaders); | ||
|
||
return $this->hydrateResponse($response, TagLimitResponse::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* 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\Model\Tag; | ||
|
||
use JetBrains\PhpStorm\ArrayShape; | ||
use Mailgun\Model\ApiResponse; | ||
|
||
final class TagLimitResponse implements ApiResponse | ||
{ | ||
private string $id; | ||
private int $limit; | ||
private int $count; | ||
|
||
/** | ||
* @param array $data | ||
* @return self | ||
*/ | ||
public static function create(array $data): TagLimitResponse | ||
{ | ||
$item = new self(); | ||
$item->setId($data['id'] ?? ''); | ||
$item->setLimit($data['limit'] ?? 0); | ||
$item->setCount($data['count'] ?? 0); | ||
|
||
return $item; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function setId(string $id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getLimit(): int | ||
{ | ||
return $this->limit; | ||
} | ||
|
||
/** | ||
* @param int $limit | ||
* @return void | ||
*/ | ||
public function setLimit(int $limit): void | ||
{ | ||
$this->limit = $limit; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getCount(): int | ||
{ | ||
return $this->count; | ||
} | ||
|
||
/** | ||
* @param int $count | ||
* @return void | ||
*/ | ||
public function setCount(int $count): void | ||
{ | ||
$this->count = $count; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
#[ArrayShape(['id' => "string", 'limit' => "int", 'count' => "int"])] public function toArray(): array | ||
Check failure on line 91 in src/Model/Tag/TagLimitResponse.php
|
||
{ | ||
return [ | ||
'id' => $this->getId(), | ||
'limit' => $this->getLimit(), | ||
'count' => $this->getCount(), | ||
]; | ||
} | ||
} |