|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* ReportingCloud PHP SDK |
|
6
|
|
|
* |
|
7
|
|
|
* PHP SDK for ReportingCloud Web API. Authored and supported by Text Control GmbH. |
|
8
|
|
|
* |
|
9
|
|
|
* @link https://www.reporting.cloud to learn more about ReportingCloud |
|
10
|
|
|
* @link https://github.com/TextControl/txtextcontrol-reportingcloud-php for the canonical source repository |
|
11
|
|
|
* @license https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-php/master/LICENSE.md |
|
12
|
|
|
* @copyright © 2019 Text Control GmbH |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace TxTextControl\ReportingCloud; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class ReportingCloud |
|
19
|
|
|
* |
|
20
|
|
|
* @package TxTextControl\ReportingCloud |
|
21
|
|
|
* @author Jonathan Maron (@JonathanMaron) |
|
22
|
|
|
*/ |
|
23
|
|
|
class ReportingCloud extends AbstractReportingCloud |
|
24
|
|
|
{ |
|
25
|
|
|
use BuildTrait; |
|
26
|
|
|
use DeleteTrait; |
|
27
|
|
|
use GetTrait; |
|
28
|
|
|
use PostTrait; |
|
29
|
|
|
use PutTrait; |
|
30
|
|
|
|
|
31
|
|
|
// <editor-fold desc="Methods"> |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* ReportingCloud constructor |
|
35
|
|
|
* |
|
36
|
|
|
* @param array|null $options |
|
37
|
|
|
*/ |
|
38
|
283 |
|
public function __construct(?array $options = null) |
|
39
|
|
|
{ |
|
40
|
283 |
|
if (is_array($options)) { |
|
41
|
|
|
|
|
42
|
|
|
$methods = [ |
|
43
|
|
|
// credentials |
|
44
|
274 |
|
'api_key' => 'setApiKey', |
|
45
|
|
|
// credentials (deprecated) |
|
46
|
|
|
'username' => 'setUsername', |
|
47
|
|
|
'password' => 'setPassword', |
|
48
|
|
|
// settings |
|
49
|
|
|
'base_uri' => 'setBaseUri', |
|
50
|
|
|
'debug' => 'setDebug', |
|
51
|
|
|
'test' => 'setTest', |
|
52
|
|
|
'timeout' => 'setTimeout', |
|
53
|
|
|
'version' => 'setVersion', |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
274 |
|
foreach ($methods as $key => $method) { |
|
57
|
274 |
|
if (array_key_exists($key, $options)) { |
|
58
|
274 |
|
$this->$method($options[$key]); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
283 |
|
if (null === $this->getBaseUri()) { |
|
64
|
283 |
|
$baseUri = $this->getBaseUriFromEnv() ?? self::DEFAULT_BASE_URI; |
|
65
|
283 |
|
$this->setBaseUri($baseUri); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
283 |
|
if (null === $this->getDebug()) { |
|
69
|
283 |
|
$this->setDebug(self::DEFAULT_DEBUG); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
283 |
|
if (null === $this->getTest()) { |
|
73
|
283 |
|
$this->setTest(self::DEFAULT_TEST); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
283 |
|
if (null === $this->getTimeout()) { |
|
77
|
283 |
|
$this->setTimeout(self::DEFAULT_TIMEOUT); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
283 |
|
if (null === $this->getVersion()) { |
|
81
|
283 |
|
$this->setVersion(self::DEFAULT_VERSION); |
|
82
|
|
|
} |
|
83
|
283 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
// </editor-fold> |
|
86
|
|
|
} |
|
87
|
|
|
|