Skip to content

Commit 3df20c5

Browse files
committed
Subscription model updates
1 parent 9623a54 commit 3df20c5

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

src/Umbraco.Cms.Integrations.Automation.Zapier/Constants.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ public static class Configuration
2323
public const string Settings = "Umbraco:Forms:Integrations:Automation:Zapier:Settings";
2424
}
2525

26-
public static class Content
26+
public static class ContentProperties
2727
{
2828
public const string Id = "id";
2929

3030
public const string Name = "name";
3131

3232
public const string PublishDate = "publishDate";
3333
}
34+
35+
public static class EntityType
36+
{
37+
public const int Content = 1;
38+
39+
public const int Form = 2;
40+
}
3441
}
3542
}

src/Umbraco.Cms.Integrations.Automation.Zapier/Extensions/ContentExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public static Dictionary<string, string> ToContentTypeDictionary(this IContentTy
1515
{
1616
var contentDict = new Dictionary<string, string>
1717
{
18-
{Constants.Content.Id, "1" },
19-
{Constants.Content.Name, contentType.Name },
20-
{Constants.Content.PublishDate, DateTime.UtcNow.ToString("s") }
18+
{Constants.ContentProperties.Id, "1" },
19+
{Constants.ContentProperties.Name, contentType.Name },
20+
{Constants.ContentProperties.PublishDate, DateTime.UtcNow.ToString("s") }
2121
};
2222

2323
foreach (var propertyType in contentType.PropertyTypes)
@@ -32,9 +32,9 @@ public static Dictionary<string, string> ToContentDictionary(this IContent conte
3232
{
3333
var contentDict = new Dictionary<string, string>
3434
{
35-
{Constants.Content.Id, contentNode.Id.ToString() },
36-
{Constants.Content.Name, contentNode.Name },
37-
{Constants.Content.PublishDate, contentNode.UpdateDate.ToString("s") }
35+
{Constants.ContentProperties.Id, contentNode.Id.ToString() },
36+
{Constants.ContentProperties.Name, contentNode.Name },
37+
{Constants.ContentProperties.PublishDate, contentNode.UpdateDate.ToString("s") }
3838
};
3939

4040
foreach (var prop in contentNode.Properties)

src/Umbraco.Cms.Integrations.Automation.Zapier/Migrations/ZapierMigration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public class ZapierSubscriptionHookTable
6666
/// 2. form ID for form triggers
6767
/// </summary>
6868
[Column("EntityId")]
69-
[Index(IndexTypes.UniqueNonClustered, Name = "IX_ZapierSubscriptionHook_EntityId")]
7069
public string EntityId { get; set; }
7170

7271
[Column("Type")]

src/Umbraco.Cms.Integrations.Automation.Zapier/Models/Dtos/EntityDto.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Umbraco.Cms.Integrations.Automation.Zapier/Models/Dtos/SubscriptionDto.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System.Linq;
22

33
using Newtonsoft.Json;
44

@@ -15,9 +15,20 @@ public class SubscriptionDto
1515
[JsonProperty("type")]
1616
public int Type { get; set; }
1717

18-
[JsonProperty("typeName")]
19-
public string TypeName => Enum.Parse(typeof(EntityDto.Type), Type.ToString()).ToString();
18+
[JsonProperty("typeName")]
19+
public string TypeName
20+
{
21+
get
22+
{
23+
var entityType = typeof(Constants.EntityType);
2024

25+
var typeField = entityType.GetFields()
26+
.FirstOrDefault(p => p.GetValue(entityType).Equals(Type));
27+
28+
return typeField != null ? typeField.Name : string.Empty;
29+
}
30+
}
31+
2132
[JsonProperty("hookUrl")]
2233
public string HookUrl { get; set; }
2334

0 commit comments

Comments
 (0)