Files
piratepoet/tasks/release/TranslationsController.php
Pavel Dohnal eda7a74f25 Remove the http client from constructor
[MAILPOET-3807]
2021-11-10 09:43:22 +01:00

36 lines
1.0 KiB
PHP

<?php
namespace MailPoetTasks\Release;
use GuzzleHttp\Client;
class TranslationsController {
private const API_IMPORT_BASE_URI = 'https://translate.wordpress.com/api/import-transifex/';
public function importTransifex(string $version, $project = 'mailpoet'): array {
$httpClient = new Client([
'base_uri' => self::API_IMPORT_BASE_URI . $project . '/',
]);
$response = $httpClient->post($version);
$response->getStatusCode();
if ($response->getStatusCode() !== 200) {
return [
'success' => false,
'data' => 'Failed preparing translations',
];
}
$result = json_decode($response->getBody()->getContents(), true);
if (!is_array($result) || !isset($result['success']) || !isset($result['data'])) {
return [
'success' => false,
'data' => 'Failed preparing translations - malformed response: ' . $response->getBody()->getContents(),
];
}
return $result;
}
public function checkIfTranslationsAreReady(string $version): bool {
return true;
}
}