Alter networking to include authorization bot header, and add initial sticker calls
This commit is contained in:
parent
eae1f391de
commit
6079fa9a01
6 changed files with 95 additions and 6 deletions
|
@ -110,3 +110,67 @@ class StickerItem {
|
|||
formatType: int.parse(js['format_type']));
|
||||
}
|
||||
}
|
||||
|
||||
class StickerPack {
|
||||
Snowflake id;
|
||||
List<Sticker> stickers;
|
||||
String name;
|
||||
Snowflake sku_id;
|
||||
Snowflake? coverStickerId;
|
||||
String description;
|
||||
Snowflake? bannerAssetId;
|
||||
|
||||
StickerPack(
|
||||
{required this.id,
|
||||
required this.stickers,
|
||||
required this.name,
|
||||
required this.sku_id,
|
||||
this.coverStickerId,
|
||||
required this.description,
|
||||
this.bannerAssetId});
|
||||
|
||||
String encode() {
|
||||
return json.encode(toJson());
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
List<Map<String, dynamic>> stickersJs = [];
|
||||
for (Sticker sticker in stickers) {
|
||||
stickersJs.add(sticker.toJson());
|
||||
}
|
||||
|
||||
return {
|
||||
"id": id.toString(),
|
||||
"stickers": stickersJs,
|
||||
"name": name,
|
||||
"sku_id": sku_id.toString(),
|
||||
if (coverStickerId != null) "cover_sticker_id": coverStickerId.toString(),
|
||||
"description": description,
|
||||
if (bannerAssetId != null) "banner_asset_id": bannerAssetId.toString()
|
||||
};
|
||||
}
|
||||
|
||||
factory StickerPack.fromJson(String js) {
|
||||
return StickerPack.decode(json.decode(js));
|
||||
}
|
||||
|
||||
factory StickerPack.decode(Map<String, dynamic> js) {
|
||||
List<Sticker> jsStickers = [];
|
||||
for (var entry in js['stickers']) {
|
||||
jsStickers.add(Sticker.decode(entry));
|
||||
}
|
||||
|
||||
return StickerPack(
|
||||
id: Snowflake.parse(js['id'], Snowflake.DiscordEpoch),
|
||||
stickers: jsStickers,
|
||||
name: js['name'],
|
||||
sku_id: Snowflake.parse(js['sku_id'], Snowflake.DiscordEpoch),
|
||||
coverStickerId: js.containsKey("cover_sticker_id")
|
||||
? Snowflake.parse(js['cover_sticker_id'], Snowflake.DiscordEpoch)
|
||||
: null,
|
||||
description: js['description'],
|
||||
bannerAssetId: js.containsKey("banner_asset_id")
|
||||
? Snowflake.parse(js['banner_asset_id'], Snowflake.DiscordEpoch)
|
||||
: null);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue