Skip to content

Commit

Permalink
refactor(consumed_thing): refactor op type defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Feb 19, 2022
1 parent fb50e98 commit b0203a0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/src/core/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,21 @@ class ConsumedThing implements scripting_api.ConsumedThing {
Form form, _AffordanceType affordanceType, OperationType operationType) {
List<String>? operationTypes = form.op;

// TODO(JKRhb): Replace with constants or stringified OperationType enum
// values.
switch (affordanceType) {
case _AffordanceType.property:
operationTypes ??= ["readproperty", "writeproperty"];
operationTypes ??= [
OperationType.readproperty.toShortString(),
OperationType.writeproperty.toShortString()
];
break;
case _AffordanceType.action:
operationTypes ??= ["invokeaction"];
operationTypes ??= [OperationType.invokeaction.toShortString()];
break;
case _AffordanceType.event:
operationTypes ??= ["subscribeevent", "unsubscribeevent"];
operationTypes ??= [
OperationType.subscribeevent.toShortString(),
OperationType.unsubscribeevent.toShortString()
];
break;
}

Expand Down

0 comments on commit b0203a0

Please sign in to comment.