fetchStickerPack method

Future<Result<PubSubError, StickerPack>> fetchStickerPack(
  1. JID jid,
  2. String id
)

Fetches the sticker pack with id id from jid.

On success, returns the StickerPack. On failure, returns a PubSubError.

Implementation

Future<Result<PubSubError, StickerPack>> fetchStickerPack(
  JID jid,
  String id,
) async {
  final pm = getAttributes().getManagerById<PubSubManager>(pubsubManager)!;
  final stickerPackDataRaw = await pm.getItem(
    jid.toBare(),
    stickersXmlns,
    id,
  );
  if (stickerPackDataRaw.isType<PubSubError>()) {
    return Result(stickerPackDataRaw.get<PubSubError>());
  }

  final stickerPackData = stickerPackDataRaw.get<PubSubItem>();
  final stickerPack = StickerPack.fromXML(
    stickerPackData.id,
    stickerPackData.payload,
  );

  return Result(stickerPack);
}