fromJson static method

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

Implementation

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

  return SponsoredMessage(
    messageId: (json['message_id'] as int?) ?? 0,
    isRecommended: (json['is_recommended'] as bool?) ?? false,
    canBeReported: (json['can_be_reported'] as bool?) ?? false,
    content: MessageContent.fromJson(tdMapFromJson(json['content'])),
    sponsor: AdvertisementSponsor.fromJson(tdMapFromJson(json['sponsor'])),
    title: (json['title'] as String?) ?? '',
    buttonText: (json['button_text'] as String?) ?? '',
    accentColorId: (json['accent_color_id'] as int?) ?? 0,
    backgroundCustomEmojiId:
        int.tryParse(
          (json['background_custom_emoji_id'] as dynamic)?.toString() ?? '',
        ) ??
        0,
    additionalInfo: (json['additional_info'] as String?) ?? '',
  );
}