|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the WrikePhpSdk package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Zbigniew Ślązak |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Zibios\WrikePhpSdk\Api; |
|
12
|
|
|
|
|
13
|
|
|
use GuzzleHttp\ClientInterface; |
|
14
|
|
|
use JMS\Serializer\SerializerInterface; |
|
15
|
|
|
use Zibios\WrikePhpSdk\Api\Configs\ResponseClassesConfig; |
|
16
|
|
|
use Zibios\WrikePhpSdk\Enums\ResponseModeEnum; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Config |
|
20
|
|
|
*/ |
|
21
|
|
|
class Config implements ConfigInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/****************************************** |
|
24
|
|
|
* General Properties |
|
25
|
|
|
*****************************************/ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var ClientInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $client; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var SerializerInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $serializer; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
* @see ResponseModeEnum |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $responseMode = ResponseModeEnum::DOCUMENT; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var boolean |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $wrikeExceptionsMode = false; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var ResponseClassesConfig |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $responseClasses; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return ClientInterface |
|
55
|
|
|
*/ |
|
56
|
57 |
|
public function getClient() |
|
57
|
|
|
{ |
|
58
|
57 |
|
return $this->client; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param ClientInterface $client |
|
63
|
|
|
* |
|
64
|
|
|
* @return $this |
|
65
|
|
|
*/ |
|
66
|
59 |
|
public function setClient(ClientInterface $client) |
|
67
|
|
|
{ |
|
68
|
59 |
|
$this->client = $client; |
|
69
|
|
|
|
|
70
|
59 |
|
return $this; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @return SerializerInterface|null |
|
75
|
|
|
*/ |
|
76
|
22 |
|
public function getSerializer() |
|
77
|
|
|
{ |
|
78
|
22 |
|
return $this->serializer; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param SerializerInterface|null $serializer |
|
83
|
|
|
* |
|
84
|
|
|
* @return $this |
|
85
|
|
|
*/ |
|
86
|
59 |
|
public function setSerializer(SerializerInterface $serializer = null) |
|
87
|
|
|
{ |
|
88
|
59 |
|
$this->serializer = $serializer; |
|
89
|
|
|
|
|
90
|
59 |
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @see ResponseModeEnum |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
21 |
|
public function getResponseMode() |
|
98
|
|
|
{ |
|
99
|
21 |
|
return $this->responseMode; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param string $responseMode |
|
104
|
|
|
* |
|
105
|
|
|
* @see ResponseModeEnum |
|
106
|
|
|
* @throws \InvalidArgumentException |
|
107
|
|
|
* @return $this |
|
108
|
|
|
*/ |
|
109
|
59 |
|
public function setResponseMode($responseMode) |
|
110
|
|
|
{ |
|
111
|
59 |
|
ResponseModeEnum::assertIsValidValue($responseMode); |
|
112
|
59 |
|
$this->responseMode = $responseMode; |
|
113
|
|
|
|
|
114
|
59 |
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return bool |
|
119
|
|
|
*/ |
|
120
|
36 |
|
public function isWrikeExceptionsMode() |
|
121
|
|
|
{ |
|
122
|
36 |
|
return (boolean) $this->wrikeExceptionsMode; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @param bool $wrikeExceptionsMode |
|
127
|
|
|
* |
|
128
|
|
|
* @return $this |
|
129
|
|
|
*/ |
|
130
|
58 |
|
public function setWrikeExceptionsMode($wrikeExceptionsMode) |
|
131
|
|
|
{ |
|
132
|
58 |
|
$this->wrikeExceptionsMode = (boolean) $wrikeExceptionsMode; |
|
133
|
|
|
|
|
134
|
58 |
|
return $this; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return ResponseClassesConfig |
|
139
|
|
|
*/ |
|
140
|
56 |
|
public function getResponseClasses() |
|
141
|
|
|
{ |
|
142
|
56 |
|
if ($this->responseClasses === null) { |
|
143
|
56 |
|
$this->responseClasses = new ResponseClassesConfig(); |
|
144
|
56 |
|
} |
|
145
|
|
|
|
|
146
|
56 |
|
return $this->responseClasses; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @param ResponseClassesConfig $responseClasses |
|
151
|
|
|
* |
|
152
|
|
|
* @return $this |
|
153
|
|
|
*/ |
|
154
|
1 |
|
public function setResponseClasses(ResponseClassesConfig $responseClasses) |
|
155
|
|
|
{ |
|
156
|
1 |
|
$this->responseClasses = $responseClasses; |
|
157
|
|
|
|
|
158
|
1 |
|
return $this; |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|