retrieveVideoAvatar method

Future<CreateVideoAvatarData?> retrieveVideoAvatar(
  1. String secretKey,
  2. String videoId,
  3. Null onRender(
    1. CreateVideoAvatarData value
    )
)

this is api implementation for retrieve Video avatar by its id retrieve video header retrieveVideoAvatar is return only one video To fetch video user will have to pass videId of video onRender is a callback function that call after video render. secretKey is mandatory key if something will happen wrong then retrieveVideoAvatar will return null

Implementation

Future<CreateVideoAvatarData?> retrieveVideoAvatar(
    String secretKey,
    String videoId,
    Null Function(CreateVideoAvatarData value) onRender) async {
  try {
    final url = Uri.parse('https://apis.elai.io/api/v1/videos/$videoId');

    final headers = {
      'Authorization': 'Bearer $secretKey',
      'accept': 'application/json',
    };

    Future.delayed(const Duration(seconds: 20), () async {
      final response = await http.get(url, headers: headers);
      if (response.statusCode == 200) {
        var res = CreateVideoAvatarData.fromJson(jsonDecode(response.body));
        if (res.status == "rendering") {
          retrieveVideoAvatar(secretKey, videoId, onRender);
        } else {
          onRender.call(res);
          return res;
        }
      } else {
        return null;
      }
    });
  } catch (e) {
    return null;
  }
  return null;
}