call method

Future call({
  1. CancelToken? cancelToken,
})

Implementation

Future<dynamic> call({CancelToken? cancelToken}) async {
  var method = apiMethod.name.toUpperCase();

  bool isData = apiMethod == ApiMethods.post || apiMethod == ApiMethods.put;
  try{
    final response = await dio.request(endPoint,
        data: isData ? data : null,
        queryParameters: !isData ? data : null,
        options: Options(
          method: method,
        ),
        cancelToken: cancelToken);
    return response.data;
  }catch(e, stackTrace){
    throw JBApiException(e, stackTrace);
  }
}