/// <summary> /// Mails the chimp_ subscribe. /// Will retrieve the Contacts.FirstName, Contacts.LastName, Contacts.Email using the ContactId. /// Invoke the MailChimp API listSubscribe /// </summary> /// <param name="ContactId">The contact id.</param> /// <param name="MailChimpListId">The mail chimp list id.</param> /// <returns></returns> public MailChimp_Response MailChimp_Subscribe(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.ListSubscribe(apikey: apiKey, mailChimpListId: MailChimpListId, subscriber: contact)); }
public void ListSubscribe() { var subscriber = new Table.MailChimpContact(); subscriber.Email = "*****@*****.**"; subscriber.FirstName = "Jac1"; subscriber.LastName = "Zhang1"; Assert.AreEqual(true, mailChimpApi.ListSubscribe(_apiKey, _listId, subscriber)); }