sendActivateBatch method
Implementation
Future<int> sendActivateBatch(List<Hit> listOfActivate) async {
// Create url
String urlString = Endpoints.DECISION_API + Endpoints.ACTIVATION;
// Create an activate batch object
ActivateBatch activateBatch = ActivateBatch(listOfActivate);
// Encode batch before send it
try {
Object? objectToSend = jsonEncode(activateBatch.toJson());
var response = await service.sendHttpRequest(RequestType.Post, urlString,
Endpoints.getFSHeader(this.apiKey), objectToSend,
timeoutMs: TIMEOUT_REQUEST);
switch (response.statusCode) {
case 200:
case 204:
Flagship.logger(Level.INFO, ACTIVATE_SUCCESS + ": $objectToSend");
onSendActivateBatchWithSuccess(listOfActivate);
return response.statusCode;
default:
Flagship.logger(Level.ERROR, HIT_FAILED);
DataUsageTracking.sharedInstance().processTroubleShootingHttp(
CriticalPoints.SEND_ACTIVATE_HIT_ROUTE_ERROR.name, response);
return response.statusCode;
}
} on Exception catch (e) {
DataUsageTracking.sharedInstance()
.processTroubleShootingException(null, e);
activateDelegate?.onFailedToSendBatch(listOfActivate);
Flagship.logger(
Level.EXCEPTIONS, EXCEPTION.replaceFirst("%s", "$e") + urlString);
Flagship.logger(Level.ERROR, HIT_FAILED);
return 500;
}
}