getDevicePositionHistory method

Future<GetDevicePositionHistoryResponse> getDevicePositionHistory({
  1. required String deviceId,
  2. required String trackerName,
  3. DateTime? endTimeExclusive,
  4. int? maxResults,
  5. String? nextToken,
  6. DateTime? startTimeInclusive,
})

Retrieves the device position history from a tracker resource within a specified range of time.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter deviceId : The device whose position history you want to retrieve.

Parameter trackerName : The tracker resource receiving the request for the device position history.

Parameter endTimeExclusive : Specify the end time for the position history in ISO 8601 format: YYYY-MM-DDThh:mm:ss.sssZ. By default, the value will be the time that the request is made.

Requirement:

  • The time specified for EndTimeExclusive must be after the time for StartTimeInclusive.

Parameter maxResults : An optional limit for the number of device positions returned in a single call.

Default value: 100

Parameter nextToken : The pagination token specifying which page of results to return in the response. If no token is provided, the default page is the first page.

Default value: null

Parameter startTimeInclusive : Specify the start time for the position history in ISO 8601 format: YYYY-MM-DDThh:mm:ss.sssZ. By default, the value will be 24 hours prior to the time that the request is made.

Requirement:

  • The time specified for StartTimeInclusive must be before EndTimeExclusive.

Implementation

Future<GetDevicePositionHistoryResponse> getDevicePositionHistory({
  required String deviceId,
  required String trackerName,
  DateTime? endTimeExclusive,
  int? maxResults,
  String? nextToken,
  DateTime? startTimeInclusive,
}) async {
  final $payload = <String, dynamic>{
    if (endTimeExclusive != null)
      'EndTimeExclusive': iso8601ToJson(endTimeExclusive),
    if (maxResults != null) 'MaxResults': maxResults,
    if (nextToken != null) 'NextToken': nextToken,
    if (startTimeInclusive != null)
      'StartTimeInclusive': iso8601ToJson(startTimeInclusive),
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/tracking/v0/trackers/${Uri.encodeComponent(trackerName)}/devices/${Uri.encodeComponent(deviceId)}/list-positions',
    hostPrefix: 'tracking.',
    exceptionFnMap: _exceptionFns,
  );
  return GetDevicePositionHistoryResponse.fromJson(response);
}