public EmailAdminNotifier(IOptions <SendGridConfig> sendGridConfiguration, IOptions <AdminContactInfo> adminContactInfo) { this.adminContactInfo = adminContactInfo.Value; this.sendGridSettings = sendGridConfiguration.Value; this.sendGridApi = new Web(sendGridConfiguration.Value.Key); }
private SendGridService GetSendGridService() { var apiKey = ""; var sendGridConifg = new SendGridConfig(apiKey); var service = new SendGridService(sendGridConifg); return(service); }
public static SendGridConfig GetConfigFromEnvVars() { SendGridConfig sendGridConfig = new SendGridConfig(); sendGridConfig.sendGridApiUser = Environment.GetEnvironmentVariable("SendGrid_ApiUser"); sendGridConfig.sendGridApiKey = Environment.GetEnvironmentVariable("SendGrid_ApiKey"); if (sendGridConfig.sendGridApiKey == null || sendGridConfig.sendGridApiUser == null) { throw new Exception("SendGrid configuration not found in environment vars or incomplete"); } return(sendGridConfig); }
public UserApiController(IUserTokenService userTokenService , IUserService userService , IAuthenticationService <int> authService , ILogger <TempAuthApiController> logger , IOptions <SecurityConfig> options , IOptions <SendGridConfig> sendGridConfig , IEmailService service) : base(logger) { _service = service; _sendGridConfig = sendGridConfig.Value; _userService = userService; _userTokenService = userTokenService; _authService = authService; _options = options; }
public void InitializeTest() { _sendGridConfig = new SendGridConfig() { ApiKey = "YOUR-API-KEY", SenderEmailAddress = "YOUR-CATCHALL-EMAIL-ADDRESS", SenderEmailName = "Do Not Reply", TemplateId = "SENDGRID-TEMPLATE-ID" }; _images = new Dictionary <string, string>() { { "TestImage1.jpg", "Images\\TestImage1.jpg" }, { "TestImage21.jpg", "Images\\TestImage2.jpg" } }; }
async static Task Main(string[] args) { string currentDirectory = Environment.CurrentDirectory; IConfigurationRoot config = new ConfigurationBuilder() .SetBasePath(currentDirectory) .AddJsonFile("appsettings.json", true) .Build(); CosmosConfig cosmosConfig = config.GetSection("CosmosConfig").Get <CosmosConfig>(); SendGridConfig sendGridConfig = config.GetSection("SendGridConfig").Get <SendGridConfig>(); SendGridClient sgc = new SendGridClient(sendGridConfig.ApiKey); CosmosDbService cosmosDbService = InitializeCosmosClientInstance(cosmosConfig); EmailTemplateUploader emailTemplateUploader = new EmailTemplateUploader( sgc, cosmosDbService ); await emailTemplateUploader.Migrate(); }
public EmailService(IOptions <SendGridConfig> options, IOptions <SiteConfig> siteConfig, IPasswordService passwordService) { _config = options.Value; _siteConfig = siteConfig.Value; _passwordService = passwordService; }
public SendGridService(IOptions <AppConfig> _appSettings) { appSettings = _appSettings.Value; sendGridConfig = appSettings.SendGrid; sendGridClient = new SendGridClient(sendGridConfig.ApiKey); }
public void SetUp() { _sendGridConfigSettings = new SendGridConfig() { ApiKey = "TestKey", FromName = "Test Name", FromEmail = "Test Email", BaseUrl = "Base Url" }; _sendGridConfig = new Mock <IOptions <SendGridConfig> >(); _sendGridConfig.SetupGet(x => x.Value).Returns(_sendGridConfigSettings); _sendGridClient = new Mock <ISendGridClient>(); _templateId = "testTemplateId"; Templates templates = new Templates(); Template template = new Template() { id = _templateId, name = "KnownTemplate" }; templates.templates = new Template[1] { template }; string responseBody = JsonConvert.SerializeObject(templates); _templatesResponse = Task.FromResult(new Response(System.Net.HttpStatusCode.OK, new StringContent(responseBody), null)); _sendGridClient.Setup(x => x.RequestAsync( It.IsAny <SendGridClient.Method>(), It.IsAny <string>(), It.IsAny <string>(), It.Is <String>(s => s.Contains("templates")), It.IsAny <CancellationToken>())) .Returns(() => _templatesResponse ); _memCacheTemplate = new Mock <IMemDistCache <Template> >(); _template = template; _memCacheTemplate.Setup(x => x.GetCachedDataAsync( It.IsAny <Func <CancellationToken, Task <Template> > >(), It.IsAny <string>(), It.IsAny <RefreshBehaviour>(), It.IsAny <CancellationToken>(), It.IsAny <NotInCacheBehaviour>())) .ReturnsAsync(() => _template); _memCacheUnsubscribeGroup = new Mock <IMemDistCache <UnsubscribeGroup> >(); _unsubscribeGroup = new UnsubscribeGroup() { id = -1 }; _memCacheUnsubscribeGroup.Setup(x => x.GetCachedDataAsync( It.IsAny <Func <CancellationToken, Task <UnsubscribeGroup> > >(), It.IsAny <string>(), It.IsAny <RefreshBehaviour>(), It.IsAny <CancellationToken>(), It.IsAny <NotInCacheBehaviour>())) .ReturnsAsync(() => _unsubscribeGroup); UnsubscribeGroup[] groups = new UnsubscribeGroup[1]; groups[0] = new UnsubscribeGroup() { id = 1, name = "KnownGroup", description = "KnownGroup description" }; string groupsResponseBody = JsonConvert.SerializeObject(groups); _groupsResponse = Task.FromResult(new Response(System.Net.HttpStatusCode.OK, new StringContent(groupsResponseBody), null)); _sendGridClient.Setup(x => x.RequestAsync( It.IsAny <SendGridClient.Method>(), It.IsAny <string>(), It.IsAny <string>(), It.Is <String>(s => s.Contains("groups")), It.IsAny <CancellationToken>())) .Returns(() => _groupsResponse ); _sendGridClient.Setup(x => x.SendEmailAsync( It.IsAny <SendGridMessage>(), It.IsAny <CancellationToken>() )).Returns(() => _sendEmailResponse); _classUnderTest = new ConnectSendGridService(_sendGridConfig.Object, _sendGridClient.Object, _memCacheTemplate.Object, _memCacheUnsubscribeGroup.Object); }
public EmailService(IOptions <SendGridConfig> options) { _config = options.Value; }
public void SetConfig(SenderConfiguration senderConfiguration) { _option = senderConfiguration.SendGrid; }
public SendGridService(SendGridConfig smtpOptions) { _smtpOptions = smtpOptions; }
public EmailService(IOptions <SendGridConfig> config) { _config = config.Value; }