1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* amadeus-ws-client |
5
|
|
|
* |
6
|
|
|
* Copyright 2015 Amadeus Benelux NV |
7
|
|
|
* |
8
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
9
|
|
|
* you may not use this file except in compliance with the License. |
10
|
|
|
* You may obtain a copy of the License at |
11
|
|
|
* |
12
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
13
|
|
|
* |
14
|
|
|
* Unless required by applicable law or agreed to in writing, software |
15
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
16
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17
|
|
|
* See the License for the specific language governing permissions and |
18
|
|
|
* limitations under the License. |
19
|
|
|
* |
20
|
|
|
* @package Amadeus |
21
|
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace Amadeus\Client\Struct\Pay; |
25
|
|
|
|
26
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
27
|
|
|
use Amadeus\Client\RequestOptions\PayListVirtualCardsOptions; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* ListVirtualCards |
31
|
|
|
* |
32
|
|
|
* @package Amadeus\Client\Struct\Pay |
33
|
|
|
* @author Konstantin Bogomolov <[email protected]> |
34
|
|
|
*/ |
35
|
|
|
class ListVirtualCards extends BaseWsMessage |
36
|
|
|
{ |
37
|
|
|
public $Version = '2.0'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $SubType; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
public $VendorCode; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var AmountRange |
51
|
|
|
*/ |
52
|
|
|
public $AmountRange; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
public $CurrencyCode; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var \SoapVar |
61
|
|
|
*/ |
62
|
|
|
public $Period; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var string |
66
|
|
|
*/ |
67
|
|
|
public $CardStatus; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @var Reservation |
71
|
|
|
*/ |
72
|
|
|
public $Reservation; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* ListVirtualCards constructor. |
76
|
|
|
* @param PayListVirtualCardsOptions $params |
77
|
|
|
*/ |
78
|
|
|
public function __construct(PayListVirtualCardsOptions $params) |
79
|
|
|
{ |
80
|
|
|
if ($params->SubType !== null) { |
81
|
|
|
$this->SubType = $params->SubType; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if ($params->VendorCode !== null) { |
85
|
|
|
$this->VendorCode = $params->VendorCode; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
if ($params->AmountRange !== null) { |
89
|
|
|
$this->AmountRange = new AmountRange($params); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
if ($params->CurrencyCode !== null) { |
93
|
|
|
$this->CurrencyCode = $params->CurrencyCode; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
$period = $params->Period; |
97
|
|
|
|
98
|
|
|
if ($period !== null) { |
99
|
|
|
/** |
100
|
|
|
* For unknown reason, the SOAP client does not generate proper XML with attributes for Period node. |
101
|
|
|
* Expected to have <Period Start="2017-04-01" End="2017-04-1" EventType="Creation" /> |
102
|
|
|
* But generated XML never contains "Start" and "End" attributes (by the way "EventType" present). |
103
|
|
|
* This SoapVar solution is not ideal, but at least it works. |
104
|
|
|
*/ |
105
|
|
|
$periodAttributes = array_filter([ |
106
|
|
|
'Start' => $period->start?->format('Y-m-d'), |
107
|
|
|
'End' => $period->end?->format('Y-m-d'), |
108
|
|
|
'EventType' => $period->eventType, |
109
|
|
|
]); |
110
|
|
|
|
111
|
|
|
// Result is <ns1:Period Start="2017-04-01" End="2017-04-1" EventType="Creation" /> |
112
|
|
|
$xml = sprintf( |
113
|
|
|
'<ns1:Period %s ></ns1:Period>', |
114
|
|
|
implode( |
115
|
|
|
' ', |
116
|
|
|
array_map( |
117
|
|
|
static fn (string $key, string $value): string => sprintf('%s="%s"', $key, $value), |
118
|
|
|
array_keys($periodAttributes), |
119
|
|
|
$periodAttributes, |
120
|
|
|
), |
121
|
|
|
), |
122
|
|
|
); |
123
|
|
|
$this->Period = new \SoapVar($xml, XSD_ANYXML); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
if ($params->CardStatus !== null) { |
127
|
|
|
$this->CardStatus = $params->CardStatus; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
if ($params->Reservation !== null) { |
131
|
|
|
$this->Reservation = new Reservation($params); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|