Skip to content

Commit

Permalink
change params
Browse files Browse the repository at this point in the history
  • Loading branch information
ce-nistal committed Oct 3, 2024
1 parent d00bb35 commit dc18327
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Apps.Crowdin/Actions/TranslationActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Crowdin.Api.StringTranslations;
using Crowdin.Api.Translations;
using RestSharp;
using Apps.Crowdin.Models.Request;

namespace Apps.Crowdin.Actions;

Expand All @@ -35,7 +36,8 @@ public TranslationActions(InvocationContext invocationContext, IFileManagementCl
[Action("Apply pre-translation", Description = "Apply pre-translation to chosen files")]
public async Task<PreTranslationEntity> PreTranslate(
[ActionParameter] ProjectRequest project,
[ActionParameter] PreTranslateRequest input)
[ActionParameter] PreTranslateRequest input,
[ActionParameter] UserRequest user)
{
var intProjectId = IntParser.Parse(project.ProjectId, nameof(project.ProjectId));
var intEngineId = IntParser.Parse(input.EngineId, nameof(input.EngineId));
Expand Down
8 changes: 4 additions & 4 deletions Apps.Crowdin/DataSourceHandlers/AiPromptIdDataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace Apps.Crowdin.DataSourceHandlers;

public class AiPromptIdDataHandler(
InvocationContext invocationContext,
[ActionParameter] ProjectRequest project,
[ActionParameter][Display("User ID")] string? UserId)
[ActionParameter] ProjectRequest project,
[ActionParameter] UserRequest user)

: BaseInvocable(invocationContext), IAsyncDataSourceHandler
{
Expand All @@ -27,7 +27,7 @@ public class AiPromptIdDataHandler(
public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(project.ProjectId) || string.IsNullOrEmpty(UserId))
if (string.IsNullOrEmpty(project.ProjectId) || string.IsNullOrEmpty(user.UserId))
throw new("You should input Project ID and User ID first");

var client = new CrowdinRestClient();
Expand All @@ -37,7 +37,7 @@ public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext con
{
var request =
new CrowdinRestRequest(
$"/users/{UserId}/ai/prompts?limit={lim}&offset={offset}",
$"/users/{user.UserId}/ai/prompts?limit={lim}&offset={offset}",
Method.Get, Creds);
request.AddQueryParameter("projectId", project.ProjectId);
request.AddQueryParameter("action", "pre_translate");
Expand Down
15 changes: 15 additions & 0 deletions Apps.Crowdin/Models/Request/UserRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Blackbird.Applications.Sdk.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apps.Crowdin.Models.Request
{
public class UserRequest
{
[Display("User ID")]
public string? UserId { get; set; }
}
}

0 comments on commit dc18327

Please sign in to comment.