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

Add useAutomaticSenderSecurity support in DomainV4 #928

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/Api/DomainV4.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Mailgun\Model\Domain\UpdateCredentialResponse;
use Mailgun\Model\Domain\UpdateOpenTrackingResponse;
use Mailgun\Model\Domain\UpdateUnsubscribeTrackingResponse;
use Mailgun\Model\Domain\UseAutomaticSenderSecurity;
use Mailgun\Model\Domain\VerifyResponse;
use Mailgun\Model\Domain\WebPrefixResponse;
use Mailgun\Model\Domain\WebSchemeResponse;
Expand Down Expand Up @@ -94,6 +95,7 @@ public function show(string $domain, array $requestHeaders = [])
* @param array $requestHeaders
* @param string|null $dkimHostName
* @param string|null $dkimSelector
* @param bool|null $useAutomaticSenderSecurity
* @return CreateResponse|array|ResponseInterface
* @throws ClientExceptionInterface
*/
Expand All @@ -109,7 +111,8 @@ public function create(
string $dkimKeySize = '1024',
array $requestHeaders = [],
?string $dkimHostName = null,
?string $dkimSelector = null
?string $dkimSelector = null,
?bool $useAutomaticSenderSecurity = null
) {
Assert::stringNotEmpty($domain);

Expand Down Expand Up @@ -174,6 +177,10 @@ public function create(
$params['dkim_selector'] = $dkimSelector;
}

if (null !== $useAutomaticSenderSecurity) {
$params['use_automatic_sender_security'] = $useAutomaticSenderSecurity ? 'true' : 'false';
}

$response = $this->httpPost('/v4/domains', $params, $requestHeaders);

return $this->hydrateResponse($response, CreateResponse::class);
Expand Down Expand Up @@ -365,6 +372,27 @@ public function updateWebScheme(string $domain, string $webScheme = 'http', arra
return $this->hydrateResponse($response, WebSchemeResponse::class);
}

/**
* Update useAutomaticSenderSecurity for existing domain
* @see https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Domains/#tag/Domains/operation/PUT-v4-domains--name-
* @param string $domain name of the domain
* @param bool $useAutomaticSenderSecurity If enabled, requires setting DNS CNAME entries for DKIM keys instead of a TXT record. Defaults to false.
* @param array $requestHeaders
* @return UseAutomaticSenderSecurity|array|ResponseInterface
* @throws ClientExceptionInterface
*/
public function updateUseAutomaticSenderSecurity(string $domain, bool $useAutomaticSenderSecurity = false, array $requestHeaders = [])
{
$params = [];
Assert::stringNotEmpty($domain);

$params['use_automatic_sender_security'] = $useAutomaticSenderSecurity;

$response = $this->httpPut(sprintf('/v4/domains/%s', $domain), $params, $requestHeaders);

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

/**
* Returns a single domain.
* @param string $domain name of the domain
Expand Down
16 changes: 16 additions & 0 deletions src/Model/Domain/UseAutomaticSenderSecurity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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\Domain;

final class UseAutomaticSenderSecurity extends AbstractDomainResponse
{
}
Loading