1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace BabDev\Transifex\Connector; |
4
|
|
|
|
5
|
|
|
use BabDev\Transifex\ApiConnector; |
6
|
|
|
use Psr\Http\Client\ClientInterface; |
7
|
|
|
use Psr\Http\Message\RequestFactoryInterface; |
8
|
|
|
use Psr\Http\Message\ResponseInterface; |
9
|
|
|
use Psr\Http\Message\StreamFactoryInterface; |
10
|
|
|
use Psr\Http\Message\UriFactoryInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Transifex API Organizations class. |
14
|
|
|
* |
15
|
|
|
* @link https://docs.transifex.com/api/organizations |
16
|
|
|
*/ |
17
|
|
|
final class Organizations extends ApiConnector |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param ClientInterface $client The HTTP client |
21
|
|
|
* @param RequestFactoryInterface $requestFactory The request factory |
22
|
|
|
* @param StreamFactoryInterface $streamFactory The stream factory |
23
|
|
|
* @param UriFactoryInterface $uriFactory The URI factory |
24
|
|
|
* @param array $options Transifex options array |
25
|
|
|
*/ |
26
|
2 |
|
public function __construct( |
27
|
|
|
ClientInterface $client, |
28
|
|
|
RequestFactoryInterface $requestFactory, |
29
|
|
|
StreamFactoryInterface $streamFactory, |
30
|
|
|
UriFactoryInterface $uriFactory, |
31
|
|
|
array $options = [] |
32
|
|
|
) { |
33
|
2 |
|
parent::__construct($client, $requestFactory, $streamFactory, $uriFactory, $options); |
34
|
|
|
|
35
|
|
|
// This API group uses the newer `api.transifex.com` subdomain, only change if the default www was given |
36
|
2 |
|
if (!$this->getOption('base_uri') || $this->getOption('base_uri') === 'https://www.transifex.com') { |
37
|
2 |
|
$this->setOption('base_uri', 'https://api.transifex.com'); |
38
|
|
|
} |
39
|
2 |
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get the organizations the authenticated user belongs to. |
43
|
|
|
* |
44
|
|
|
* @return ResponseInterface |
45
|
|
|
*/ |
46
|
2 |
|
public function getOrganizations(): ResponseInterface |
47
|
|
|
{ |
48
|
2 |
|
return $this->client->sendRequest($this->createRequest('GET', $this->createUri('/organizations/'))); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|