report static method
- required int prepareId,
- required int categId,
- String description = '',
- Uint8List? snapshot,
- ImageFileFormat? format,
- ParameterList? params,
- void onComplete(
- GemError error
Report a social event.
Parameters
- IN prepareId Prepared report operation id ( returned by a call to prepareReporting )
- IN categId Report category id
- IN description Report description text
- IN snapshot Report snapshot image
- IN format Report snapshot image format
- IN params Report parameters. They must follow the structure returned by
SocialReportsOverlayCategory.parameters.find(PredefinedOverlayGenericParametersIds.keyVals)
- IN onComplete callback to be called when the request is completed with the error code:
- GemError.invalidInput - categId is not a valid social report category id / params are ill-formed / snapshot is an invalid image
- GemError.suspended - report rate limit exceeded
- GemError.expired - prepared report id not found or is expired ( too old )
- GemError.notFound - no accurate sense data source position to complete
- GemError.success - report submitted successfully
Returns
- The operation progress listener if the operation could be started, null otherwise
Throws
- An exception if it fails.
Implementation
static EventHandler? report({
required final int prepareId,
required final int categId,
final String description = '',
final Uint8List? snapshot,
final ImageFileFormat? format,
final ParameterList? params,
final void Function(GemError error)? onComplete,
}) {
if ((snapshot == null) != (format == null)) {
onComplete?.call(GemError.invalidInput);
return null;
}
dynamic gemImage;
if (snapshot != null) {
gemImage = GemKitPlatform.instance.createGemImage(
snapshot,
format!.id,
);
}
try {
final EventDrivenProgressListener progListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(
progListener.id,
progListener,
);
progListener.registerOnCompleteWithDataCallback((final int err, _, __) {
GemKitPlatform.instance.unregisterEventHandler(progListener.id);
onComplete?.call(GemErrorExtension.fromCode(err));
});
final OperationResult result = staticMethod(
'SocialOverlay',
'report',
args: <String, dynamic>{
'prepareId': prepareId,
'categId': categId,
'description': description,
'snapshot': gemImage ?? 0,
'params': params != null ? params.pointerId : 0,
'listener': progListener.id,
},
);
final int id = result['result'];
final GemError error = GemErrorExtension.fromCode(id);
if (error != GemError.scheduled) {
GemKitPlatform.instance.unregisterEventHandler(progListener.id);
onComplete?.call(error);
return null;
}
return progListener;
} finally {
if (gemImage != null) {
GemKitPlatform.instance.deleteCPointer(gemImage);
}
}
}