list method

Implementation

Future<ListResponseModel> list(ListRequestModel request) async {
  final uri = Uri.parse(_kListEndpoint);
  late final Response response;

  if (request.target != null) {
    final body = jsonEncode(request.toJson());
    log('GTranslateV2:list: body=`$body`');

    response = await client.post(
      uri,
      body: body,
      headers: _headers,
    );
  } else {
    response = await client.get(
      uri,
      headers: _headers,
    );
  }

  _checkHttpCode(response);
  final responseJson = _checkBodyFormat(response);

  log('GTranslateV2:list: responseJson=`$responseJson`');
  return ListResponseModel.fromJson(responseJson);
}