1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WebservicesNl\Protocol\Soap\Config\Platform\Webservices; |
4
|
|
|
|
5
|
|
|
use WebservicesNl\Platform\Webservices\PlatformConfig; |
6
|
|
|
use WebservicesNl\Protocol\Soap\Client\SoapConfig; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class WebservicesConfig. |
10
|
|
|
* |
11
|
|
|
* Container for all settings to connect to Webservices platform. User credentials and time out settings. etc |
12
|
|
|
*/ |
13
|
|
|
class Config extends SoapConfig |
14
|
|
|
{ |
15
|
|
|
const DEFAULT_RESPONSE_TIMEOUT = 20; |
16
|
|
|
const RETRY_MINUTES = 60; |
17
|
|
|
const SOAPHEADER_URL = 'http://www.webservices.nl/soap/'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* List with Soap Server endpoints. |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected static $endPoints = [ |
25
|
|
|
'https://ws1.webservices.nl/soap', |
26
|
|
|
'https://ws2.webservices.nl/soap', |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Config constructor. |
31
|
|
|
* |
32
|
|
|
* @param PlatformConfig $config |
33
|
|
|
*/ |
34
|
11 |
|
public function __construct(PlatformConfig $config) |
35
|
|
|
{ |
36
|
11 |
|
$this->converter = Converter::build(); |
37
|
11 |
|
$this->soapHeaders[] = new \SoapHeader( |
38
|
11 |
|
self::SOAPHEADER_URL, |
39
|
11 |
|
'HeaderLogin', |
40
|
|
|
[ |
41
|
11 |
|
'username' => $config->getUserName(), |
42
|
11 |
|
'password' => $config->getPassword(), |
43
|
11 |
|
], |
44
|
|
|
true |
45
|
11 |
|
); |
46
|
|
|
|
47
|
11 |
|
parent::__construct($config); |
48
|
11 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return Converter |
52
|
|
|
*/ |
53
|
10 |
|
public function getConverter() |
54
|
|
|
{ |
55
|
10 |
|
return $this->converter; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return int |
60
|
|
|
*/ |
61
|
1 |
|
public function getConnectionTimeout() |
62
|
|
|
{ |
63
|
1 |
|
return $this->getPlatformConfig()->getConnectionTimeout(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
1 |
|
public function getPassword() |
70
|
|
|
{ |
71
|
1 |
|
return $this->getPlatformConfig()->getPassword(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return int |
76
|
|
|
*/ |
77
|
1 |
|
public function getRetryMinutes() |
78
|
|
|
{ |
79
|
1 |
|
return $this->getPlatformConfig()->getRetryMinutes(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return int |
84
|
|
|
*/ |
85
|
1 |
|
public function getResponseTimeout() |
86
|
|
|
{ |
87
|
1 |
|
return $this->getPlatformConfig()->getResponseTimeout(); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
9 |
|
public function getSoapHeaders() |
94
|
|
|
{ |
95
|
9 |
|
return $this->soapHeaders; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return string |
100
|
|
|
*/ |
101
|
2 |
|
public function getUserName() |
102
|
|
|
{ |
103
|
2 |
|
return $this->getPlatformConfig()->getUserName(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
2 |
|
public function toArray() |
110
|
|
|
{ |
111
|
2 |
|
return array_filter([ |
112
|
2 |
|
'converter' => $this->getConverter(), |
113
|
2 |
|
'connection_timeout' => $this->getPlatformConfig()->getConnectionTimeout(), |
114
|
2 |
|
'endpoints' => self::$endPoints, |
115
|
2 |
|
'password' => $this->getPlatformConfig()->getPassword(), |
116
|
2 |
|
'retry_minutes' => $this->getPlatformConfig()->getRetryMinutes(), |
117
|
2 |
|
'soap_headers' => (array)$this->getSoapHeaders(), |
118
|
2 |
|
'timeout' => $this->getPlatformConfig()->getResponseTimeout(), |
119
|
2 |
|
'username' => $this->getPlatformConfig()->getUserName(), |
120
|
2 |
|
]); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return PlatformConfig |
125
|
|
|
*/ |
126
|
10 |
|
public function getPlatformConfig() |
127
|
|
|
{ |
128
|
10 |
|
return $this->platformConfig; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|