1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ReportingCloud PHP Wrapper |
5
|
|
|
* |
6
|
|
|
* PHP wrapper for ReportingCloud Web API. Authored and supported by Text Control GmbH. |
7
|
|
|
* |
8
|
|
|
* @link http://www.reporting.cloud to learn more about ReportingCloud |
9
|
|
|
* @link https://github.com/TextControl/txtextcontrol-reportingcloud-php for the canonical source repository |
10
|
|
|
* @license https://raw.githubusercontent.com/TextControl/txtextcontrol-reportingcloud-php/master/LICENSE.md |
11
|
|
|
* @copyright © 2018 Text Control GmbH |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace TxTextControl\ReportingCloud; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* ReportingCloud |
18
|
|
|
* |
19
|
|
|
* @package TxTextControl\ReportingCloud |
20
|
|
|
* @author Jonathan Maron (@JonathanMaron) |
21
|
|
|
*/ |
22
|
|
|
class ReportingCloud |
23
|
|
|
{ |
24
|
|
|
use DeleteTrait; |
25
|
|
|
use GetTrait; |
26
|
|
|
use PostTrait; |
27
|
|
|
use PutTrait; |
28
|
|
|
use SetGetTrait; |
29
|
|
|
use UtilityTrait; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Default date/time format of backend is 'ISO 8601' |
33
|
|
|
* |
34
|
|
|
* Note, last letter is 'P' and not 'O': |
35
|
|
|
* |
36
|
|
|
* O - Difference to Greenwich time (GMT) in hours (e.g. +0200) |
37
|
|
|
* P - Difference to Greenwich time (GMT) with colon between hours and minutes (e.g. +02:00) |
38
|
|
|
* |
39
|
|
|
* Backend uses the 'P' variant |
40
|
|
|
* |
41
|
|
|
* @const DEFAULT_DATE_FORMAT |
42
|
|
|
*/ |
43
|
|
|
const DEFAULT_DATE_FORMAT = 'Y-m-d\TH:i:sP'; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Default time zone of backend |
47
|
|
|
* |
48
|
|
|
* @const DEFAULT_TIME_ZONE |
49
|
|
|
*/ |
50
|
|
|
const DEFAULT_TIME_ZONE = 'UTC'; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Default base URI of backend |
54
|
|
|
* |
55
|
|
|
* @const DEFAULT_BASE_URI |
56
|
|
|
*/ |
57
|
|
|
const DEFAULT_BASE_URI = 'https://api.reporting.cloud'; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Default version string of backend |
61
|
|
|
* |
62
|
|
|
* @const DEFAULT_VERSION |
63
|
|
|
*/ |
64
|
|
|
const DEFAULT_VERSION = 'v1'; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Default timeout of backend in seconds |
68
|
|
|
* |
69
|
|
|
* @const DEFAULT_TIMEOUT |
70
|
|
|
*/ |
71
|
|
|
const DEFAULT_TIMEOUT = 120; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Default test flag of backend |
75
|
|
|
* |
76
|
|
|
* @const DEFAULT_TEST |
77
|
|
|
*/ |
78
|
|
|
const DEFAULT_TEST = false; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Default debug flag of REST client |
82
|
|
|
* |
83
|
|
|
* @const DEFAULT_DEBUG |
84
|
|
|
*/ |
85
|
|
|
const DEFAULT_DEBUG = false; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* AbstractReportingCloud constructor |
89
|
|
|
* |
90
|
|
|
* @param array $options |
91
|
|
|
*/ |
92
|
132 |
|
public function __construct(array $options = []) |
93
|
|
|
{ |
94
|
|
|
$methods = [ |
95
|
132 |
|
'api_key' => 'setApiKey', |
96
|
66 |
|
'base_uri' => 'setBaseUri', |
97
|
66 |
|
'debug' => 'setDebug', |
98
|
66 |
|
'password' => 'setPassword', |
99
|
66 |
|
'test' => 'setTest', |
100
|
66 |
|
'timeout' => 'setTimeout', |
101
|
66 |
|
'username' => 'setUsername', |
102
|
66 |
|
'version' => 'setVersion', |
103
|
66 |
|
]; |
104
|
|
|
|
105
|
132 |
|
foreach ($methods as $key => $method) { |
106
|
132 |
|
if (array_key_exists($key, $options)) { |
107
|
67 |
|
$this->$method($options[$key]); |
108
|
1 |
|
} |
109
|
66 |
|
} |
110
|
132 |
|
} |
111
|
|
|
} |
112
|
|
|
|