@@ -22,28 +22,6 @@ final class CalculateRouteMatrixRequest extends Input
22
22
*/
23
23
private $ calculatorName ;
24
24
25
- /**
26
- * Specifies route preferences when traveling by `Car`, such as avoiding routes that use ferries or tolls.
27
- *
28
- * Requirements: `TravelMode` must be specified as `Car`.
29
- *
30
- * @var CalculateRouteCarModeOptions|null
31
- */
32
- private $ carModeOptions ;
33
-
34
- /**
35
- * Sets the time of departure as the current time. Uses the current time to calculate the route matrix. You can't set
36
- * both `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic
37
- * conditions is used to calculate the route matrix.
38
- *
39
- * Default Value: `false`
40
- *
41
- * Valid Values: `false` | `true`
42
- *
43
- * @var bool|null
44
- */
45
- private $ departNow ;
46
-
47
25
/**
48
26
* The list of departure (origin) positions for the route matrix. An array of points, each of which is itself a 2-value
49
27
* array defined in WGS 84 [^1] format: `[longitude, latitude]`. For example, `[-123.115, 49.285]`.
@@ -67,21 +45,6 @@ final class CalculateRouteMatrixRequest extends Input
67
45
*/
68
46
private $ departurePositions ;
69
47
70
- /**
71
- * Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set both
72
- * `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic conditions
73
- * is used to calculate the route matrix.
74
- *
75
- * > Setting a departure time in the past returns a `400 ValidationException` error.
76
- *
77
- * - In ISO 8601 [^1] format: `YYYY-MM-DDThh:mm:ss.sssZ`. For example, `2020–07-2T12:15:20.000Z+01:00`
78
- *
79
- * [^1]: https://www.iso.org/iso-8601-date-and-time-format.html
80
- *
81
- * @var \DateTimeImmutable|null
82
- */
83
- private $ departureTime ;
84
-
85
48
/**
86
49
* The list of destination positions for the route matrix. An array of points, each of which is itself a 2-value array
87
50
* defined in WGS 84 [^1] format: `[longitude, latitude]`. For example, `[-122.339, 47.615]`.
@@ -105,24 +68,6 @@ final class CalculateRouteMatrixRequest extends Input
105
68
*/
106
69
private $ destinationPositions ;
107
70
108
- /**
109
- * Set the unit system to specify the distance.
110
- *
111
- * Default Value: `Kilometers`
112
- *
113
- * @var DistanceUnit::*|null
114
- */
115
- private $ distanceUnit ;
116
-
117
- /**
118
- * The optional API key [^1] to authorize the request.
119
- *
120
- * [^1]: https://docs.aws.amazon.com/location/latest/developerguide/using-apikeys.html
121
- *
122
- * @var string|null
123
- */
124
- private $ key ;
125
-
126
71
/**
127
72
* Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road
128
73
* compatibility.
@@ -147,6 +92,52 @@ final class CalculateRouteMatrixRequest extends Input
147
92
*/
148
93
private $ travelMode ;
149
94
95
+ /**
96
+ * Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set both
97
+ * `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic conditions
98
+ * is used to calculate the route matrix.
99
+ *
100
+ * > Setting a departure time in the past returns a `400 ValidationException` error.
101
+ *
102
+ * - In ISO 8601 [^1] format: `YYYY-MM-DDThh:mm:ss.sssZ`. For example, `2020–07-2T12:15:20.000Z+01:00`
103
+ *
104
+ * [^1]: https://www.iso.org/iso-8601-date-and-time-format.html
105
+ *
106
+ * @var \DateTimeImmutable|null
107
+ */
108
+ private $ departureTime ;
109
+
110
+ /**
111
+ * Sets the time of departure as the current time. Uses the current time to calculate the route matrix. You can't set
112
+ * both `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic
113
+ * conditions is used to calculate the route matrix.
114
+ *
115
+ * Default Value: `false`
116
+ *
117
+ * Valid Values: `false` | `true`
118
+ *
119
+ * @var bool|null
120
+ */
121
+ private $ departNow ;
122
+
123
+ /**
124
+ * Set the unit system to specify the distance.
125
+ *
126
+ * Default Value: `Kilometers`
127
+ *
128
+ * @var DistanceUnit::*|null
129
+ */
130
+ private $ distanceUnit ;
131
+
132
+ /**
133
+ * Specifies route preferences when traveling by `Car`, such as avoiding routes that use ferries or tolls.
134
+ *
135
+ * Requirements: `TravelMode` must be specified as `Car`.
136
+ *
137
+ * @var CalculateRouteCarModeOptions|null
138
+ */
139
+ private $ carModeOptions ;
140
+
150
141
/**
151
142
* Specifies route preferences when traveling by `Truck`, such as avoiding routes that use ferries or tolls, and truck
152
143
* specifications to consider when choosing an optimal road.
@@ -157,48 +148,57 @@ final class CalculateRouteMatrixRequest extends Input
157
148
*/
158
149
private $ truckModeOptions ;
159
150
151
+ /**
152
+ * The optional API key [^1] to authorize the request.
153
+ *
154
+ * [^1]: https://docs.aws.amazon.com/location/latest/developerguide/using-apikeys.html
155
+ *
156
+ * @var string|null
157
+ */
158
+ private $ key ;
159
+
160
160
/**
161
161
* @param array{
162
162
* CalculatorName?: string,
163
- * CarModeOptions?: null|CalculateRouteCarModeOptions|array,
164
- * DepartNow?: null|bool,
165
163
* DeparturePositions?: array[],
166
- * DepartureTime?: null|\DateTimeImmutable|string,
167
164
* DestinationPositions?: array[],
168
- * DistanceUnit?: null|DistanceUnit::*,
169
- * Key?: null|string,
170
165
* TravelMode?: null|TravelMode::*,
166
+ * DepartureTime?: null|\DateTimeImmutable|string,
167
+ * DepartNow?: null|bool,
168
+ * DistanceUnit?: null|DistanceUnit::*,
169
+ * CarModeOptions?: null|CalculateRouteCarModeOptions|array,
171
170
* TruckModeOptions?: null|CalculateRouteTruckModeOptions|array,
171
+ * Key?: null|string,
172
172
* '@region'?: string|null,
173
173
* } $input
174
174
*/
175
175
public function __construct (array $ input = [])
176
176
{
177
177
$ this ->calculatorName = $ input ['CalculatorName ' ] ?? null ;
178
- $ this ->carModeOptions = isset ($ input ['CarModeOptions ' ]) ? CalculateRouteCarModeOptions::create ($ input ['CarModeOptions ' ]) : null ;
179
- $ this ->departNow = $ input ['DepartNow ' ] ?? null ;
180
178
$ this ->departurePositions = $ input ['DeparturePositions ' ] ?? null ;
181
- $ this ->departureTime = !isset ($ input ['DepartureTime ' ]) ? null : ($ input ['DepartureTime ' ] instanceof \DateTimeImmutable ? $ input ['DepartureTime ' ] : new \DateTimeImmutable ($ input ['DepartureTime ' ]));
182
179
$ this ->destinationPositions = $ input ['DestinationPositions ' ] ?? null ;
183
- $ this ->distanceUnit = $ input ['DistanceUnit ' ] ?? null ;
184
- $ this ->key = $ input ['Key ' ] ?? null ;
185
180
$ this ->travelMode = $ input ['TravelMode ' ] ?? null ;
181
+ $ this ->departureTime = !isset ($ input ['DepartureTime ' ]) ? null : ($ input ['DepartureTime ' ] instanceof \DateTimeImmutable ? $ input ['DepartureTime ' ] : new \DateTimeImmutable ($ input ['DepartureTime ' ]));
182
+ $ this ->departNow = $ input ['DepartNow ' ] ?? null ;
183
+ $ this ->distanceUnit = $ input ['DistanceUnit ' ] ?? null ;
184
+ $ this ->carModeOptions = isset ($ input ['CarModeOptions ' ]) ? CalculateRouteCarModeOptions::create ($ input ['CarModeOptions ' ]) : null ;
186
185
$ this ->truckModeOptions = isset ($ input ['TruckModeOptions ' ]) ? CalculateRouteTruckModeOptions::create ($ input ['TruckModeOptions ' ]) : null ;
186
+ $ this ->key = $ input ['Key ' ] ?? null ;
187
187
parent ::__construct ($ input );
188
188
}
189
189
190
190
/**
191
191
* @param array{
192
192
* CalculatorName?: string,
193
- * CarModeOptions?: null|CalculateRouteCarModeOptions|array,
194
- * DepartNow?: null|bool,
195
193
* DeparturePositions?: array[],
196
- * DepartureTime?: null|\DateTimeImmutable|string,
197
194
* DestinationPositions?: array[],
198
- * DistanceUnit?: null|DistanceUnit::*,
199
- * Key?: null|string,
200
195
* TravelMode?: null|TravelMode::*,
196
+ * DepartureTime?: null|\DateTimeImmutable|string,
197
+ * DepartNow?: null|bool,
198
+ * DistanceUnit?: null|DistanceUnit::*,
199
+ * CarModeOptions?: null|CalculateRouteCarModeOptions|array,
201
200
* TruckModeOptions?: null|CalculateRouteTruckModeOptions|array,
201
+ * Key?: null|string,
202
202
* '@region'?: string|null,
203
203
* }|CalculateRouteMatrixRequest $input
204
204
*/
@@ -388,12 +388,6 @@ private function requestBody(): array
388
388
{
389
389
$ payload = [];
390
390
391
- if (null !== $ v = $ this ->carModeOptions ) {
392
- $ payload ['CarModeOptions ' ] = $ v ->requestBody ();
393
- }
394
- if (null !== $ v = $ this ->departNow ) {
395
- $ payload ['DepartNow ' ] = (bool ) $ v ;
396
- }
397
391
if (null === $ v = $ this ->departurePositions ) {
398
392
throw new InvalidArgument (sprintf ('Missing parameter "DeparturePositions" for "%s". The value cannot be null. ' , __CLASS__ ));
399
393
}
@@ -411,9 +405,6 @@ private function requestBody(): array
411
405
}
412
406
}
413
407
414
- if (null !== $ v = $ this ->departureTime ) {
415
- $ payload ['DepartureTime ' ] = $ v ->format (\DateTimeInterface::ATOM );
416
- }
417
408
if (null === $ v = $ this ->destinationPositions ) {
418
409
throw new InvalidArgument (sprintf ('Missing parameter "DestinationPositions" for "%s". The value cannot be null. ' , __CLASS__ ));
419
410
}
@@ -431,18 +422,26 @@ private function requestBody(): array
431
422
}
432
423
}
433
424
425
+ if (null !== $ v = $ this ->travelMode ) {
426
+ if (!TravelMode::exists ($ v )) {
427
+ throw new InvalidArgument (sprintf ('Invalid parameter "TravelMode" for "%s". The value "%s" is not a valid "TravelMode". ' , __CLASS__ , $ v ));
428
+ }
429
+ $ payload ['TravelMode ' ] = $ v ;
430
+ }
431
+ if (null !== $ v = $ this ->departureTime ) {
432
+ $ payload ['DepartureTime ' ] = $ v ->format (\DateTimeInterface::ATOM );
433
+ }
434
+ if (null !== $ v = $ this ->departNow ) {
435
+ $ payload ['DepartNow ' ] = (bool ) $ v ;
436
+ }
434
437
if (null !== $ v = $ this ->distanceUnit ) {
435
438
if (!DistanceUnit::exists ($ v )) {
436
439
throw new InvalidArgument (sprintf ('Invalid parameter "DistanceUnit" for "%s". The value "%s" is not a valid "DistanceUnit". ' , __CLASS__ , $ v ));
437
440
}
438
441
$ payload ['DistanceUnit ' ] = $ v ;
439
442
}
440
-
441
- if (null !== $ v = $ this ->travelMode ) {
442
- if (!TravelMode::exists ($ v )) {
443
- throw new InvalidArgument (sprintf ('Invalid parameter "TravelMode" for "%s". The value "%s" is not a valid "TravelMode". ' , __CLASS__ , $ v ));
444
- }
445
- $ payload ['TravelMode ' ] = $ v ;
443
+ if (null !== $ v = $ this ->carModeOptions ) {
444
+ $ payload ['CarModeOptions ' ] = $ v ->requestBody ();
446
445
}
447
446
if (null !== $ v = $ this ->truckModeOptions ) {
448
447
$ payload ['TruckModeOptions ' ] = $ v ->requestBody ();
0 commit comments