public static TemplateDto FromDomainObject(Template template) { var result = SimpleMapper.Map(template, new TemplateDto()); if (template.Formatting != null) { result.Formatting = NotificationFormattingDto.FromDomainObject(template.Formatting); } else { result.Formatting = new NotificationFormattingDto(); } result.Settings ??= new Dictionary <string, NotificationSettingDto>(); if (template.Settings != null) { foreach (var(key, value) in template.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } return(result); }
public static TemplateDto FromDomainObject(Template source) { var result = SimpleMapper.Map(source, new TemplateDto()); if (source.Formatting != null) { result.Formatting = NotificationFormattingDto.FromDomainObject(source.Formatting); } else { result.Formatting = new NotificationFormattingDto(); } if (source.Settings != null) { foreach (var(key, value) in source.Settings) { if (value != null) { result.Settings[key] = NotificationSettingDto.FromDomainObject(value); } } } return(result); }
public static EventDto FromDomainObject(Event source, App app) { var result = SimpleMapper.Map(source, new EventDto { Settings = new Dictionary <string, ChannelSettingDto>() }); result.Properties = source.Properties ?? EmptyProperties; if (source.Formatting.Subject.TryGetValue(app.Language, out var subject)) { result.DisplayName = subject; } else { result.DisplayName = source.Formatting.Subject.Values.FirstOrDefault() ?? string.Empty; } if (source.Formatting != null) { result.Formatting = NotificationFormattingDto.FromDomainObject(source.Formatting); } if (source.Scheduling != null) { result.Scheduling = SchedulingDto.FromDomainObject(source.Scheduling); } if (source.Settings?.Count > 0) { result.Settings = new Dictionary <string, ChannelSettingDto>(); foreach (var(key, value) in source.Settings) { if (value != null) { result.Settings[key] = ChannelSettingDto.FromDomainObject(value); } } } else { result.Settings = EmptySettings; } result.Counters = source.Counters ?? EmptyCounters; return(result); }
public static async Task Main(string[] args) { var client = NotifoClientBuilder.Create() .SetApiKey(ApiKey) .SetApiUrl("https://*****:*****@squidex.io", Id = userId }; await client.Users.PostUsersAsync(AppId, new UpsertUsersDto { Requests = new List <UpsertUserDto> { request }, }); } Console.WriteLine("Generated Users..."); } if (args?.Contains("--subscriptions") == true) { Console.WriteLine("Generating Subscriptions..."); foreach (var userId in users) { var request = new SubscribeDto { TopicPrefix = TopicPrefix }; await client.Users.PostSubscriptionAsync(AppId, userId, request); } Console.WriteLine("Generated Subscriptions..."); } if (args?.Contains("--no-events") != true) { Console.WriteLine("Generating Events..."); for (var i = 0; i < 1; i++) { var request = new PublishRequestDto { Topic = Topic }; var formatting = new NotificationFormattingDto { Body = new LocalizedText { ["en"] = "Hello Body {{var}}", ["de"] = "Hallo Body {{var}}" }, Subject = new LocalizedText { ["en"] = "Hello Title {{var}}", ["de"] = "Hallo Title {{var}}" }, }; request.Properties = new EventProperties { ["var"] = "123" }; request.Preformatted = formatting; await client.Events.PostEventsAsync(AppId, new PublishManyRequestDto { Requests = new List <PublishRequestDto> { request } }); } Console.WriteLine("Generated Events..."); } }