toJson method

Map<String, dynamic> toJson()

Converts the ActionModel to JSON for API requests.

Implementation

Map<String, dynamic> toJson() {
  final json = <String, dynamic>{
    'title': title,
    'name': name,
    'handler': handler,
    'method': method,
    'priority': priority,
    'enabled': enabled,
    'settings': settings,
  };

  if (id != null) {
    json['_id'] = id!;
  }

  if (condition != null) {
    json['condition'] = condition!;
  }

  return json;
}