MessageTemplate.fromJson constructor

MessageTemplate.fromJson(
  1. Map<String, Object?> json
)

Implementation

factory MessageTemplate.fromJson(Map<String, Object?> json) =>
    MessageTemplate(
      id: json["id"] as String,
      name: json["name"] as String,
      about: json["about"] == null ? null : json["about"] as String,
      channel: Channel.fromJson(json["channel"]),
      purpose: json["purpose"] as String,
      locale: json["locale"] as String,
      status: Status.fromJson(json["status"]),
      version: (json["version"] as num).toInt(),
      publishedVersion: json["published_version"] == null
          ? null
          : (json["published_version"] as num).toInt(),
      draftVersion: (json["draft_version"] as num).toInt(),
      hasUnpublishedChanges: json["has_unpublished_changes"] as bool,
      variables: json["variables"] == null
          ? null
          : (json["variables"] as List)
              .map(
                (item) => Variable.fromJson(
                  (item as Map).cast<String, Object?>(),
                ),
              )
              .toList(),
      sms: json["sms"] == null
          ? null
          : SMSContent.fromJson(
              (json["sms"] as Map).cast<String, Object?>(),
            ),
      email: json["email"] == null
          ? null
          : EmailContent.fromJson(
              (json["email"] as Map).cast<String, Object?>(),
            ),
      attachments: json["attachments"] == null
          ? null
          : (json["attachments"] as List)
              .map((item) => item as String)
              .toList(),
      createdAt: decodeDateTime(json["created_at"]),
      updatedAt: decodeDateTime(json["updated_at"]),
      publishedAt: json["published_at"] == null
          ? null
          : decodeDateTime(json["published_at"]),
      archivedAt: json["archived_at"] == null
          ? null
          : decodeDateTime(json["archived_at"]),
    );