From b789c5d5e30cddf75fbd5926a2084d5f18a9ab01 Mon Sep 17 00:00:00 2001 From: AsyncAws <61784373+async-aws-bot@users.noreply.github.com> Date: Wed, 13 Dec 2023 00:11:40 -0800 Subject: [PATCH] Update generated code (#1623) update generated code --- CHANGELOG.md | 1 + src/Enum/OptimizationMode.php | 17 +++++ src/Input/CalculateRouteRequest.php | 65 ++++++++++++++++++- src/LocationServiceClient.php | 3 + .../SearchPlaceIndexForPositionResponse.php | 1 + .../SearchPlaceIndexForTextResponse.php | 1 + src/ValueObject/Place.php | 19 ++++++ 7 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 src/Enum/OptimizationMode.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c0e8fc..48aea61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - AWS api-change: Added `fips-us-gov-west-1` region +- AWS api-change: This release 1) adds sub-municipality field in Places API for searching and getting places information, and 2) allows optimizing route calculation based on expected arrival time. ### Changed diff --git a/src/Enum/OptimizationMode.php b/src/Enum/OptimizationMode.php new file mode 100644 index 0000000..1ac56b5 --- /dev/null +++ b/src/Enum/OptimizationMode.php @@ -0,0 +1,17 @@ + true, + self::SHORTEST_ROUTE => true, + ][$value]); + } +} diff --git a/src/Input/CalculateRouteRequest.php b/src/Input/CalculateRouteRequest.php index afc1f0f..b15a23e 100644 --- a/src/Input/CalculateRouteRequest.php +++ b/src/Input/CalculateRouteRequest.php @@ -7,12 +7,23 @@ use AsyncAws\Core\Request; use AsyncAws\Core\Stream\StreamFactory; use AsyncAws\LocationService\Enum\DistanceUnit; +use AsyncAws\LocationService\Enum\OptimizationMode; use AsyncAws\LocationService\Enum\TravelMode; use AsyncAws\LocationService\ValueObject\CalculateRouteCarModeOptions; use AsyncAws\LocationService\ValueObject\CalculateRouteTruckModeOptions; final class CalculateRouteRequest extends Input { + /** + * Specifies the desired time of arrival. Uses the given time to calculate the route. Otherwise, the best time of day to + * travel with the best traffic conditions is used to calculate the route. + * + * > ArrivalTime is not supported Esri. + * + * @var \DateTimeImmutable|null + */ + private $arrivalTime; + /** * The name of the route calculator resource that you want to use to calculate the route. * @@ -67,8 +78,6 @@ final class CalculateRouteRequest extends Input * Specifies the desired time of departure. Uses the given time to calculate the route. Otherwise, the best time of day * to travel with the best traffic conditions is used to calculate the route. * - * > Setting a departure time in the past returns a `400 ValidationException` error. - * * - In ISO 8601 [^1] format: `YYYY-MM-DDThh:mm:ss.sssZ`. For example, `2020–07-2T12:15:20.000Z+01:00` * * [^1]: https://www.iso.org/iso-8601-date-and-time-format.html @@ -125,6 +134,13 @@ final class CalculateRouteRequest extends Input */ private $key; + /** + * Specifies the distance to optimize for when calculating a route. + * + * @var OptimizationMode::*|null + */ + private $optimizeFor; + /** * Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road * compatibility. You can choose `Car`, `Truck`, `Walking`, `Bicycle` or `Motorcycle` as options for the `TravelMode`. @@ -184,6 +200,7 @@ final class CalculateRouteRequest extends Input /** * @param array{ + * ArrivalTime?: null|\DateTimeImmutable|string, * CalculatorName?: string, * CarModeOptions?: null|CalculateRouteCarModeOptions|array, * DepartNow?: null|bool, @@ -193,6 +210,7 @@ final class CalculateRouteRequest extends Input * DistanceUnit?: null|DistanceUnit::*, * IncludeLegGeometry?: null|bool, * Key?: null|string, + * OptimizeFor?: null|OptimizationMode::*, * TravelMode?: null|TravelMode::*, * TruckModeOptions?: null|CalculateRouteTruckModeOptions|array, * WaypointPositions?: null|array[], @@ -201,6 +219,7 @@ final class CalculateRouteRequest extends Input */ public function __construct(array $input = []) { + $this->arrivalTime = !isset($input['ArrivalTime']) ? null : ($input['ArrivalTime'] instanceof \DateTimeImmutable ? $input['ArrivalTime'] : new \DateTimeImmutable($input['ArrivalTime'])); $this->calculatorName = $input['CalculatorName'] ?? null; $this->carModeOptions = isset($input['CarModeOptions']) ? CalculateRouteCarModeOptions::create($input['CarModeOptions']) : null; $this->departNow = $input['DepartNow'] ?? null; @@ -210,6 +229,7 @@ public function __construct(array $input = []) $this->distanceUnit = $input['DistanceUnit'] ?? null; $this->includeLegGeometry = $input['IncludeLegGeometry'] ?? null; $this->key = $input['Key'] ?? null; + $this->optimizeFor = $input['OptimizeFor'] ?? null; $this->travelMode = $input['TravelMode'] ?? null; $this->truckModeOptions = isset($input['TruckModeOptions']) ? CalculateRouteTruckModeOptions::create($input['TruckModeOptions']) : null; $this->waypointPositions = $input['WaypointPositions'] ?? null; @@ -218,6 +238,7 @@ public function __construct(array $input = []) /** * @param array{ + * ArrivalTime?: null|\DateTimeImmutable|string, * CalculatorName?: string, * CarModeOptions?: null|CalculateRouteCarModeOptions|array, * DepartNow?: null|bool, @@ -227,6 +248,7 @@ public function __construct(array $input = []) * DistanceUnit?: null|DistanceUnit::*, * IncludeLegGeometry?: null|bool, * Key?: null|string, + * OptimizeFor?: null|OptimizationMode::*, * TravelMode?: null|TravelMode::*, * TruckModeOptions?: null|CalculateRouteTruckModeOptions|array, * WaypointPositions?: null|array[], @@ -238,6 +260,11 @@ public static function create($input): self return $input instanceof self ? $input : new self($input); } + public function getArrivalTime(): ?\DateTimeImmutable + { + return $this->arrivalTime; + } + public function getCalculatorName(): ?string { return $this->calculatorName; @@ -292,6 +319,14 @@ public function getKey(): ?string return $this->key; } + /** + * @return OptimizationMode::*|null + */ + public function getOptimizeFor(): ?string + { + return $this->optimizeFor; + } + /** * @return TravelMode::*|null */ @@ -343,6 +378,13 @@ public function request(): Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body), 'routes.'); } + public function setArrivalTime(?\DateTimeImmutable $value): self + { + $this->arrivalTime = $value; + + return $this; + } + public function setCalculatorName(?string $value): self { $this->calculatorName = $value; @@ -415,6 +457,16 @@ public function setKey(?string $value): self return $this; } + /** + * @param OptimizationMode::*|null $value + */ + public function setOptimizeFor(?string $value): self + { + $this->optimizeFor = $value; + + return $this; + } + /** * @param TravelMode::*|null $value */ @@ -445,6 +497,9 @@ public function setWaypointPositions(array $value): self private function requestBody(): array { $payload = []; + if (null !== $v = $this->arrivalTime) { + $payload['ArrivalTime'] = $v->format(\DateTimeInterface::ATOM); + } if (null !== $v = $this->carModeOptions) { $payload['CarModeOptions'] = $v->requestBody(); @@ -487,6 +542,12 @@ private function requestBody(): array $payload['IncludeLegGeometry'] = (bool) $v; } + if (null !== $v = $this->optimizeFor) { + if (!OptimizationMode::exists($v)) { + throw new InvalidArgument(sprintf('Invalid parameter "OptimizeFor" for "%s". The value "%s" is not a valid "OptimizationMode".', __CLASS__, $v)); + } + $payload['OptimizeFor'] = $v; + } if (null !== $v = $this->travelMode) { if (!TravelMode::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "TravelMode" for "%s". The value "%s" is not a valid "TravelMode".', __CLASS__, $v)); diff --git a/src/LocationServiceClient.php b/src/LocationServiceClient.php index 037678d..69354fe 100644 --- a/src/LocationServiceClient.php +++ b/src/LocationServiceClient.php @@ -8,6 +8,7 @@ use AsyncAws\Core\Configuration; use AsyncAws\Core\RequestContext; use AsyncAws\LocationService\Enum\DistanceUnit; +use AsyncAws\LocationService\Enum\OptimizationMode; use AsyncAws\LocationService\Enum\TravelMode; use AsyncAws\LocationService\Exception\AccessDeniedException; use AsyncAws\LocationService\Exception\InternalServerException; @@ -58,6 +59,7 @@ class LocationServiceClient extends AbstractApi * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-geo-2020-11-19.html#calculateroute * * @param array{ + * ArrivalTime?: null|\DateTimeImmutable|string, * CalculatorName: string, * CarModeOptions?: null|CalculateRouteCarModeOptions|array, * DepartNow?: null|bool, @@ -67,6 +69,7 @@ class LocationServiceClient extends AbstractApi * DistanceUnit?: null|DistanceUnit::*, * IncludeLegGeometry?: null|bool, * Key?: null|string, + * OptimizeFor?: null|OptimizationMode::*, * TravelMode?: null|TravelMode::*, * TruckModeOptions?: null|CalculateRouteTruckModeOptions|array, * WaypointPositions?: null|array[], diff --git a/src/Result/SearchPlaceIndexForPositionResponse.php b/src/Result/SearchPlaceIndexForPositionResponse.php index 9fcd8b2..bfb900c 100644 --- a/src/Result/SearchPlaceIndexForPositionResponse.php +++ b/src/Result/SearchPlaceIndexForPositionResponse.php @@ -67,6 +67,7 @@ private function populateResultPlace(array $json): Place 'PostalCode' => isset($json['PostalCode']) ? (string) $json['PostalCode'] : null, 'Region' => isset($json['Region']) ? (string) $json['Region'] : null, 'Street' => isset($json['Street']) ? (string) $json['Street'] : null, + 'SubMunicipality' => isset($json['SubMunicipality']) ? (string) $json['SubMunicipality'] : null, 'SubRegion' => isset($json['SubRegion']) ? (string) $json['SubRegion'] : null, 'SupplementalCategories' => !isset($json['SupplementalCategories']) ? null : $this->populateResultPlaceSupplementalCategoryList($json['SupplementalCategories']), 'TimeZone' => empty($json['TimeZone']) ? null : $this->populateResultTimeZone($json['TimeZone']), diff --git a/src/Result/SearchPlaceIndexForTextResponse.php b/src/Result/SearchPlaceIndexForTextResponse.php index b2138db..3b44b75 100644 --- a/src/Result/SearchPlaceIndexForTextResponse.php +++ b/src/Result/SearchPlaceIndexForTextResponse.php @@ -119,6 +119,7 @@ private function populateResultPlace(array $json): Place 'PostalCode' => isset($json['PostalCode']) ? (string) $json['PostalCode'] : null, 'Region' => isset($json['Region']) ? (string) $json['Region'] : null, 'Street' => isset($json['Street']) ? (string) $json['Street'] : null, + 'SubMunicipality' => isset($json['SubMunicipality']) ? (string) $json['SubMunicipality'] : null, 'SubRegion' => isset($json['SubRegion']) ? (string) $json['SubRegion'] : null, 'SupplementalCategories' => !isset($json['SupplementalCategories']) ? null : $this->populateResultPlaceSupplementalCategoryList($json['SupplementalCategories']), 'TimeZone' => empty($json['TimeZone']) ? null : $this->populateResultTimeZone($json['TimeZone']), diff --git a/src/ValueObject/Place.php b/src/ValueObject/Place.php index c4fdacc..fd0cc71 100644 --- a/src/ValueObject/Place.php +++ b/src/ValueObject/Place.php @@ -103,6 +103,17 @@ final class Place */ private $street; + /** + * An area that's part of a larger municipality. For example, `Blissville ` is a submunicipality in the Queen County in + * New York. + * + * > This property supported by Esri and OpenData. The Esri property is `district`, and the OpenData property is + * > `borough`. + * + * @var string|null + */ + private $subMunicipality; + /** * A county, or an area that's part of a larger region. For example, `Metro Vancouver`. * @@ -157,6 +168,7 @@ final class Place * PostalCode?: null|string, * Region?: null|string, * Street?: null|string, + * SubMunicipality?: null|string, * SubRegion?: null|string, * SupplementalCategories?: null|string[], * TimeZone?: null|TimeZone|array, @@ -177,6 +189,7 @@ public function __construct(array $input) $this->postalCode = $input['PostalCode'] ?? null; $this->region = $input['Region'] ?? null; $this->street = $input['Street'] ?? null; + $this->subMunicipality = $input['SubMunicipality'] ?? null; $this->subRegion = $input['SubRegion'] ?? null; $this->supplementalCategories = $input['SupplementalCategories'] ?? null; $this->timeZone = isset($input['TimeZone']) ? TimeZone::create($input['TimeZone']) : null; @@ -197,6 +210,7 @@ public function __construct(array $input) * PostalCode?: null|string, * Region?: null|string, * Street?: null|string, + * SubMunicipality?: null|string, * SubRegion?: null|string, * SupplementalCategories?: null|string[], * TimeZone?: null|TimeZone|array, @@ -267,6 +281,11 @@ public function getStreet(): ?string return $this->street; } + public function getSubMunicipality(): ?string + { + return $this->subMunicipality; + } + public function getSubRegion(): ?string { return $this->subRegion;