diff --git a/Apps.XTM/Apps.XTM.csproj b/Apps.XTM/Apps.XTM.csproj
index d663aa5..bbe4bf9 100644
--- a/Apps.XTM/Apps.XTM.csproj
+++ b/Apps.XTM/Apps.XTM.csproj
@@ -4,7 +4,7 @@
enable
enable
XTM
- 3.1.5
+ 3.2.0
Translation management system that centralizes localization assets and enables fast, accurate translation and deployment of content tailored to any audience in any territory
Apps.XTM
12
@@ -18,8 +18,7 @@
-
-
+
diff --git a/Apps.XTM/DataSourceHandlers/EnumHandlers/ProjectStatusHandler.cs b/Apps.XTM/DataSourceHandlers/EnumHandlers/ProjectStatusHandler.cs
new file mode 100644
index 0000000..c4b62c1
--- /dev/null
+++ b/Apps.XTM/DataSourceHandlers/EnumHandlers/ProjectStatusHandler.cs
@@ -0,0 +1,16 @@
+using Blackbird.Applications.Sdk.Common.Dictionaries;
+
+namespace Apps.XTM.DataSourceHandlers.EnumHandlers;
+
+public class ProjectStatusHandler : IStaticDataSourceHandler
+{
+ public Dictionary GetData()
+ {
+ return new()
+ {
+ ["NOT_STARTED"] = "Not started",
+ ["STARTED"] = "Started",
+ ["FINISHED"] = "Finished"
+ };
+ }
+}
\ No newline at end of file
diff --git a/Apps.XTM/Models/Response/Projects/FullProject.cs b/Apps.XTM/Models/Response/Projects/FullProject.cs
index 976b4ef..e4a3fa6 100644
--- a/Apps.XTM/Models/Response/Projects/FullProject.cs
+++ b/Apps.XTM/Models/Response/Projects/FullProject.cs
@@ -19,4 +19,6 @@ public class FullProject
[Display("Target languages")] public IEnumerable TargetLanguages { get; set; }
[Display("Template ID")] public string TemplateId { get; set; }
+
+ public string Status { get; set; }
}
\ No newline at end of file
diff --git a/Apps.XTM/Polling/Models/Memory/DateMemory.cs b/Apps.XTM/Polling/Models/Memory/DateMemory.cs
new file mode 100644
index 0000000..abb29a0
--- /dev/null
+++ b/Apps.XTM/Polling/Models/Memory/DateMemory.cs
@@ -0,0 +1,6 @@
+namespace Apps.XTM.Polling.Models.Memory;
+
+public class DateMemory
+{
+ public DateTime LastInteractionDate { get; set; }
+}
\ No newline at end of file
diff --git a/Apps.XTM/Polling/Models/Memory/ProjectStatusMemory.cs b/Apps.XTM/Polling/Models/Memory/ProjectStatusMemory.cs
new file mode 100644
index 0000000..a1d8e42
--- /dev/null
+++ b/Apps.XTM/Polling/Models/Memory/ProjectStatusMemory.cs
@@ -0,0 +1,6 @@
+namespace Apps.XTM.Polling.Models.Memory;
+
+public class ProjectStatusMemory
+{
+ public string Status { get; set; }
+}
\ No newline at end of file
diff --git a/Apps.XTM/Polling/PollingList.cs b/Apps.XTM/Polling/PollingList.cs
new file mode 100644
index 0000000..41aa362
--- /dev/null
+++ b/Apps.XTM/Polling/PollingList.cs
@@ -0,0 +1,129 @@
+using System.Globalization;
+using Apps.XTM.Constants;
+using Apps.XTM.DataSourceHandlers.EnumHandlers;
+using Apps.XTM.Invocables;
+using Apps.XTM.Models.Request.Projects;
+using Apps.XTM.Models.Response.Projects;
+using Apps.XTM.Polling.Models.Memory;
+using Blackbird.Applications.Sdk.Common;
+using Blackbird.Applications.Sdk.Common.Dictionaries;
+using Blackbird.Applications.Sdk.Common.Invocation;
+using Blackbird.Applications.Sdk.Common.Polling;
+using RestSharp;
+
+namespace Apps.XTM.Polling;
+
+[PollingEventList]
+public class PollingList : XtmInvocable
+{
+ public PollingList(InvocationContext invocationContext) : base(invocationContext)
+ {
+ }
+
+ [PollingEvent("On projects created (polling)", "On any new projects created")]
+ public Task> OnProjectsCreated(
+ PollingEventRequest request) => ProcessProjectsPolling(request,
+ $"createdDateFrom={request.Memory?.LastInteractionDate.ToString("o", CultureInfo.InvariantCulture)}");
+
+ [PollingEvent("On projects updated (polling)", "On any projects are updated")]
+ public Task> OnProjectsUpdated(
+ PollingEventRequest request) => ProcessProjectsPolling(request,
+ $"modifiedDateFrom={request.Memory?.LastInteractionDate.ToString("o", CultureInfo.InvariantCulture)}");
+
+ [PollingEvent("On projects finished (polling)", "On any projects are finished")]
+ public Task> OnProjectsFinished(
+ PollingEventRequest request) => ProcessProjectsPolling(request,
+ $"finishedDateFrom={request.Memory?.LastInteractionDate.ToString("o", CultureInfo.InvariantCulture)}");
+
+ [PollingEvent("On project status changed (polling)", "On status of the specific project changed")]
+ public async Task> OnProjectStatusChanged(
+ PollingEventRequest request,
+ [PollingEventParameter] ProjectRequest project,
+ [PollingEventParameter] [Display("Project status")] [StaticDataSource(typeof(ProjectStatusHandler))]
+ string? status)
+ {
+ var projectEntity = (await Client.ExecuteXtmWithJson>(
+ $"{ApiEndpoints.Projects}?ids={project.ProjectId}",
+ Method.Get,
+ null,
+ Creds)).FirstOrDefault() ?? throw new InvalidOperationException("Not project found with the provided ID");
+
+ if (request.Memory is null)
+ {
+ return new()
+ {
+ FlyBird = false,
+ Memory = new()
+ {
+ Status = projectEntity.Status
+ }
+ };
+ }
+
+ return new()
+ {
+ FlyBird = request.Memory.Status != projectEntity.Status &&
+ (status == null || projectEntity.Status == status),
+ Result = projectEntity,
+ Memory = new()
+ {
+ Status = projectEntity.Status
+ }
+ };
+ }
+
+ private async Task> ProcessProjectsPolling(
+ PollingEventRequest request,
+ string query)
+ {
+ if (request.Memory is null)
+ {
+ return new()
+ {
+ FlyBird = false,
+ Memory = new()
+ {
+ LastInteractionDate = DateTime.UtcNow
+ }
+ };
+ }
+
+ var result = new List();
+ var page = 1;
+
+ List response;
+ do
+ {
+ response = await Client.ExecuteXtmWithJson>(
+ $"{ApiEndpoints.Projects}?{query}&page={page}",
+ Method.Get,
+ null,
+ Creds);
+ result.AddRange(response);
+
+ page++;
+ } while (response.Any());
+
+ if (!result.Any())
+ {
+ return new()
+ {
+ FlyBird = false,
+ Memory = new()
+ {
+ LastInteractionDate = DateTime.UtcNow
+ }
+ };
+ }
+
+ return new()
+ {
+ FlyBird = true,
+ Result = new(result),
+ Memory = new()
+ {
+ LastInteractionDate = DateTime.UtcNow
+ }
+ };
+ }
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 13c496d..f8a2fb3 100644
--- a/README.md
+++ b/README.md
@@ -78,6 +78,10 @@ Before you can connect you need to make sure that:
- **On project accepted**
- **On project finished**
- **On invoice status changed**
+- **On projects created (polling)**
+- **On projects updated (polling)**
+- **On projects finished (polling)**
+- **On project status changed (polling)**
## Missing features