Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #10

Merged
merged 9 commits into from
Jun 18, 2024
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
4 changes: 2 additions & 2 deletions Apps.Crowdin/Actions/FileActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public async Task<FileEntity> AddFile(
ExcludedTargetLanguages = input.ExcludedTargetLanguages?.ToList(),
AttachLabelIds = input.AttachLabelIds?.ToList()
};

var file = await client.SourceFiles.AddFile(intProjectId!.Value, request);

return new(file);
}

[Action("Update file", Description = "Update an existing file with new content")]
public async Task<FileEntity> UpdateFile(
[ActionParameter] ProjectRequest project,
Expand Down
5 changes: 2 additions & 3 deletions Apps.Crowdin/Actions/ProjectActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public async Task<ListProjectsResponse> ListProjects([ActionParameter] ListProje
var client = new CrowdinClient(Creds);

var items = await Paginator.Paginate((lim, offset)
=> client.ProjectsGroups.ListProjects<ProjectBase>(userId, groupId, input.HasManagerAccess ?? false, lim, offset));

=> client.ProjectsGroups.ListProjects<ProjectBase>(userId, groupId, input.HasManagerAccess ?? false, null, lim, offset));
var projects = items.Select(x => new ProjectEntity(x)).ToArray();

return new(projects);
}

Expand Down
5 changes: 4 additions & 1 deletion Apps.Crowdin/Api/CrowdinClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ namespace Apps.Crowdin.Api;

public class CrowdinClient : CrowdinApiClient
{
public CrowdinClient(IEnumerable<AuthenticationCredentialsProvider> creds)
private readonly AuthenticationCredentialsProvider[] _creds;

public CrowdinClient(IEnumerable<AuthenticationCredentialsProvider> creds)
: base(GetCrowdinCreds(creds))
{
this._creds = creds.ToArray();
}

private static CrowdinCredentials GetCrowdinCreds(
Expand Down
6 changes: 3 additions & 3 deletions Apps.Crowdin/Apps.Crowdin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<Nullable>enable</Nullable>
<Product>Crowdin</Product>
<Description>Cloud-based solution that streamlines localization management</Description>
<Version>1.0.5</Version>
<Version>1.0.7</Version>
<AssemblyName>Apps.Crowdin</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Blackbird.Applications.Sdk.Common" Version="2.6.0" />
<PackageReference Include="Blackbird.Applications.Sdk.Common" Version="2.8.0" />
<PackageReference Include="Blackbird.Applications.SDK.Extensions.FileManagement" Version="1.0.1" />
<PackageReference Include="Blackbird.Applications.Sdk.Utils" Version="1.0.25" />
<PackageReference Include="Crowdin.Api" Version="2.22.1" />
<PackageReference Include="Crowdin.Api" Version="2.23.1" />
<PackageReference Include="MimeTypes" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
10 changes: 3 additions & 7 deletions Apps.Crowdin/DataSourceHandlers/ProjectDataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@

namespace Apps.Crowdin.DataSourceHandlers;

public class ProjectDataHandler : BaseInvocable, IAsyncDataSourceHandler
public class ProjectDataHandler(InvocationContext invocationContext)
: BaseInvocable(invocationContext), IAsyncDataSourceHandler
{
private AuthenticationCredentialsProvider[] Creds =>
InvocationContext.AuthenticationCredentialsProviders.ToArray();

public ProjectDataHandler(InvocationContext invocationContext) : base(invocationContext)
{
}

public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context,
CancellationToken cancellationToken)
{
var client = new CrowdinClient(Creds);

var items = await Paginator.Paginate((lim, offset)
=> client.ProjectsGroups.ListProjects<ProjectBase>(null, null, false, lim, offset));

=> client.ProjectsGroups.ListProjects<ProjectBase>(null, null, false, null, lim, offset));
return items
.Where(x => context.SearchString == null ||
x.Name.Contains(context.SearchString, StringComparison.OrdinalIgnoreCase))
Expand Down
4 changes: 3 additions & 1 deletion Apps.Crowdin/Models/Request/File/AddNewFileRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Blackbird.Applications.Sdk.Common;
using Apps.Crowdin.DataSourceHandlers.EnumHandlers;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dictionaries;
using Blackbird.Applications.Sdk.Common.Files;

namespace Apps.Crowdin.Models.Request.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Crowdin.Api.Webhooks;
using Newtonsoft.Json;
using RestSharp;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Base;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Project;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Project;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Project;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.String;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.String;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.String;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.StringComment;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.StringComment;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.StringComment;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.StringComment;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Suggestion;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Suggestion;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Suggestion;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Suggestion;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Suggestion;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Task;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Task;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Task;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Apps.Crowdin.Webhooks.Handlers.Base;
using Apps.Crowdin.Webhooks.Models.Inputs;
using Blackbird.Applications.Sdk.Common.Webhooks;
using Crowdin.Api.Webhooks;
using EventType = Crowdin.Api.Webhooks.EventType;

namespace Apps.Crowdin.Webhooks.Handlers.Project.Translation;

Expand Down