|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace TK\API\ValueObject; |
|
5
|
|
|
|
|
6
|
|
|
use TK\API\Exception\InvalidArgumentException; |
|
7
|
|
|
|
|
8
|
|
|
final class GetAvailabilityParameters implements ValueObjectInterface |
|
9
|
|
|
{ |
|
10
|
|
|
public const ROUTING_TYPE_ROUND_TRIP = 'r'; |
|
11
|
|
|
public const ROUTING_TYPE_ONE_WAY = 'o'; |
|
12
|
|
|
public const REDUCED_DATA_INDICATOR_TRUE = true; |
|
13
|
|
|
public const REDUCED_DATA_INDICATOR_FALSE = false; |
|
14
|
|
|
|
|
15
|
|
|
private static $routingTypeEnum = ['o', 'r']; |
|
16
|
|
|
|
|
17
|
|
|
private $queryParameters = [ |
|
18
|
|
|
'OriginDestinationInformation' => [], |
|
19
|
|
|
'ReducedDataIndicator' => false |
|
20
|
|
|
]; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct( |
|
23
|
|
|
bool $reducedDataIndicator, |
|
24
|
|
|
string $routingType, |
|
25
|
|
|
PassengerTypeQuantity $passengerTypeQuantity |
|
26
|
|
|
) { |
|
27
|
|
|
$this->queryParameters['ReducedDataIndicator'] = $reducedDataIndicator; |
|
28
|
|
|
$this->setRoutingType($routingType); |
|
29
|
|
|
$this->queryParameters['PassengerTypeQuantity'] = $passengerTypeQuantity->getValue(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
private function setRoutingType(string $routingType) : void |
|
33
|
|
|
{ |
|
34
|
|
|
if (!\in_array($routingType, self::$routingTypeEnum, true)) { |
|
35
|
|
|
throw new InvalidArgumentException( |
|
36
|
|
|
'Invalid Trip Type. Possible values are "' . |
|
37
|
|
|
implode(', ', self::$routingTypeEnum) . '"' . |
|
38
|
|
|
' but provided value is "' . $routingType . '"' |
|
39
|
|
|
); |
|
40
|
|
|
} |
|
41
|
|
|
$this->queryParameters['RoutingType'] = $routingType; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function withTargetSource() : GetAvailabilityParameters |
|
45
|
|
|
{ |
|
46
|
|
|
$this->queryParameters['TargetSource'] = 'AWT'; |
|
47
|
|
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function withOriginDestinationInformation( |
|
51
|
|
|
OriginDestinationInformation $originDestinationInformation |
|
52
|
|
|
) : GetAvailabilityParameters { |
|
53
|
|
|
$this->queryParameters['OriginDestinationInformation'][] = $originDestinationInformation->getValue(); |
|
54
|
|
|
return $this; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getValue() : array |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->queryParameters; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|