1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* amadeus-ws-client |
4
|
|
|
* |
5
|
|
|
* Copyright 2015 Amadeus Benelux NV |
6
|
|
|
* |
7
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
8
|
|
|
* you may not use this file except in compliance with the License. |
9
|
|
|
* You may obtain a copy of the License at |
10
|
|
|
* |
11
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
12
|
|
|
* |
13
|
|
|
* Unless required by applicable law or agreed to in writing, software |
14
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
15
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16
|
|
|
* See the License for the specific language governing permissions and |
17
|
|
|
* limitations under the License. |
18
|
|
|
* |
19
|
|
|
* @package Amadeus |
20
|
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace Amadeus\Client\Struct\DocRefund\UpdateRefund; |
24
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\DocRefund\AddressOpt; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* StructuredAddress |
29
|
|
|
* |
30
|
|
|
* @package Amadeus\Client\Struct\DocRefund\UpdateRefund |
31
|
|
|
* @author Dieter Devlieghere <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
class StructuredAddress |
34
|
|
|
{ |
35
|
|
|
const TYPE_BILLING_ADDRESS = "AB"; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* self::TYPE_* |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
public $informationType; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var Address[] |
46
|
|
|
*/ |
47
|
|
|
public $address = []; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* StructuredAddress constructor. |
51
|
|
|
* |
52
|
|
|
* @param AddressOpt $opt |
53
|
|
|
*/ |
54
|
10 |
|
public function __construct(AddressOpt $opt) |
55
|
|
|
{ |
56
|
10 |
|
$this->informationType = $opt->type; |
57
|
|
|
|
58
|
10 |
|
$this->loadAddress($opt); |
59
|
10 |
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param AddressOpt $opt |
63
|
|
|
*/ |
64
|
10 |
|
protected function loadAddress($opt) |
65
|
|
|
{ |
66
|
10 |
|
if (!empty($opt->company)) { |
67
|
10 |
|
$this->address[] = new Address( |
68
|
10 |
|
Address::OPTION_COMPANY, |
69
|
10 |
|
$opt->company |
70
|
4 |
|
); |
71
|
4 |
|
} |
72
|
10 |
|
if (!empty($opt->name)) { |
73
|
10 |
|
$this->address[] = new Address( |
74
|
10 |
|
Address::OPTION_NAME, |
75
|
10 |
|
$opt->name |
76
|
4 |
|
); |
77
|
4 |
|
} |
78
|
10 |
|
if (!empty($opt->addressLine1)) { |
79
|
10 |
|
$this->address[] = new Address( |
80
|
10 |
|
Address::OPTION_ADDRESS_LINE_1, |
81
|
10 |
|
$opt->addressLine1 |
82
|
4 |
|
); |
83
|
4 |
|
} |
84
|
10 |
|
if (!empty($opt->addressLine2)) { |
85
|
5 |
|
$this->address[] = new Address( |
86
|
5 |
|
Address::OPTION_ADDRESS_LINE_2, |
87
|
5 |
|
$opt->addressLine2 |
88
|
2 |
|
); |
89
|
2 |
|
} |
90
|
10 |
|
if (!empty($opt->city)) { |
91
|
10 |
|
$this->address[] = new Address( |
92
|
10 |
|
Address::OPTION_CITY, |
93
|
10 |
|
$opt->city |
94
|
4 |
|
); |
95
|
4 |
|
} |
96
|
10 |
|
if (!empty($opt->country)) { |
97
|
10 |
|
$this->address[] = new Address( |
98
|
10 |
|
Address::OPTION_COUNTRY, |
99
|
10 |
|
$opt->country |
100
|
4 |
|
); |
101
|
4 |
|
} |
102
|
10 |
|
if (!empty($opt->poBox)) { |
103
|
5 |
|
$this->address[] = new Address( |
104
|
5 |
|
Address::OPTION_PO_BOX, |
105
|
5 |
|
$opt->poBox |
106
|
2 |
|
); |
107
|
2 |
|
} |
108
|
10 |
|
if (!empty($opt->postalCode)) { |
109
|
10 |
|
$this->address[] = new Address( |
110
|
10 |
|
Address::OPTION_POSTAL_CODE, |
111
|
10 |
|
$opt->postalCode |
112
|
4 |
|
); |
113
|
4 |
|
} |
114
|
10 |
|
if (!empty($opt->state)) { |
115
|
5 |
|
$this->address[] = new Address( |
116
|
5 |
|
Address::OPTION_STATE, |
117
|
5 |
|
$opt->state |
118
|
2 |
|
); |
119
|
2 |
|
} |
120
|
10 |
|
} |
121
|
|
|
} |
122
|
|
|
|