Filter for license provisioning

This commit adds a filter that will provision the API key. It only runs on WP.com sites with plugins.

[MAILPOET-5131]
This commit is contained in:
Brezo Cordero
2023-03-17 16:45:00 -05:00
committed by Aschepikov
parent 397232e932
commit fc8837e03c
5 changed files with 168 additions and 1 deletions

View File

@ -4,7 +4,9 @@ namespace MailPoet\API\JSON\v1;
use MailPoet\API\JSON\Endpoint as APIEndpoint;
use MailPoet\API\JSON\Error as APIError;
use MailPoet\API\JSON\ErrorResponse;
use MailPoet\API\JSON\Response;
use MailPoet\API\JSON\SuccessResponse;
use MailPoet\Config\AccessControl;
use MailPoet\Config\ServicesChecker;
use MailPoet\Cron\Workers\SubscribersEngagementScore;
@ -493,4 +495,24 @@ class Settings extends APIEndpoint {
'action' => 'reactivate',
];
}
/**
* Prepares the settings to set up MSS with the given key and calls the set method.
*
* @param string $apiKey
* @return ErrorResponse|SuccessResponse
*/
public function setupMSS(string $apiKey) {
$new_settings = [
'mta_group' => 'mailpoet',
'mta' => [
'method' => 'MailPoet',
'mailpoet_api_key' => $apiKey,
],
'signup_confirmation' => [
'enabled' => '1',
],
];
return $this->set($new_settings);
}
}