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