requestWithSinglePATH<T extends HttpDataParser<T>> method

  1. @override
Future<EasyHttpRequestResponse<T>> requestWithSinglePATH<T extends HttpDataParser<T>>(
  1. {required T model,
  2. required EasyHttpType requestType,
  3. String extraUri = '',
  4. Map<String, dynamic> queryParams = const {},
  5. bool returnModel = false}
)
override

Method to make request by EasyHttpType on SINGLE API PATH.

Parameters:

model (required): The model that will be handled in the query. You must implement HttpDataParser.

extraUri (optional): If apart from the base api that you initialized the package with, you need to add more information.

Example:

Your api base is https://www.domain.com/api and your endpoint to consult is https://www.domain.com/api/users in this parameter you add the part of users to complete the endpoint

queryParams (optional): You can send the query parameters directly in the path, but it is more recommended to use key: value for this.

Example:

https://www.domain.com/api/users/id=3 has id = 3 as a parameter. With this property you can do this: {"id": 3}

And it will be exactly the same

returnModel(optional): You can set it to true if your service returns a json of your model that has just been created and you need that information to save it locally or to update the UI

Implementation

@override
Future<EasyHttpRequestResponse<T>>
    requestWithSinglePATH<T extends HttpDataParser<T>>({
  required T model,
  required EasyHttpType requestType,
  String extraUri = '',
  Map<String, dynamic> queryParams = const {},
  bool returnModel = false,
}) async {
  final client = EasyHttpClient.singleClient;

  return await _makeRequest<T>(
    client: client,
    model: model,
    requestType: requestType,
    extraUri: extraUri,
    queryParams: queryParams,
  );
}