예제 #1
0
 /// <summary>
 /// Constructor dependency injection
 /// </summary>
 /// <param name="emailServiceApi"></param>
 /// <param name="mailJetClient"></param>
 /// <param name="globalConfigs"></param>
 public EmailServiceApi(IEmailService emailServiceApi, IMailjetClient mailJetClient, GlobalConfigs globalConfigs)
 {
     _connected       = true;
     _emailServiceApi = emailServiceApi;
     _mailJetClient   = mailJetClient;
     _globalConfigs   = globalConfigs;
 }
        public static async Task <string> GetValidSenderEmail(IMailjetClient client)
        {
            MailjetRequest request = new MailjetRequest
            {
                Resource = Sender.Resource
            };

            MailjetResponse response = await client.GetAsync(request);

            Assert.AreEqual(200, response.StatusCode);

            foreach (var emailObject in response.GetData())
            {
                if (emailObject.Type != JTokenType.Object)
                {
                    continue;
                }

                if (emailObject.Value <string>("Status") == "Active")
                {
                    return(emailObject.Value <string>("Email"));
                }
            }

            Assert.Fail("Cannot find Active sender address under given account");
            throw new AssertFailedException();
        }
        public async Task TestInitialize()
        {
            _client = new MailjetClient(Environment.GetEnvironmentVariable("MJ_APIKEY_PUBLIC"),
                                        Environment.GetEnvironmentVariable("MJ_APIKEY_PRIVATE"));

            _senderEmail = await GetValidSenderEmail(_client);
        }
 /// <summary>
 /// Constructor dependency injection
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="mailJetClient"></param>
 /// <param name="globalConfigs"></param>
 /// <param name="mailGunConfig"></param>
 public EmailServiceApi(ILogger <EmailServiceApi> logger, IMailjetClient mailJetClient, GlobalConfigs globalConfigs, MailGunConfig mailGunConfig)
 {
     _connected     = true;
     _logger        = logger;
     _mailJetClient = mailJetClient;
     _globalConfigs = globalConfigs;
     _mailGunConfig = mailGunConfig;
 }
예제 #5
0
 public EmailService(IMailjetClient mailjetClient)
 {
     _mailjetClient = mailjetClient;
 }