Skip to content

Commit

Permalink
feat(definitions): add DataSchema fields to Event class
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 18, 2022
1 parent 4448830 commit b6c79a7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/src/definitions/interaction_affordances/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,34 @@
//
// SPDX-License-Identifier: MIT OR Apache-2.0

import '../data_schema.dart';
import '../form.dart';
import 'interaction_affordance.dart';

/// Class representing an [Event] Affordance in a Thing Description.
class Event extends InteractionAffordance {
/// Defines data that needs to be passed upon [subscription].
DataSchema? subscription;

/// Defines the [DataSchema] of the Event instance messages pushed by the
/// Thing.
DataSchema? data;

/// Defines any data that needs to be passed to cancel a subscription.
DataSchema? cancellation;

/// Creates a new [Event] from a [List] of [forms].
Event(List<Form> forms) : super(forms);

/// Creates a new [Event] from a [json] object.
Event.fromJson(Map<String, dynamic> json) : super([]) {
parseAffordanceFields(json);
_parseEventFields(json);
}

void _parseEventFields(Map<String, dynamic> json) {
subscription = DataSchema.fromJson(json);
data = DataSchema.fromJson(json);
cancellation = DataSchema.fromJson(json);
}
}

0 comments on commit b6c79a7

Please sign in to comment.