/// <summary>
        /// Requests data each time the period specified by Interval has elapsed.
        /// </summary>
        public async override Task RequestData()
        {
            try {
                MailChimp.Net.MailChimpManager mailChimp = new MailChimp.Net.MailChimpManager(APIKey);
                MailChimp.Net.Models.Report    report    = await mailChimp.Reports.GetReportAsync(CampaignID);

                await WriteToDatabase(new List <InfluxDatapoint <InfluxValueField> >() { MailChimp_CampaignReport.CreateInfluxDatapoint(MeasurementName, report) });
            }
            catch (Exception ex) {
                Console.WriteLine("Error trying to request MailChimp data for campaign ID '" + CampaignID + "' using API key '" + APIKey + "': " + ex.Message);
            }
        }
Exemplo n.º 2
0
        public bool addUserToList(string apiKey, string idList, string email)
        {
            MailChimp.Net.Models.Member member = new MailChimp.Net.Models.Member()
            {
                EmailAddress = email,
                Status       = MailChimp.Net.Models.Status.Subscribed
            };

            MailChimp.Net.Interfaces.IMailChimpManager mailChimpManager = new MailChimp.Net.MailChimpManager(apiKey);
            var result = Task.Run(() => mailChimpManager.Members.AddOrUpdateAsync(idList, member)).Result;

            return(result.Id != null);
        }