/// <summary> /// Batches the unsubscribe. /// </summary> /// <param name="recordList">The records</param> public virtual listBatchUnsubscribeOutput BatchUnsubscribe(IEnumerable <MailChimpEventQueueRecord> recordList) { if (String.IsNullOrEmpty(_mailChimpSettings.DefaultListId)) { throw new ArgumentException("MailChimp list is not specified"); } var input = new listBatchUnsubscribeInput(); //any directive overrides input.api_Validate = true; input.api_AccessType = EnumValues.AccessType.Serial; input.api_OutputType = EnumValues.OutputType.JSON; //method parameters input.parms.apikey = _mailChimpSettings.ApiKey; input.parms.id = _mailChimpSettings.DefaultListId; //batch the emails var batch = recordList.Select(sub => sub.Email).ToList(); input.parms.emails = batch; //execution var cmd = new listBatchUnsubscribe(input); listBatchUnsubscribeOutput listSubscribeOutput = cmd.Execute(); return(listSubscribeOutput); }
/// <summary> /// Batches the unsubscribe. /// </summary> /// <param name="recordList">The records</param> public virtual listBatchUnsubscribeOutput BatchUnsubscribe(IEnumerable<MailChimpEventQueueRecord> recordList) { if (String.IsNullOrEmpty(_mailChimpSettings.DefaultListId)) throw new ArgumentException("MailChimp list is not specified"); var input = new listBatchUnsubscribeInput(); //any directive overrides input.api_Validate = true; input.api_AccessType = EnumValues.AccessType.Serial; input.api_OutputType = EnumValues.OutputType.JSON; //method parameters input.parms.apikey = _mailChimpSettings.ApiKey; input.parms.id = _mailChimpSettings.DefaultListId; //batch the emails var batch = recordList.Select(sub => sub.Email).ToList(); input.parms.emails = batch; //execution var cmd = new listBatchUnsubscribe(input); listBatchUnsubscribeOutput listSubscribeOutput = cmd.Execute(); return listSubscribeOutput; }
/// <summary> /// Lists the batch unsubscribe. /// </summary> /// <param name="apikey">The apikey.</param> /// <param name="mailChimpListId">The mail chimp list id.</param> /// <param name="subscriberList">The subscriber list.</param> /// <returns></returns> public MailChimp_Response ListBatchUnsubscribe(string apikey, string mailChimpListId, List <Table.MailChimpContact> subscriberList) { //todo:pass MailChimp_Response response = new MailChimp_Response(); response.hdr = new RespHdr(); string StatusInfo = ""; var input = GetListBatchUnsubscribeInput(apikey, mailChimpListId); var deleteEmails = (from subscriber in subscriberList select subscriber.Email).ToList(); input.parms.emails = deleteEmails; // execution var cmd = new listBatchUnsubscribe(input); var output = cmd.Execute(); if (output.api_ErrorMessages.Count > 0) { StringBuilder sbErrDetail = new StringBuilder(); foreach (var apiErrorMessage in output.api_ErrorMessages) { sbErrDetail.AppendLine(string.Format("error code:{0},error msg:{1}", apiErrorMessage.code, apiErrorMessage.error)); StatusInfo = apiErrorMessage.error; } string errMsg = string.Format("apikey:{4}mailChimpListId:{5}\r\n{0}{1}{2}{3}", output.api_Request, output.api_Response, // raw data sbErrDetail, output.api_ValidatorMessages, apikey, mailChimpListId); int Event_id = 5017; EventLog.WriteEntry(InfoHubEventLog.LogSource, errMsg, EventLogEntryType.Warning, Event_id, Category); response.hdr.Successful = false; response.hdr.StatusInfo = "MailChimpMgr: " + StatusInfo; return(response); } else { //Console.Write(output); response.hdr.Successful = true; response.hdr.StatusInfo = ""; return(response); } }
private listBatchUnsubscribeOutput listBatchUnSubscribe_method(string apikey, string id, List<string> EMails) { listBatchUnsubscribeInput input = new listBatchUnsubscribeInput(); input.parms.apikey = apikey; input.parms.delete_member = true; input.parms.emails = EMails; input.parms.id = id; input.parms.send_goodbye = false; input.parms.send_notify = false; listBatchUnsubscribe cmd_Unsubscribe = new listBatchUnsubscribe(input); listBatchUnsubscribeOutput output = cmd_Unsubscribe.Execute(); return output; }