예제 #1
0
        public IEnumerable <NeverBounceValidationResult> GetNeverBounceValidationResult(IEnumerable <string> recipients)
        {
            if (recipients.Count() == 0)
            {
                return(Enumerable.Empty <NeverBounceValidationResult>());
            }

            var jobIds = new List <int>();

            foreach (var batch in recipients.Batch(1000))
            {
                var model = new JobCreateSuppliedDataRequestModel();
                model.auto_parse = true;
                model.auto_start = true;
                model.input      = new List <object>();
                foreach (var r in batch)
                {
                    model.input.Add(new { email = r });
                }

                // Create job from supplied data
                JobCreateResponseModel resp = sdk.Jobs.CreateFromSuppliedData(model).Result;
                jobIds.Add(resp.job_id);
            }

            var result = new List <NeverBounceValidationResult>();

            foreach (var jobId in jobIds)
            {
                var emails = GetEmailJobValidationResult(jobId);
                result.AddRange(emails);
            }

            return(result);
        }
예제 #2
0
        /// <summary>
        ///     This method calls the create job end point using supplied data for input
        ///     See: "https://developers.neverbounce.com/v4.0/reference#jobs-create"
        /// </summary>
        /// <param name="model">JobCreateRequestModel</param>
        /// <returns>JobCreateResponseModel</returns>
        public async Task <JobCreateResponseModel> CreateFromSuppliedData(JobCreateSuppliedDataRequestModel model)
        {
            var client = new NeverBounceHttpClient(_client, _apiKey, _host);
            var result = await client.MakeRequest("POST", "/jobs/create", model);

            return(JsonConvert.DeserializeObject <JobCreateResponseModel>(result));
        }
예제 #3
0
        public static async Task <JobCreateResponseModel> CreateSuppliedData(NeverBounceSdk sdk)
        {
            var model = new JobCreateSuppliedDataRequestModel();

            model.filename   = "Created From dotNET.csv";
            model.auto_parse = true;
            model.auto_start = false;
            var data = new List <object>();

            data.Add(new { id = "3", email = "*****@*****.**", name = "Fred McValid" });
            data.Add(new { id = "4", email = "*****@*****.**", name = "Bob McInvalid" });
            model.input = data;
            return(await sdk.Jobs.CreateFromSuppliedData(model));
        }