Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/src/api/models/action/action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ enum ActionType {
setVariant,

/// Call a custom function.
callFunction;
callFunction,

/// Call an API.
callApi;

/// Displayable string representation of the [ActionType].
String get prettify {
Expand All @@ -43,6 +46,8 @@ enum ActionType {
return 'Set Variant';
case ActionType.callFunction:
return 'Call Function';
case ActionType.callApi:
return 'Call API';
}
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/api/models/action/action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions lib/src/api/models/action/api_call_action.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

import '../../mixins.dart';
import 'action.dart';

part 'api_call_action.g.dart';

/// Holds information about an API call action to perform on a user interaction.
@JsonSerializable()
class ApiCallAction extends ActionModel with EquatableMixin, SerializableMixin {
/// ID of the API to call.
final String? apiId;

/// Parameters to pass to the API.
final Map<String, String> parameters;

/// Creates an [ApiCallAction] with the given data.
ApiCallAction({
this.apiId,
Map<String, String>? parameters,
}) : parameters = parameters ?? {},
super(type: ActionType.callApi);

@override
List<Object?> get props => [apiId, parameters];

/// Creates a copy of this [ApiCallAction] but with the given fields replaced
/// with the new values.
ApiCallAction copyWith({
String? apiId,
Map<String, String>? parameters,
}) =>
ApiCallAction(
apiId: apiId ?? this.apiId,
parameters: parameters ?? this.parameters,
);

/// Creates a new [ApiCallAction] from a JSON object.
factory ApiCallAction.fromJson(Map json) => _$ApiCallActionFromJson(json);

@override
Map toJson() => _$ApiCallActionToJson(this);
}
40 changes: 40 additions & 0 deletions lib/src/api/models/action/api_call_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/api/models/action/call_function_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/api/models/action/link_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/api/models/action/navigation_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/api/models/action/set_value_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/api/models/action/set_variant_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/src/api/models/action/submit_action.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions lib/src/api/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// license that can be found in the LICENSE.md file.

export 'action/action.dart';
export 'action/navigation_action.dart';
export 'action/api_call_action.dart';
export 'action/call_function_action.dart';
export 'action/link_action.dart';
export 'action/submit_action.dart';
export 'action/navigation_action.dart';
export 'action/set_value_action.dart';
export 'action/set_variant_action.dart';
export 'action/call_function_action.dart';
export 'action/submit_action.dart';
export 'alignment.dart';
export 'axis.dart';
export 'axis_alignments.dart';
Expand All @@ -24,9 +25,11 @@ export 'color_stop.dart';
export 'corner_radius.dart';
export 'edge_insets.dart';
export 'effect.dart';
export 'fab_props.dart';
export 'fit.dart';
export 'font_family.dart';
export 'font_name.dart';
export 'google_maps.dart';
export 'icon.dart';
export 'icon_model.dart';
export 'input_border.dart';
Expand All @@ -49,9 +52,7 @@ export 'text_direction.dart';
export 'text_input_type.dart';
export 'text_overflow.dart';
export 'trigger.dart';
export 'twitter.dart';
export 'vec.dart';
export 'visual_density.dart';
export 'webview_models.dart';
export 'twitter.dart';
export 'google_maps.dart';
export 'fab_props.dart';
2 changes: 2 additions & 0 deletions lib/src/api/models/reaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ ActionModel actionFromJson(Map json) {
return SetVariantAction.fromJson(json);
case ActionType.callFunction:
return CallFunctionAction.fromJson(json);
case ActionType.callApi:
return ApiCallAction.fromJson(json);
}
}
2 changes: 1 addition & 1 deletion lib/src/api/nodes/accordion_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/app_bar_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/auto_placeholder_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/button_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/canvas_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/checkbox_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/divider_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/dropdown_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/embedded_video_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/expansion_tile_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/floating_action_button_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/frame_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/freeform_placeholder_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/icon_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/list_tile_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/list_view_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/loading_indicator_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/api/nodes/navigation_bar_node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading