Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De 1251 api messages endpoint #904

Merged
merged 7 commits into from
Apr 27, 2024
17 changes: 17 additions & 0 deletions src/Api/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Mailgun\Assert;
use Mailgun\Exception\InvalidArgumentException;
use Mailgun\Message\BatchMessage;
use Mailgun\Model\Message\QueueStatusResponse;
use Mailgun\Model\Message\SendResponse;
use Mailgun\Model\Message\ShowResponse;
use Psr\Http\Client\ClientExceptionInterface;
Expand Down Expand Up @@ -146,6 +147,22 @@ public function show(string $url, bool $rawMessage = false, array $requestHeader
return $this->hydrateResponse($response, ShowResponse::class);
}

/**
* Get messages queue status
* @see https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Messages/#tag/Messages/operation/httpapi.(*LegacyHttpApi).GetDomainSendingQueues-fm-70
* @param string $domain
* @param array $requestHeaders
* @return QueueStatusResponse
* @throws ClientExceptionInterface
*/
public function getMessageQueueStatus(string $domain, array $requestHeaders = [])
{
Assert::notEmpty($domain);
$response = $this->httpGet(sprintf('/v3/domains/%s/sending_queues', $domain), [], $requestHeaders);

return $this->hydrateResponse($response, QueueStatusResponse::class);
}

/**
* @param array $filePath array('fileContent' => 'content') or array('filePath' => '/foo/bar')
*
Expand Down
52 changes: 52 additions & 0 deletions src/Model/Message/QueueStatusResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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\Message;

use Mailgun\Model\ApiResponse;

final class QueueStatusResponse implements ApiResponse
{
/**
* @var array
*/
private $regular;
/**
* @var array
*/
private $scheduled;

public static function create(array $data): self
{
$model = new self();
$model->regular = $data['regular'] ?? [];
$model->scheduled = $data['scheduled'] ?? [];

return $model;
}

/**
* @return array
*/
public function getRegular(): array
{
return $this->regular;
}

/**
* @return array
*/
public function getScheduled(): array
{
return $this->scheduled;
}

}
Loading