示例#1
0
        /// <summary>
        /// Mails the chimp_ unsubscribe.
        /// Will retrieve the Contacts.FirstName, Contacts.LastName, Contacts.Email using the ContactId.
        /// Invoke the MailChimp API listUnsubscribe
        /// </summary>
        /// <param name="ContactId">The contact id.</param>
        /// <param name="MailChimpListId">The mail chimp list id.</param>
        /// <returns></returns>
        public MailChimp_Response MailChimp_Unsubscribe(int ContactId, string MailChimpListId)
        {
            MailChimp_Response response = new MailChimp_Response();

            response.hdr = new RespHdr();

            if (ContactId <= 0)
            {
                response.hdr.Successful = false;
                response.hdr.StatusInfo = string.Format("MailChimpMgr: ContactId is less than 0.");
                return(response);
            }

            if (string.IsNullOrEmpty(MailChimpListId))
            {
                response.hdr.Successful = false;
                response.hdr.StatusInfo = string.Format("MailChimpMgr: MailChimpListId is null.");
                return(response);
            }

            string apiKey = string.Empty;

            apiKey = GetApiKey(MailChimpListId);
            if (string.IsNullOrEmpty(apiKey))
            {
                response.hdr.Successful = false;
                response.hdr.StatusInfo = string.Format("MailChimpMgr: MailChimpAPIKey is null.");
                return(response);
            }

            var contact = _dataAccess.GetMailChimpContact(ContactId);

            return(_mailChimpApi.ListUnsubscribe(apikey: apiKey, mailChimpListId: MailChimpListId, subscriber: contact));
        }
示例#2
0
        public void tListUnSubscribe()
        {
            var subscriber = new Table.MailChimpContact();

            subscriber.Email = "*****@*****.**";
            Assert.AreEqual(true, mailChimpApi.ListUnsubscribe(_apiKey, _listId, subscriber));
        }