|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Raigu\XRoad\SoapEnvelope; |
|
4
|
|
|
|
|
5
|
|
|
use Raigu\XRoad\SoapEnvelope\Element\DOMElementInjection; |
|
6
|
|
|
use Raigu\XRoad\SoapEnvelope\Element\FragmentInjection; |
|
7
|
|
|
use Raigu\XRoad\SoapEnvelope\Element\XmlInjectable; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* I am factory of X-Road SOAP Envelope elements. |
|
11
|
|
|
*/ |
|
12
|
|
|
final class XRoadSoapMessageElementsFactory |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param string $reference encoded service. |
|
16
|
|
|
* Format: {xRoadInstance}/{memberClass/{memberCode}/{subsystemCode}/{serviceCode}/{serviceVerson} |
|
17
|
|
|
* Example: EE/GOV/70000310/DHX.Riigi-Teataja/sendDocument/v1 |
|
18
|
|
|
* @return XmlInjectable |
|
19
|
|
|
*/ |
|
20
|
1 |
|
public function service(string $reference): XmlInjectable |
|
21
|
|
|
{ |
|
22
|
1 |
|
return (new ServiceFactory())->fromStr($reference); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @param string $reference encoded client. |
|
27
|
|
|
* Format: {xRoadInstance}/{memberClass/{memberCode}/{subsystemCode} |
|
28
|
|
|
* Example: EE/COM/00000000/sys |
|
29
|
|
|
* @return XmlInjectable |
|
30
|
|
|
*/ |
|
31
|
1 |
|
public function client(string $reference): XmlInjectable |
|
32
|
|
|
{ |
|
33
|
1 |
|
return (new ClientFactory)->fromStr($reference); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param string $serviceRequest service request |
|
38
|
|
|
* @return XmlInjectable |
|
39
|
|
|
*/ |
|
40
|
1 |
|
public function body(string $serviceRequest): XmlInjectable |
|
41
|
|
|
{ |
|
42
|
1 |
|
return new FragmentInjection( |
|
43
|
1 |
|
'http://schemas.xmlsoap.org/soap/envelope/', |
|
44
|
1 |
|
'Body', |
|
45
|
1 |
|
$serviceRequest |
|
46
|
|
|
); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string $userId the user who is making the request |
|
51
|
|
|
* Format: {iso2LetterCountryCode}{personCode} |
|
52
|
|
|
* Example: EE0000000000 |
|
53
|
|
|
* @return XmlInjectable |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function userId(string $userId): XmlInjectable |
|
56
|
|
|
{ |
|
57
|
1 |
|
return new DOMElementInjection( |
|
58
|
1 |
|
'http://schemas.xmlsoap.org/soap/envelope/', |
|
59
|
1 |
|
'Header', |
|
60
|
1 |
|
new \DOMElement( |
|
61
|
1 |
|
'userId', |
|
62
|
1 |
|
(new ValidatedUserId($userId))->asStr(), |
|
63
|
1 |
|
'http://x-road.eu/xsd/xroad.xsd' |
|
64
|
|
|
) |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @see https://x-tee.ee/docs/live/xroad/pr-third_party_representation_extension.html |
|
70
|
|
|
* @param string $reference string representing representative party. format: [{partyClass}/]{partyCode} |
|
71
|
|
|
* String is concatenation of represented party class (optional) and code in separated by /. |
|
72
|
|
|
* @return XmlInjectable |
|
73
|
|
|
*/ |
|
74
|
1 |
|
public static function representedParty(string $reference): XmlInjectable |
|
75
|
|
|
{ |
|
76
|
1 |
|
return (new RepresentedPartyFactory)->fromStr($reference); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|