public override Task <bool> TestAuthentication( ProviderUpdateContext context, IDictionary <string, object> configuration, Guid organizationId, Guid userId, Guid providerDefinitionId) { var adversusCrawlJobData = new AdversusCrawlJobData(); if (configuration.ContainsKey(AdversusConstants.KeyName.ApiKey)) { adversusCrawlJobData.ApiKey = configuration[AdversusConstants.KeyName.ApiKey].ToString(); } if (configuration.ContainsKey(AdversusConstants.KeyName.Username)) { adversusCrawlJobData.Username = configuration[AdversusConstants.KeyName.Username].ToString(); } if (configuration.ContainsKey(AdversusConstants.KeyName.Password)) { adversusCrawlJobData.Password = configuration[AdversusConstants.KeyName.Password].ToString(); } try { var client = _adversusClientFactory.CreateNew(adversusCrawlJobData); var result = client.GetAccountInformation(); return(Task.FromResult(result != null)); } catch (Exception exception) { context.Log.LogError("Could not add Adversus provider", exception); return(Task.FromResult(false)); } }
public IEnumerable <object> GetData(CrawlJobData jobData) { if (!(jobData is AdversusCrawlJobData adversuscrawlJobData)) { yield break; } var client = clientFactory.CreateNew(adversuscrawlJobData); foreach (var item in client.GetCampaigns(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); foreach (var campaignEfficiency in client.GetCampaignEfficiency(item.Id, adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { campaignEfficiency.CampaignId = item.Id; yield return(campaignEfficiency); } } foreach (var item in client.GetProjects(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(client.GetProjectDetails(item.Id, adversuscrawlJobData.Username, adversuscrawlJobData.Password)); } foreach (var item in client.GetContacts(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(client.GetContactDetails(item, adversuscrawlJobData.Username, adversuscrawlJobData.Password)); } foreach (var item in client.GetLeads(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetSessions(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetUsers(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetPools(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetAppointments(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetCDR(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetSales(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetProducts(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } foreach (var item in client.GetSMS(adversuscrawlJobData.Username, adversuscrawlJobData.Password)) { yield return(item); } }