setStickerSetThumbnail method

Future<bool> setStickerSetThumbnail(
  1. String name,
  2. int userId, {
  3. dynamic thumbnail,
})

Use this method to set the thumbnail of a sticker set

Animated thumbnails can be set for animated sticker sets only.

Returns True on success.

https://core.telegram.org/bots/api#setstickersetthumbnail

Implementation

Future<bool> setStickerSetThumbnail(String name, int userId,
    {dynamic thumbnail}) async {
  var requestUrl = _apiUri('setStickerSetThumbnail');
  var body = <String, dynamic>{
    'name': name,
    'user_id': userId,
  };
  if (thumbnail == null) {
    return await HttpClient.httpPost(requestUrl, body: body);
  } else if (thumbnail is io.File) {
    // filename cannot be empty to post to Telegram server
    var files = List<MultipartFile>.filled(
        1,
        MultipartFile(
            'thumbnail', thumbnail.openRead(), thumbnail.lengthSync(),
            filename: '${thumbnail.lengthSync()}'));
    return await HttpClient.httpMultipartPost(requestUrl, files, body: body);
  } else if (thumbnail is String) {
    body.addAll({'thumbnail': thumbnail});
    return await HttpClient.httpPost(requestUrl, body: body);
  } else {
    return Future.error(TelegramException(
        'Attribute \'thumbnail\' can only be either io.File or String (Telegram fileId or image url)'));
  }
}