list method

Future<GetTerminalLocationsResponse> list({
  1. String? endingBefore,
  2. List<String>? expand,
  3. int? limit,
  4. String? startingAfter,
})

Returns a list of Location objects.

Implementation

Future<GetTerminalLocationsResponse> list({
  String? endingBefore,
  List<String>? expand,
  int? limit,
  String? startingAfter,
}) async {
  final $queryParameters = <String, Object>{};
  if (endingBefore != null) {
    $queryParameters['ending_before'] = endingBefore;
  }
  if (expand != null) {
    $queryParameters['expand'] = expand;
  }
  if (limit != null) {
    $queryParameters['limit'] = limit.toString();
  }
  if (startingAfter != null) {
    $queryParameters['starting_after'] = startingAfter;
  }
  final $uri = Uri.parse('$_baseUri/v1/terminal/locations')
      .replace(queryParameters: $queryParameters);
  final $request = _$http.Request(
    'GET',
    $uri,
  );
  $request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
  $request.headers['Accept'] = 'application/json';
  final $response = await _httpClient.send($request);
  final $body = await $response.stream.toBytes();
  switch ($response.statusCode) {
    /// Successful response.
    case 200:
      final $json = _$convert.jsonDecode(_$convert.utf8.decode($body));
      return GetTerminalLocationsResponse.fromJson($json);

    /// Error response.
    case _:
      final $json = _$convert.jsonDecode(_$convert.utf8.decode($body));
      throw Error.fromJson($json);
  }
}