-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CB-30 Add ApiActionNodeModel with mapper
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
ChatbotBuilderApi.Presentation/Graphs/Nodes/ApiAction/ApiActionNodeMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using ChatbotBuilderApi.Application.Graphs.Nodes.ApiAction; | ||
using ChatbotBuilderApi.Presentation.Graphs.Metas; | ||
using ChatbotBuilderApi.Presentation.Graphs.Ports; | ||
using Riok.Mapperly.Abstractions; | ||
|
||
namespace ChatbotBuilderApi.Presentation.Graphs.Nodes.ApiAction; | ||
|
||
[Mapper] | ||
public static partial class ApiActionNodeMapper | ||
{ | ||
public static ApiActionNodeModel ToModel(this ApiActionNodeDto dto) | ||
{ | ||
return new ApiActionNodeModel( | ||
dto.Info.ToModel(), | ||
dto.Visual.ToModel(), | ||
dto.UrlInputPort.ToModel(), | ||
dto.HttpMethod, | ||
dto.Headers, | ||
dto.BodyInputPort?.ToModel(), | ||
dto.ResponseOutputPort.ToModel()); | ||
} | ||
|
||
public static ApiActionNodeDto ToDto(this ApiActionNodeModel model) | ||
{ | ||
return new ApiActionNodeDto( | ||
model.Info.ToDomain(), | ||
model.Visual.ToDomain(), | ||
model.UrlInputPort.ToDto(), | ||
model.HttpMethod, | ||
model.Headers, | ||
model.BodyInputPort?.ToDto(), | ||
model.ResponseOutputPort.ToDto()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
ChatbotBuilderApi.Presentation/Graphs/Nodes/ApiAction/ApiActionNodeModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using ChatbotBuilderApi.Application.Graphs.Nodes; | ||
using ChatbotBuilderApi.Domain.Graphs.Abstract.Services; | ||
using ChatbotBuilderApi.Presentation.Graphs.Metas; | ||
using ChatbotBuilderApi.Presentation.Graphs.Ports; | ||
|
||
namespace ChatbotBuilderApi.Presentation.Graphs.Nodes.ApiAction; | ||
|
||
/// <summary> | ||
/// API Action node model: | ||
/// <list type="bullet"> | ||
/// <item>Executes an API call when activated.</item> | ||
/// <item>The endpoint can be dynamic, constructed from an input port.</item> | ||
/// <item>Requires details about the HTTP method, headers, and body.</item> | ||
/// <item>Has an output port to pass along the API response.</item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="Info">Generic information for the node.</param> | ||
/// <param name="Visual">Visual information for the node.</param> | ||
/// <param name="UrlInputPort">Text input port for the API endpoint URL.</param> | ||
/// <param name="HttpMethod">The HTTP method to use (GET, POST, PUT, DELETE, etc.).</param> | ||
/// <param name="Headers">Optional dictionary of headers to include in the API call.</param> | ||
/// <param name="BodyInputPort">Optional input port for the request body.</param> | ||
/// <param name="ResponseOutputPort">Output port for the API response. Must be of text data type.</param> | ||
public sealed record ApiActionNodeModel( | ||
InfoMetaModel Info, | ||
VisualMetaModel Visual, | ||
InputPortModel UrlInputPort, | ||
ApiActionHttpMethod HttpMethod, | ||
IReadOnlyDictionary<string, string>? Headers, | ||
InputPortModel? BodyInputPort, | ||
OutputPortModel ResponseOutputPort) | ||
: NodeModel(Info, Visual, NodeType.ApiAction); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters