Event.fromJson constructor

Event.fromJson(
  1. Map<String, dynamic> json,
  2. PrefixMapping prefixMapping
)

Creates a new Event from a json object.

Implementation

factory Event.fromJson(
  Map<String, dynamic> json,
  PrefixMapping prefixMapping,
) {
  final Set<String> parsedFields = {};

  final title = json.parseField<String>("title", parsedFields);
  final titles = json.parseMapField<String>("titles", parsedFields);
  final description = json.parseField<String>("description", parsedFields);
  final descriptions =
      json.parseMapField<String>("descriptions", parsedFields);
  final uriVariables = json.parseDataSchemaMapField(
    "uriVariables",
    prefixMapping,
    parsedFields,
  );

  final subscription =
      json.parseDataSchemaField("subscription", prefixMapping, parsedFields);
  final data = json.parseDataSchemaField("data", prefixMapping, parsedFields);
  final cancellation =
      json.parseDataSchemaField("cancellation", prefixMapping, parsedFields);

  final forms = json.parseAffordanceForms(prefixMapping, parsedFields);
  final additionalFields =
      json.parseAdditionalFields(prefixMapping, parsedFields);

  final event = Event(
    forms: forms,
    title: title,
    titles: titles,
    description: description,
    descriptions: descriptions,
    uriVariables: uriVariables,
    subscription: subscription,
    data: data,
    cancellation: cancellation,
    additionalFields: additionalFields,
  );

  return event;
}