-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathImport.php
44 lines (37 loc) · 1.07 KB
/
Import.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
*
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace FAPI\Localise\Api;
use FAPI\Localise\Exception;
use FAPI\Localise\Model\Import\Imported;
use Psr\Http\Message\ResponseInterface;
/**
* @author Tobias Nyholm <[email protected]>
*/
class Import extends HttpApi
{
/**
* Export a locale.
* {@link https://localise.biz/api/docs/export/exportlocale}.
*
* @return string|ResponseInterface
*
* @throws Exception
*/
public function import(string $projectKey, string $ext, string $body, array $params)
{
$params['key'] = $projectKey;
$response = $this->httpPostRaw(sprintf('/api/import/%s?%s', $ext, http_build_query($params)), $body);
if (!$this->hydrator) {
return $response;
}
if (200 !== $response->getStatusCode() && 201 !== $response->getStatusCode()) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Imported::class);
}
}