Skip to content

Commit

Permalink
Update generated code (#1623)
Browse files Browse the repository at this point in the history
update generated code
  • Loading branch information
async-aws-bot authored Dec 13, 2023
1 parent 1404d9d commit b789c5d
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions src/Enum/OptimizationMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace AsyncAws\LocationService\Enum;

final class OptimizationMode
{
public const FASTEST_ROUTE = 'FastestRoute';
public const SHORTEST_ROUTE = 'ShortestRoute';

public static function exists(string $value): bool
{
return isset([
self::FASTEST_ROUTE => true,
self::SHORTEST_ROUTE => true,
][$value]);
}
}
65 changes: 63 additions & 2 deletions src/Input/CalculateRouteRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -184,6 +200,7 @@ final class CalculateRouteRequest extends Input

/**
* @param array{
* ArrivalTime?: null|\DateTimeImmutable|string,
* CalculatorName?: string,
* CarModeOptions?: null|CalculateRouteCarModeOptions|array,
* DepartNow?: null|bool,
Expand All @@ -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[],
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -218,6 +238,7 @@ public function __construct(array $input = [])

/**
* @param array{
* ArrivalTime?: null|\DateTimeImmutable|string,
* CalculatorName?: string,
* CarModeOptions?: null|CalculateRouteCarModeOptions|array,
* DepartNow?: null|bool,
Expand All @@ -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[],
Expand All @@ -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;
Expand Down Expand Up @@ -292,6 +319,14 @@ public function getKey(): ?string
return $this->key;
}

/**
* @return OptimizationMode::*|null
*/
public function getOptimizeFor(): ?string
{
return $this->optimizeFor;
}

/**
* @return TravelMode::*|null
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions src/LocationServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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[],
Expand Down
1 change: 1 addition & 0 deletions src/Result/SearchPlaceIndexForPositionResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
1 change: 1 addition & 0 deletions src/Result/SearchPlaceIndexForTextResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
19 changes: 19 additions & 0 deletions src/ValueObject/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b789c5d

Please sign in to comment.