Skip to content

Commit

Permalink
Update generated code (#1722)
Browse files Browse the repository at this point in the history
* update generated code

* Update src/Service/LocationService/CHANGELOG.md

---------

Co-authored-by: Jérémy Derussé <[email protected]>
  • Loading branch information
async-aws-bot and jderusse authored Jun 7, 2024
1 parent 9960016 commit d77e001
Show file tree
Hide file tree
Showing 23 changed files with 740 additions and 744 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changed

- AWS enhancement: Documentation updates.
- Add `Accept: application/json` header in request to fix incompatibility with 3rd party providers

## 1.0.2
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.1-dev"
}
}
}
16 changes: 8 additions & 8 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
final class ValidationException extends ClientException
{
/**
* The field where the invalid entry was detected.
* A message with the reason for the validation exception error.
*
* @var ValidationExceptionField[]
* @var ValidationExceptionReason::*
*/
private $fieldList;
private $reason;

/**
* A message with the reason for the validation exception error.
* The field where the invalid entry was detected.
*
* @var ValidationExceptionReason::*
* @var ValidationExceptionField[]
*/
private $reason;
private $fieldList;

/**
* @return ValidationExceptionField[]
Expand All @@ -46,15 +46,15 @@ protected function populateResult(ResponseInterface $response): void
{
$data = $response->toArray(false);

$this->fieldList = $this->populateResultValidationExceptionFieldList($data['fieldList'] ?? []);
$this->reason = (string) $data['reason'];
$this->fieldList = $this->populateResultValidationExceptionFieldList($data['fieldList'] ?? []);
}

private function populateResultValidationExceptionField(array $json): ValidationExceptionField
{
return new ValidationExceptionField([
'Message' => (string) $json['message'],
'Name' => (string) $json['name'],
'Message' => (string) $json['message'],
]);
}

Expand Down
169 changes: 84 additions & 85 deletions src/Input/CalculateRouteMatrixRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ final class CalculateRouteMatrixRequest extends Input
*/
private $calculatorName;

/**
* Specifies route preferences when traveling by `Car`, such as avoiding routes that use ferries or tolls.
*
* Requirements: `TravelMode` must be specified as `Car`.
*
* @var CalculateRouteCarModeOptions|null
*/
private $carModeOptions;

/**
* Sets the time of departure as the current time. Uses the current time to calculate the route matrix. You can't set
* both `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic
* conditions is used to calculate the route matrix.
*
* Default Value: `false`
*
* Valid Values: `false` | `true`
*
* @var bool|null
*/
private $departNow;

/**
* The list of departure (origin) positions for the route matrix. An array of points, each of which is itself a 2-value
* array defined in WGS 84 [^1] format: `[longitude, latitude]`. For example, `[-123.115, 49.285]`.
Expand All @@ -67,21 +45,6 @@ final class CalculateRouteMatrixRequest extends Input
*/
private $departurePositions;

/**
* Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set both
* `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic conditions
* is used to calculate the route matrix.
*
* > 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
*
* @var \DateTimeImmutable|null
*/
private $departureTime;

/**
* The list of destination positions for the route matrix. An array of points, each of which is itself a 2-value array
* defined in WGS 84 [^1] format: `[longitude, latitude]`. For example, `[-122.339, 47.615]`.
Expand All @@ -105,24 +68,6 @@ final class CalculateRouteMatrixRequest extends Input
*/
private $destinationPositions;

/**
* Set the unit system to specify the distance.
*
* Default Value: `Kilometers`
*
* @var DistanceUnit::*|null
*/
private $distanceUnit;

/**
* The optional API key [^1] to authorize the request.
*
* [^1]: https://docs.aws.amazon.com/location/latest/developerguide/using-apikeys.html
*
* @var string|null
*/
private $key;

/**
* Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road
* compatibility.
Expand All @@ -147,6 +92,52 @@ final class CalculateRouteMatrixRequest extends Input
*/
private $travelMode;

/**
* Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set both
* `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic conditions
* is used to calculate the route matrix.
*
* > 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
*
* @var \DateTimeImmutable|null
*/
private $departureTime;

/**
* Sets the time of departure as the current time. Uses the current time to calculate the route matrix. You can't set
* both `DepartureTime` and `DepartNow`. If neither is set, the best time of day to travel with the best traffic
* conditions is used to calculate the route matrix.
*
* Default Value: `false`
*
* Valid Values: `false` | `true`
*
* @var bool|null
*/
private $departNow;

/**
* Set the unit system to specify the distance.
*
* Default Value: `Kilometers`
*
* @var DistanceUnit::*|null
*/
private $distanceUnit;

/**
* Specifies route preferences when traveling by `Car`, such as avoiding routes that use ferries or tolls.
*
* Requirements: `TravelMode` must be specified as `Car`.
*
* @var CalculateRouteCarModeOptions|null
*/
private $carModeOptions;

/**
* Specifies route preferences when traveling by `Truck`, such as avoiding routes that use ferries or tolls, and truck
* specifications to consider when choosing an optimal road.
Expand All @@ -157,48 +148,57 @@ final class CalculateRouteMatrixRequest extends Input
*/
private $truckModeOptions;

/**
* The optional API key [^1] to authorize the request.
*
* [^1]: https://docs.aws.amazon.com/location/latest/developerguide/using-apikeys.html
*
* @var string|null
*/
private $key;

/**
* @param array{
* CalculatorName?: string,
* CarModeOptions?: null|CalculateRouteCarModeOptions|array,
* DepartNow?: null|bool,
* DeparturePositions?: array[],
* DepartureTime?: null|\DateTimeImmutable|string,
* DestinationPositions?: array[],
* DistanceUnit?: null|DistanceUnit::*,
* Key?: null|string,
* TravelMode?: null|TravelMode::*,
* DepartureTime?: null|\DateTimeImmutable|string,
* DepartNow?: null|bool,
* DistanceUnit?: null|DistanceUnit::*,
* CarModeOptions?: null|CalculateRouteCarModeOptions|array,
* TruckModeOptions?: null|CalculateRouteTruckModeOptions|array,
* Key?: null|string,
* '@region'?: string|null,
* } $input
*/
public function __construct(array $input = [])
{
$this->calculatorName = $input['CalculatorName'] ?? null;
$this->carModeOptions = isset($input['CarModeOptions']) ? CalculateRouteCarModeOptions::create($input['CarModeOptions']) : null;
$this->departNow = $input['DepartNow'] ?? null;
$this->departurePositions = $input['DeparturePositions'] ?? null;
$this->departureTime = !isset($input['DepartureTime']) ? null : ($input['DepartureTime'] instanceof \DateTimeImmutable ? $input['DepartureTime'] : new \DateTimeImmutable($input['DepartureTime']));
$this->destinationPositions = $input['DestinationPositions'] ?? null;
$this->distanceUnit = $input['DistanceUnit'] ?? null;
$this->key = $input['Key'] ?? null;
$this->travelMode = $input['TravelMode'] ?? null;
$this->departureTime = !isset($input['DepartureTime']) ? null : ($input['DepartureTime'] instanceof \DateTimeImmutable ? $input['DepartureTime'] : new \DateTimeImmutable($input['DepartureTime']));
$this->departNow = $input['DepartNow'] ?? null;
$this->distanceUnit = $input['DistanceUnit'] ?? null;
$this->carModeOptions = isset($input['CarModeOptions']) ? CalculateRouteCarModeOptions::create($input['CarModeOptions']) : null;
$this->truckModeOptions = isset($input['TruckModeOptions']) ? CalculateRouteTruckModeOptions::create($input['TruckModeOptions']) : null;
$this->key = $input['Key'] ?? null;
parent::__construct($input);
}

/**
* @param array{
* CalculatorName?: string,
* CarModeOptions?: null|CalculateRouteCarModeOptions|array,
* DepartNow?: null|bool,
* DeparturePositions?: array[],
* DepartureTime?: null|\DateTimeImmutable|string,
* DestinationPositions?: array[],
* DistanceUnit?: null|DistanceUnit::*,
* Key?: null|string,
* TravelMode?: null|TravelMode::*,
* DepartureTime?: null|\DateTimeImmutable|string,
* DepartNow?: null|bool,
* DistanceUnit?: null|DistanceUnit::*,
* CarModeOptions?: null|CalculateRouteCarModeOptions|array,
* TruckModeOptions?: null|CalculateRouteTruckModeOptions|array,
* Key?: null|string,
* '@region'?: string|null,
* }|CalculateRouteMatrixRequest $input
*/
Expand Down Expand Up @@ -388,12 +388,6 @@ private function requestBody(): array
{
$payload = [];

if (null !== $v = $this->carModeOptions) {
$payload['CarModeOptions'] = $v->requestBody();
}
if (null !== $v = $this->departNow) {
$payload['DepartNow'] = (bool) $v;
}
if (null === $v = $this->departurePositions) {
throw new InvalidArgument(sprintf('Missing parameter "DeparturePositions" for "%s". The value cannot be null.', __CLASS__));
}
Expand All @@ -411,9 +405,6 @@ private function requestBody(): array
}
}

if (null !== $v = $this->departureTime) {
$payload['DepartureTime'] = $v->format(\DateTimeInterface::ATOM);
}
if (null === $v = $this->destinationPositions) {
throw new InvalidArgument(sprintf('Missing parameter "DestinationPositions" for "%s". The value cannot be null.', __CLASS__));
}
Expand All @@ -431,18 +422,26 @@ private function requestBody(): array
}
}

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));
}
$payload['TravelMode'] = $v;
}
if (null !== $v = $this->departureTime) {
$payload['DepartureTime'] = $v->format(\DateTimeInterface::ATOM);
}
if (null !== $v = $this->departNow) {
$payload['DepartNow'] = (bool) $v;
}
if (null !== $v = $this->distanceUnit) {
if (!DistanceUnit::exists($v)) {
throw new InvalidArgument(sprintf('Invalid parameter "DistanceUnit" for "%s". The value "%s" is not a valid "DistanceUnit".', __CLASS__, $v));
}
$payload['DistanceUnit'] = $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));
}
$payload['TravelMode'] = $v;
if (null !== $v = $this->carModeOptions) {
$payload['CarModeOptions'] = $v->requestBody();
}
if (null !== $v = $this->truckModeOptions) {
$payload['TruckModeOptions'] = $v->requestBody();
Expand Down
Loading

0 comments on commit d77e001

Please sign in to comment.