addComment method

Future<CommentThread> addComment({
  1. required String videoId,
  2. required String text,
  3. String? channelId,
  4. GoogleApisClientApiKey? googleApisClientApiKey,
})

Implementation

Future<CommentThread> addComment({
  required String videoId,
  required String text,
  String? channelId,
  GoogleApisClientApiKey? googleApisClientApiKey,
}) async {
  YouTubeApi youTubeApi =
      await youTubeApiClient(googleApisClientApiKey: googleApisClientApiKey);
  String channel_id = await () async {
    if (channelId is String) {
      if (channelId.isNotEmpty) {
        return channelId;
      }
    }
    // youTubeApi.channels.list([]);
    return "";
  }.call();
  return (await youTubeApi.commentThreads.insert(
    CommentThread(
      snippet: CommentThreadSnippet(
        videoId: videoId,
        channelId: channel_id,
        topLevelComment: Comment(
          snippet: CommentSnippet(
            textOriginal: text,
          ),
        ),
      ),
    ),
    ["snippet"],
  ));
}