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\Pnr\AddMultiElements; |
24
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\Pnr\Element\Address as AddressOptions; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* StructuredAddress |
29
|
|
|
* |
30
|
|
|
* @package Amadeus\Client\Struct\Pnr\AddMultiElements |
31
|
|
|
* @author Dieter Devlieghere <[email protected]> |
32
|
|
|
*/ |
33
|
|
|
class StructuredAddress |
34
|
|
|
{ |
35
|
|
|
const TYPE_BILLING_ADDRESS = "2"; |
36
|
|
|
|
37
|
|
|
const TYPE_MAILING_ADDRESS = "P08"; |
38
|
|
|
|
39
|
|
|
const TYPE_MISC_ADDRESS = "P18"; |
40
|
|
|
|
41
|
|
|
const TYPE_HOME_MAILING_ADDRESS = "P24"; |
42
|
|
|
|
43
|
|
|
const TYPE_DELIVERY_MAILING_ADDRESS = "P25"; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
public $informationType; |
49
|
|
|
/** |
50
|
|
|
* @var Address |
51
|
|
|
*/ |
52
|
|
|
public $address; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var OptionalData[] |
56
|
|
|
*/ |
57
|
|
|
public $optionalData = []; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* StructuredAddress constructor. |
61
|
|
|
* |
62
|
|
|
* @param AddressOptions $params |
63
|
|
|
*/ |
64
|
10 |
|
public function __construct(AddressOptions $params) |
65
|
|
|
{ |
66
|
10 |
|
$this->informationType = $this->makeType($params->type); |
67
|
|
|
|
68
|
10 |
|
$this->address = new Address($params->addressLine1); |
69
|
|
|
|
70
|
10 |
|
if (!empty($params->addressLine2)) { |
71
|
10 |
|
$this->optionalData[] = new OptionalData( |
72
|
10 |
|
$params->addressLine2, |
73
|
6 |
|
OptionalData::OPT_ADDRESS_LINE_2 |
74
|
4 |
|
); |
75
|
4 |
|
}; |
76
|
|
|
|
77
|
10 |
|
if (!empty($params->city)) { |
78
|
10 |
|
$this->optionalData[] = new OptionalData( |
79
|
10 |
|
$params->city, |
80
|
6 |
|
OptionalData::OPT_CITY |
81
|
4 |
|
); |
82
|
4 |
|
}; |
83
|
|
|
|
84
|
10 |
|
if (!empty($params->country)) { |
85
|
10 |
|
$this->optionalData[] = new OptionalData( |
86
|
10 |
|
$params->country, |
87
|
6 |
|
OptionalData::OPT_COUNTRY |
88
|
4 |
|
); |
89
|
4 |
|
}; |
90
|
|
|
|
91
|
10 |
|
if (!empty($params->name)) { |
92
|
10 |
|
$this->optionalData[] = new OptionalData( |
93
|
10 |
|
$params->name, |
94
|
6 |
|
OptionalData::OPT_NAME |
95
|
4 |
|
); |
96
|
4 |
|
}; |
97
|
|
|
|
98
|
10 |
|
if (!empty($params->state)) { |
99
|
10 |
|
$this->optionalData[] = new OptionalData( |
100
|
10 |
|
$params->state, |
101
|
6 |
|
OptionalData::OPT_STATE |
102
|
4 |
|
); |
103
|
4 |
|
}; |
104
|
|
|
|
105
|
10 |
|
if (!empty($params->zipCode)) { |
106
|
10 |
|
$this->optionalData[] = new OptionalData( |
107
|
10 |
|
$params->zipCode, |
108
|
6 |
|
OptionalData::OPT_ZIP_CODE |
109
|
4 |
|
); |
110
|
4 |
|
}; |
111
|
|
|
|
112
|
10 |
|
if (!empty($params->company)) { |
113
|
10 |
|
$this->optionalData[] = new OptionalData( |
114
|
10 |
|
$params->company, |
115
|
6 |
|
OptionalData::OPT_COMPANY |
116
|
4 |
|
); |
117
|
4 |
|
}; |
118
|
10 |
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param string $segmentType |
122
|
|
|
* @return string|null |
123
|
|
|
*/ |
124
|
10 |
|
protected function makeType($segmentType) |
125
|
|
|
{ |
126
|
10 |
|
$infType = null; |
127
|
|
|
|
128
|
10 |
|
if ($segmentType === ElementManagementData::SEGNAME_ADDRESS_BILLING_STRUCTURED) { |
129
|
5 |
|
$infType = self::TYPE_BILLING_ADDRESS; |
130
|
7 |
|
} elseif ($segmentType === ElementManagementData::SEGNAME_ADDRESS_MAILING_STRUCTURED) { |
131
|
5 |
|
$infType = self::TYPE_MAILING_ADDRESS; |
132
|
2 |
|
} |
133
|
|
|
|
134
|
10 |
|
return $infType; |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|