|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* For the full copyright and license information, please view the LICENSE file |
|
5
|
|
|
* that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare ( |
|
9
|
|
|
strict_types = 1 |
|
10
|
|
|
); |
|
11
|
|
|
|
|
12
|
|
|
namespace Component\Remote\BurzeDzisNet; |
|
13
|
|
|
|
|
14
|
|
|
use SoapClient; |
|
15
|
|
|
use SoapFault; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Endpoint interface is the entry point end a burze.dzis.net service |
|
19
|
|
|
* |
|
20
|
|
|
* @author Krzysztof Piasecki <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class Endpoint implements EndpointInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* URI of WSDL file |
|
26
|
|
|
* |
|
27
|
|
|
* @var string URI of WSDL file |
|
28
|
|
|
*/ |
|
29
|
|
|
private $wsdl = 'https://burze.dzis.net/soap.php?WSDL'; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* API key. |
|
33
|
|
|
* |
|
34
|
|
|
* @var string API key |
|
35
|
|
|
*/ |
|
36
|
|
|
private $apiKey; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Custom options |
|
40
|
|
|
* |
|
41
|
|
|
* @var array custom options |
|
42
|
|
|
*/ |
|
43
|
|
|
private $options; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Constructor. |
|
47
|
|
|
* |
|
48
|
|
|
* Custom options will be used as an argument when calling {@see client} method |
|
49
|
|
|
* |
|
50
|
|
|
* @param string $apiKey API key |
|
51
|
|
|
* @param array $options custom soap options |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct(string $apiKey, array $options = []) |
|
54
|
|
|
{ |
|
55
|
|
|
$this->apiKey = $apiKey; |
|
56
|
|
|
$this->options = $options; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get Soap client in WSDL mode |
|
61
|
|
|
* |
|
62
|
|
|
* @see __construct() Customizing client with option parameter |
|
63
|
|
|
* @see {@link \SoapClient http://php.net/manual/en/class.soapclient.php} SoapClient |
|
64
|
|
|
* @return SoapClient SoapClient in WSDL mode |
|
65
|
|
|
* @throws SoapFault if the WSDL URI cannot be loaded or parsed |
|
66
|
|
|
*/ |
|
67
|
|
|
public function client(): SoapClient |
|
68
|
|
|
{ |
|
69
|
|
|
return new SoapClient($this->wsdl(), $this->options()); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get URI of WSDL file |
|
74
|
|
|
* |
|
75
|
|
|
* @return string URI of WSDL file |
|
76
|
|
|
*/ |
|
77
|
|
|
public function wsdl(): string |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->wsdl; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get API key |
|
84
|
|
|
* |
|
85
|
|
|
* @return string API key |
|
86
|
|
|
*/ |
|
87
|
|
|
public function apiKey(): string |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->apiKey; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get options |
|
94
|
|
|
* |
|
95
|
|
|
* @return array endpoint options |
|
96
|
|
|
*/ |
|
97
|
|
|
public function options(): array |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->options; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|