get<T extends CoffeeModel> method

CoffeeRequestGet<T> get<T extends CoffeeModel>(
  1. String endpoint, [
  2. List<CoffeeQueryFilter>? args
])

Retrieves a CoffeeRequestGet instance configured for querying a specified API endpoint.

This method constructs a URL by concatenating baseUrl and the specified endpoint, and returns a CoffeeRequestGet instance configured with that URL and any provided query args.

Parameters:

  • endpoint: The API endpoint to send the request to.
  • args: Optional. A list of CoffeeQueryFilter instances to apply as query parameters.

Returns:

A CoffeeRequestGet instance configured to query the specified endpoint with the provided args.

Example:

get<User>('/user/info', [where((model) => model.name, '==', 'john'), whereDate('createdAt', 'day', 28)])
  .returnListOf(User)
  .then((list) => print('Retrieved list: $list'));

// or

get<User>('/user/info')
  .where((model) => model.name, '==', 'john') // filter with type
  .whereDate('createdAt', 'day', 28) // filter with no type
  .returnListOf(User)
  .then((list) => print('Retrieved list: $list'));

Note: Ensure to replace User, where, and whereDate with actual implementations suitable for your use case.

Implementation

CoffeeRequestGet<T> get<T extends CoffeeModel>(String endpoint, [List<cqf.CoffeeQueryFilter>? args]) {
  final url = CoffeeUtil.concatUrl(baseUrl, endpoint);
  return CoffeeRequestGet<T>(httpClient, url, args);
}