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 email actions to Environments endpoint. #314

Merged
merged 9 commits into from Feb 8, 2023
34 changes: 34 additions & 0 deletions src/Endpoints/Environments.php
Expand Up @@ -191,6 +191,40 @@ public function disableProductionMode(string $environmentUuid): OperationRespons
);
}

/**
* Enable platform email for an environment.
*
* @param string $environmentUuid
*
* @return OperationResponse
*/
public function enableEmail(string $environmentUuid): OperationResponse
{
return new OperationResponse(
$this->client->request(
'post',
"/environments/$environmentUuid/email/actions/enable"
)
);
}

/**
* Disable platform email for an environment.
*
* @param string $environmentUuid
*
* @return OperationResponse
*/
public function disableEmail(string $environmentUuid): OperationResponse
{
return new OperationResponse(
$this->client->request(
'post',
"/environments/$environmentUuid/email/actions/disable"
)
);
}

/**
* Add a new continuous delivery environment to an application.
*
Expand Down
28 changes: 28 additions & 0 deletions tests/Endpoints/EnvironmentsTest.php
Expand Up @@ -157,4 +157,32 @@ public function testDeleteCDEnvironment(): void
$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('The environment is being deleted.', $result->message);
}

public testEnableEmail(): void
fiasco marked this conversation as resolved.
Show resolved Hide resolved
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/enableEmail.json');

$client = $this->getMockClient($response);

/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->enableEmail('24-a47ac10b-58cc-4372-a567-0e02b2c3d470');

$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('Platform Email is being enabled', $result->message);
}

public testDisableEmail(): void
fiasco marked this conversation as resolved.
Show resolved Hide resolved
{
$response = $this->getPsr7JsonResponseForFixture('Endpoints/Environments/enableEmail.json');

$client = $this->getMockClient($response);

/** @var \AcquiaCloudApi\Connector\ClientInterface $client */
$environment = new Environments($client);
$result = $environment->disableEmail('24-a47ac10b-58cc-4372-a567-0e02b2c3d470');

$this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result);
$this->assertEquals('Platform Email is being disabled', $result->message);
}
}
3 changes: 3 additions & 0 deletions tests/Fixtures/Endpoints/Environments/disableEmail.json
@@ -0,0 +1,3 @@
{
"message": "Platform Email is being disabled"
}
3 changes: 3 additions & 0 deletions tests/Fixtures/Endpoints/Environments/enableEmail.json
@@ -0,0 +1,3 @@
{
"message": "Platform Email is being enabled"
}