fromJson static method

Gift? fromJson(
  1. Map<String, dynamic>? json
)

Implementation

static Gift? fromJson(Map<String, dynamic>? json) {
  if (json == null) {
    return null;
  }

  return Gift(
    id: int.tryParse((json['id'] as dynamic)?.toString() ?? '') ?? 0,
    publisherChatId: (json['publisher_chat_id'] as int?) ?? 0,
    sticker: Sticker.fromJson(tdMapFromJson(json['sticker'])),
    starCount: (json['star_count'] as int?) ?? 0,
    defaultSellStarCount: (json['default_sell_star_count'] as int?) ?? 0,
    upgradeStarCount: (json['upgrade_star_count'] as int?) ?? 0,
    upgradeVariantCount: (json['upgrade_variant_count'] as int?) ?? 0,
    hasColors: (json['has_colors'] as bool?) ?? false,
    isForBirthday: (json['is_for_birthday'] as bool?) ?? false,
    isPremium: (json['is_premium'] as bool?) ?? false,
    auctionInfo: GiftAuction.fromJson(tdMapFromJson(json['auction_info'])),
    nextSendDate: (json['next_send_date'] as int?) ?? 0,
    userLimits: GiftPurchaseLimits.fromJson(
      tdMapFromJson(json['user_limits']),
    ),
    overallLimits: GiftPurchaseLimits.fromJson(
      tdMapFromJson(json['overall_limits']),
    ),
    background: GiftBackground.fromJson(tdMapFromJson(json['background'])),
    firstSendDate: (json['first_send_date'] as int?) ?? 0,
    lastSendDate: (json['last_send_date'] as int?) ?? 0,
  );
}