request static method
Implementation
static Future<void> request({
required String method,
required String url,
Map<String, dynamic>? body,
Map<String, dynamic>? headers,
}) async {
try {
SyncLogger.log(
'Trying API Request',
);
await RetryManager.retryRequest(
request: () async {
await ApiService.request(
method: method,
url: url,
body: body,
headers: headers,
);
},
maxAttempts:
config.retryCount,
delay: config.retryDelay,
);
SyncLogger.log(
'API Success',
);
} catch (e) {
SyncLogger.log(
'API Failed -> Saving Queue',
);
final request =
QueuedRequest(
id: _uuid.v4(),
url: url,
method: method,
body: body,
headers: headers,
createdAt: DateTime.now(),
);
await RequestQueue.add(
request,
);
}
}