/**
        ** listMemberInfo method definitions
        **/
        public MCMemberInfo listMemberInfo(string listId, string email_address)
        {
            DummyMCMemberInfo tmp = this.api.listMemberInfo(this.apikey, listId, email_address);
            XmlRpcStruct      s   = (XmlRpcStruct)tmp.merges;

            MCMergeVar[] vars  = new MCMergeVar[(s).Count];
            MCMemberInfo toret = new MCMemberInfo();

            //copy everything normal over
            toret.email      = tmp.email;
            toret.email_type = tmp.email_type;
            toret.status     = tmp.status;
            toret.timestamp  = tmp.timestamp;
            int i = 0;

            foreach (string tag in s.Keys)
            {
                MCMergeVar v = new MCMergeVar();
                v.tag   = tag;
                v.val   = (string)s[tag];
                vars[i] = v;
                i++;
            }
            toret.merges = vars;
            return(toret);
        }
Esempio n. 2
0
 public void update_member()
 {
     // listUpdateMember(string listId, string email_address, MCMergeVar[] merges, string email_type, bool replace_interests){
         string list_id = "YOUR_LIST_ID";
         string email = "*****@*****.**";
         bool replace_interests = false;
         string email_type = "text";
         MCMergeVar[] merges = new MCMergeVar[3];
         merges[0].tag = "FNAME";
         merges[0].val = "David";
         merges[1].tag = "LNAME";
         merges[1].val = "Gilmour";
         merges[2].tag = "INTERESTS";
         merges[2].val = "Sand";
         if (this.api.listUpdateMember(list_id, email, merges, email_type, replace_interests) ){
             Console.WriteLine("Woot!");
         } else {
             Console.WriteLine("A failure of epic proportions has occurred!");
         }
 }
Esempio n. 3
0
    public void list_subscribe()
    {
        string list_id = "YOUR_LIST_ID";
            string email = "*****@*****.**";
            string email_type = "text";
            MCMergeVar[] merges = new MCMergeVar[3];
            merges[0].tag = "FNAME";
            merges[0].val = "Roger";
            merges[1].tag = "LNAME";
            merges[1].val = "Waters";
            merges[2].tag = "INTERESTS";
            merges[2].val = "Sand";

            if ( this.api.listSubscribe( list_id, email, merges, email_type, true) ){
                Console.WriteLine("Woot!");
            } else {
                Console.WriteLine("A failure of epic proportions has occurred!");
            }
    }
        /// <summary>
        /// Method used to subscribe a person to the MailChimp List (and Arena newsletter).
        /// </summary>
        /// <param name="person">person to subscribe</param>
        /// <param name="listID">MailChimp list ID</param>
        /// <param name="newsletterID">Arena's newsletter ID</param>
        private void Subscribe( Person person, string listID, int newsletterID, ListItemCollection listItemCollection )
        {
            MCMergeVar[] merges = new MCMergeVar[5];
            BuildMergeVars( person, merges, listItemCollection );

            if ( api.listSubscribe( listID, person.Emails.FirstActive, merges ) )
            {
                // Track the subscription locally too
                NewsletterSubscription subscription = FetchOrCreateNewsletterSubscription( person, newsletterID );
                subscription.Status = true;
                subscription.Save( CurrentUser.Identity.Name );
            }
            else
            {
                AddMsg( "An error prevented the person from being subscribed to the list." );
            }
        }
        /// <summary>
        /// Save the person's interest groups.  This already assumes the person is Subscribed.
        /// </summary>
        /// <param name="person"></param>
        /// <param name="listID"></param>
        /// <param name="newsletterID"></param>
        /// <param name="listItemCollection"></param>
        private bool SaveGroups( Person person, string listID, int newsletterID, ListItemCollection listItemCollection )
        {
            MCMergeVar[] merges = new MCMergeVar[5];
            BuildMergeVars( person, merges, listItemCollection );

            if ( ! api.listUpdateMember( listID, person.Emails.FirstActive, merges, "", true ) )
            {
                AddMsg( "An error occurred while trying to save the person's interests." );
                return false;
            }
            else
            {
                return true;
            }
        }
        /// <summary>
        /// A small helper method to create the basic merge varibles from a person (FNAME, LNAME, BIRTHDATE, GENDER).
        /// </summary>
        /// <param name="person"></param>
        /// <param name="merges"></param>
        private static void BuildMergeVars( Person person, MCMergeVar[] merges, ListItemCollection listItemCollection)
        {
            merges[0].tag = "FNAME";
            merges[0].val = person.FirstName;
            merges[1].tag = "LNAME";
            merges[1].val = person.LastName;

            if ( person.BirthDate != Constants.NULL_DATE )
            {
                merges[2].tag = "BIRTHDATE";
                merges[2].val = person.BirthDate.ToShortDateString();
            }
            merges[3].tag = "GENDER";
            merges[3].val = person.Gender.ToString();

            merges[4].tag = "INTERESTS";

            // Turn the selected items in the checkbox into a comma delimited list of interests (ex: "A,B,C")
            var values =  listItemCollection.Cast<ListItem>().Where( n => n.Selected ).Select( n => n.Value ).ToArray();
            merges[4].val = string.Join( ",", values );
        }
 /**
  ** Misc Private Helper Methods
  **/
 private XmlRpcStruct mergeArrayToStruct(MCMergeVar[] merges)
 {
     XmlRpcStruct mv = new XmlRpcStruct();
     foreach (MCMergeVar var in merges)
     {
         if (var.tag != null)
             mv.Add(var.tag, var.val);
     }
     return mv;
 }
        public bool listUpdateMember(string listId, string email_address, MCMergeVar[] merges, string email_type, bool replace_interests)
        {
            XmlRpcStruct mv = this.mergeArrayToStruct(merges);

            return this.api.listUpdateMember(this.apikey, listId, email_address, mv, email_type, replace_interests);
        }
 public bool listUpdateMember(string listId, string email_address, MCMergeVar[] merges, string email_type)
 {
     return this.listUpdateMember(listId, email_address, merges, email_type, true);
 }
 /**
  ** listUpdateMember method definitions
  **/
 public bool listUpdateMember(string listId, string email_address, MCMergeVar[] merges)
 {
     return this.listUpdateMember(listId, email_address, merges, "html");
 }
        public bool listSubscribe(string id, string email_address, MCMergeVar[] merges, string email_type, bool double_optin)
        {
            XmlRpcStruct mv = this.mergeArrayToStruct(merges);

            return this.api.listSubscribe(this.apikey, id, email_address, mv, email_type, double_optin);
        }
 public bool listSubscribe(string id, string email_address, MCMergeVar[] merges, string email_type)
 {
     return this.listSubscribe(id, email_address, merges, email_type, true);
 }
 public bool listSubscribe(string id, string email_address, MCMergeVar[] merges)
 {
     return this.listSubscribe(id, email_address, merges, "html");
 }
 /**
  ** listMemberInfo method definitions
  **/
 public MCMemberInfo listMemberInfo(string listId, string email_address)
 {
     DummyMCMemberInfo tmp = this.api.listMemberInfo(this.apikey, listId, email_address);
     XmlRpcStruct s = (XmlRpcStruct)tmp.merges;
     MCMergeVar[] vars = new MCMergeVar[(s).Count];
     MCMemberInfo toret = new MCMemberInfo();
     //copy everything normal over
     toret.email = tmp.email;
     toret.email_type = tmp.email_type;
     toret.status = tmp.status;
     toret.timestamp = tmp.timestamp;
     int i = 0;
     foreach (string tag in s.Keys)
     {
         MCMergeVar v = new MCMergeVar();
         v.tag = tag;
         v.val = (string)s[tag];
         vars[i] = v;
         i++;
     }
     toret.merges = vars;
     return toret;
 }