Exemplo n.º 1
0
 /// <summary>
 /// New Message
 /// </summary>
 /// <param name="title">Message Title</param>
 /// <param name="subject">Message Subject</param>
 /// <param name="fromName">Message Name From</param>
 /// <param name="fromEmail">Message Email From</param>
 /// <param name="analytics">Use Analytics?</param>
 /// <param name="listId">List Id</param>
 /// <param name="templateId">Template Id</param>
 public Message(string title, string subject, string fromName, string fromEmail, string replyEmail, string html, int templateId, List<KeyValuePair<int, string>> edit, List<KeyValuePair<int, string>> repeats, bool analytics, string emails, int listId)
 {
     this.Title = title;
     this.Subject = subject;
     this.FromName = fromName;
     this.FromEmail = fromEmail;
     this.ReplyEmail = replyEmail;
     this.Html = html;
     this.TemplateId = templateId;
     this.Edit = edit;
     this.Repeats = repeats;
     this.Analytics = analytics;
     this.Emails = emails;
     this.ListId = listId;
     this.SegmentId = listId;
 }
Exemplo n.º 2
0
    private void add()
    {
        try
        {
            //Create List
            Mailee.List list = new Mailee.List();
            list.Name = txtName.Text;
            list.Description = txtDescription.Text;
            list.Company = txtCompany.Text;
            list.Address = txtAddress.Text;
            list.Phone = txtPhone.Text;
            list.Site = txtSite.Text;
            list.Facebook = txtFacebook.Text;
            list.Twitter = txtTwitter.Text;
            list.Active = chkActive.Checked;

            //Save List
            list.save();

            //Redirect
            Response.Redirect("View.aspx");

        }
        catch (Mailee.RestExcepction ex)
        {
            //Show http status
            Response.Write(string.Format("statusCode =  {0} <br /> statusDescription = {1}", ex.StatusCode, ex.StatusDesciption));

            //Show error messages
            foreach (string error in ex.ErrorMessages)
                Response.Write("<br />" + error);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// Find all Messages
        /// </summary>
        public static List<Mailee.Message> findAll()
        {
            List<Mailee.Message> messages = new List<Mailee.Message>();

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/messages)
            string url = string.Concat(Mailee.Config.UrlAPI, "messages.xml");

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Create XML
            XmlDocument xmlDoc = new XmlDocument();

            //Load XML
            xmlDoc.LoadXml(htmlReponse);

            //Get Messagess
            XmlNodeList xmlMessages = xmlDoc.GetElementsByTagName("message");

            //Each Messages
            foreach (XmlNode xmlMessage in xmlMessages)
            {
                //Create new Message
                Mailee.Message newMessage = new Mailee.Message();

                //Set properties
                newMessage.Analytics = Mailee.Util.parseBool(xmlMessage.ChildNodes[0].InnerText);
                newMessage.CreatedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[1].InnerText);
                newMessage.DeletedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[2].InnerText);
                newMessage.FromEmail = xmlMessage.ChildNodes[3].InnerText;
                newMessage.FromName = xmlMessage.ChildNodes[4].InnerText;
                newMessage.Id = Mailee.Util.parseInt(xmlMessage.ChildNodes[5].InnerText);
                //newMessage.ListId = Mailee.Util.parseInt(xmlMessage.ChildNodes[6].InnerText);
                newMessage.Log = xmlMessage.ChildNodes[6].InnerText;
                newMessage.NewsletterId = Mailee.Util.parseInt(xmlMessage.ChildNodes[7].InnerText);
                newMessage.ReplyEmail = xmlMessage.ChildNodes[8].InnerText;
                newMessage.SegmentId = Mailee.Util.parseInt(xmlMessage.ChildNodes[9].InnerText);
                newMessage.SendAfter = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[10].InnerText);
                newMessage.SendWhen = xmlMessage.ChildNodes[11].InnerText;
                newMessage.Status = Mailee.Util.parseInt(xmlMessage.ChildNodes[12].InnerText);
                newMessage.Subject = xmlMessage.ChildNodes[13].InnerText;
                newMessage.TemplateId = Mailee.Util.parseInt(xmlMessage.ChildNodes[14].InnerText);
                newMessage.Title = xmlMessage.ChildNodes[15].InnerText;
                newMessage.Total = Mailee.Util.parseInt(xmlMessage.ChildNodes[16].InnerText);

                //Add Message
                messages.Add(newMessage);
            }

            return messages;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update existing Template
        /// </summary>
        private string update()
        {
            //URL (PUT) (api.XXXXXXXXXXXXX.subdomain.mailee.me/templates)
            string url = string.Format("{0}templates/{1}.xml", Mailee.Config.UrlAPI, this.Id);

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("template[title]", this.Title));
            pars.Add(new RestParameter("template[html]", this.Html));

            //Post Data
            string result = Mailee.Rest.put(url, pars);

            return result;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create New Template
        /// </summary>
        private string Create()
        {
            //URL (POST) (api.XXXXXXXXXXXXX.subdomain.mailee.me/templates.xml)
            string url = string.Concat(Mailee.Config.UrlAPI, "templates.xml");

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("template[title]", this.Title));
            pars.Add(new RestParameter("template[html]", this.Html));

            //Post Data
            string result = Mailee.Rest.post(url, pars);

            return result;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Find all Templates
        /// </summary>
        public static List<Mailee.Template> findAll()
        {
            List<Mailee.Template> templates = new List<Mailee.Template>();

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/templates)
            string url = string.Concat(Mailee.Config.UrlAPI, "templates.xml");

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Create XML
            XmlDocument xmlDoc = new XmlDocument();

            //Load XML
            xmlDoc.LoadXml(htmlReponse);

            //Get Templates
            XmlNodeList xmlTemplates = xmlDoc.GetElementsByTagName("template");

            //Each Tenplates
            foreach (XmlNode xmlTemplate in xmlTemplates)
            {
                //Create new Template
                Mailee.Template newTemplate = new Mailee.Template();

                //Set properties
                newTemplate.ClientId = Mailee.Util.parseInt(xmlTemplate.ChildNodes[0].InnerText);
                newTemplate.CreatedAt = Mailee.Util.parseDateTime(xmlTemplate.ChildNodes[1].InnerText);
                newTemplate.DeletedAt = Mailee.Util.parseDateTime(xmlTemplate.ChildNodes[2].InnerText);
                newTemplate.Html = xmlTemplate.ChildNodes[3].InnerText;
                newTemplate.Id = Mailee.Util.parseInt(xmlTemplate.ChildNodes[4].InnerText);
                newTemplate.Simulations = xmlTemplate.ChildNodes[5].InnerText;
                newTemplate.ThumbContentType = xmlTemplate.ChildNodes[6].InnerText;
                newTemplate.ThumbFileName = xmlTemplate.ChildNodes[7].InnerText;
                newTemplate.ThumbFileSize = Mailee.Util.parseInt(xmlTemplate.ChildNodes[8].InnerText);
                newTemplate.ThumbUpdatedAt = Mailee.Util.parseDateTime(xmlTemplate.ChildNodes[9].InnerText);
                newTemplate.Title = xmlTemplate.ChildNodes[10].InnerText;
                newTemplate.UpdatedAt = Mailee.Util.parseDateTime(xmlTemplate.ChildNodes[11].InnerText);

                //Add Template
                templates.Add(newTemplate);
            }

            return templates;
        }
Exemplo n.º 7
0
 /// <summary>
 /// New Contact
 /// </summary>
 /// <param name="id">Id</param>
 /// <param name="email">Email</param>
 /// <param name="name">Name</param>
 /// <param name="internal_id">Id contact your system</param>
 /// <param name="company">Contact Company</param>
 /// <param name="position">Contact Position</param>
 /// <param name="sex">Contact Sex</param>
 /// <param name="birthday">Contact Sex</param>
 /// <param name="age">Contact Age</param>
 /// <param name="phone">Contact Phone</param>
 /// <param name="mobile">Contact Mobile</param>
 /// <param name="address">Contact Address</param>
 /// <param name="notes">Contact Notes</param>
 /// <param name="dynamicValues">Contact Dynamic Values</param>
 public Contact(int id, string email, string name, int internalid, string company, string position, string sex, DateTime? birthday, int age, string phone, string mobile, string address, string notes, List<KeyValuePair<string, string>> dynamicValues)
 {
     this.Id = id;
     this.Email = _email;
     this.Name = _name;
     this.InternalId = _internalId;
     this.Company = _company;
     this.Position = _position;
     this.Sex = _sex;
     this.Birthday = _birthday;
     this.Age = _age;
     this.Phone = _phone;
     this.Mobile = _mobile;
     this.Address = _address;
     this.Notes = _notes;
     this.DynamicValues = _dynamicValues;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Find all Contacts with pagination
        /// </summary>
        /// <param name="page">Page</param>
        public static List<Mailee.Contact> findAll(int page)
        {
            List<Mailee.Contact> contacts = new List<Mailee.Contact>();

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/contacts)
            string url = string.Format("{0}contacts.xml?page={1}", Mailee.Config.UrlAPI, page);

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Create XML
            XmlDocument xmlDoc = new XmlDocument();

            //Load XML
            xmlDoc.LoadXml(htmlReponse);

            //Get Contacts
            XmlNodeList xmlContacts = xmlDoc.GetElementsByTagName("contact");

            //Each Contacts
            foreach (XmlNode xmlContact in xmlContacts)
            {
                //Create new Concat
                Mailee.Contact newContact = new Mailee.Contact();

                //Set properties
                newContact.Address = xmlContact.ChildNodes[0].InnerText;
                newContact.Age = Mailee.Util.parseInt(xmlContact.ChildNodes[1].InnerText);
                newContact.Birthday = Mailee.Util.parseDateTime(xmlContact.ChildNodes[2].InnerText);
                newContact.ClientId = Mailee.Util.parseInt(xmlContact.ChildNodes[3].InnerText);
                newContact.Company = xmlContact.ChildNodes[4].InnerText;
                newContact.ContactStatusId = Mailee.Util.parseInt(xmlContact.ChildNodes[5].InnerText);
                newContact.CreatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[6].InnerText);
                newContact.DeletedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[7].InnerText);
                //contact.DynamicValues = xmlContact.ChildNodes[8].InnerText;
                newContact.Email = xmlContact.ChildNodes[9].InnerText;
                newContact.FacebookFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[10].InnerText);
                newContact.ForwardedBy = Mailee.Util.parseInt(xmlContact.ChildNodes[11].InnerText);
                newContact.GoodreadsConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[12].InnerText);
                newContact.Id = Mailee.Util.parseInt(xmlContact.ChildNodes[13].InnerText);
                newContact.ImportId = Mailee.Util.parseInt(xmlContact.ChildNodes[14].InnerText);
                newContact.InternalId = Mailee.Util.parseInt(xmlContact.ChildNodes[15].InnerText);
                newContact.Kscore = Mailee.Util.parseFloat(xmlContact.ChildNodes[16].InnerText);
                newContact.Latitude = Mailee.Util.parseDecimal(xmlContact.ChildNodes[17].InnerText);
                newContact.LinkedinFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[18].InnerText);
                newContact.LinkedinRecomendations = Mailee.Util.parseInt(xmlContact.ChildNodes[19].InnerText);
                newContact.Longitude = Mailee.Util.parseDecimal(xmlContact.ChildNodes[20].InnerText);
                newContact.Mobile = xmlContact.ChildNodes[21].InnerText;
                newContact.Name = xmlContact.ChildNodes[22].InnerText;
                newContact.Notes = xmlContact.ChildNodes[23].InnerText;
                newContact.OriginId = Mailee.Util.parseInt(xmlContact.ChildNodes[24].InnerText);
                newContact.OrkutFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[25].InnerText);
                newContact.Phone = xmlContact.ChildNodes[26].InnerText;
                newContact.PhotoContentType = xmlContact.ChildNodes[27].InnerText;
                newContact.PhotoFileName = xmlContact.ChildNodes[28].InnerText;
                newContact.PhotoFileSize = Mailee.Util.parseInt(xmlContact.ChildNodes[29].InnerText);
                newContact.PhotoUpdatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[30].InnerText);
                newContact.PlaxoConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[31].InnerText);
                newContact.Position = xmlContact.ChildNodes[32].InnerText;
                newContact.Sex = xmlContact.ChildNodes[33].InnerText;
                newContact.SkoobConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[34].InnerText);
                newContact.TwitterFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[35].InnerText);
                newContact.UpdatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[36].InnerText);

                //Add Contact
                contacts.Add(newContact);
            }

            return contacts;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Find List by ID
        /// </summary>
        /// <param name="id">List ID</param>
        public static Mailee.List findById(int id)
        {
            Mailee.List list = new Mailee.List();

            //Validation
            if (id == 0)
                return list;

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/lists/X.xml)
            string url = string.Format("{0}lists/{1}.xml", Mailee.Config.UrlAPI, id);

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Checks if the xml is valid
            bool isValidXml = Mailee.Util.IsValidXML(htmlReponse);

            if (isValidXml == true)
            {
                //Create XML
                XmlDocument xmlDoc = new XmlDocument();

                //Load XML
                xmlDoc.LoadXml(htmlReponse);

                //Get List
                XmlNodeList xmlLists = xmlDoc.GetElementsByTagName("list");

                if (xmlLists.Count > 0)
                {
                    XmlNode xmlList = xmlLists[0];

                    //Set properties
                    list.Active = Mailee.Util.parseBool(xmlList.ChildNodes[0].InnerText);
                    list.Address = xmlList.ChildNodes[1].InnerText;
                    list.ClientId = Mailee.Util.parseInt(xmlList.ChildNodes[2].InnerText);
                    list.Company = xmlList.ChildNodes[3].InnerText;
                    list.CreatedAt = Mailee.Util.parseDateTime(xmlList.ChildNodes[4].InnerText);
                    list.DeletedAt = Mailee.Util.parseDateTime(xmlList.ChildNodes[5].InnerText);
                    list.Description = xmlList.ChildNodes[6].InnerText;
                    list.Facebook = xmlList.ChildNodes[7].InnerText;
                    list.Id = Mailee.Util.parseInt(xmlList.ChildNodes[8].InnerText);
                    list.ListsContactsCount = Mailee.Util.parseInt(xmlList.ChildNodes[10].InnerText);
                    list.Name = xmlList.ChildNodes[11].InnerText;
                    list.Phone = xmlList.ChildNodes[12].InnerText;
                    list.Site = xmlList.ChildNodes[13].InnerText;
                    list.Total = Mailee.Util.parseInt(xmlList.ChildNodes[14].InnerText);
                    list.Twitter = xmlList.ChildNodes[15].InnerText;

                }

            }

            return list;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Create New Contact
        /// </summary>
        private string Create()
        {
            //URL (POST) (api.XXXXXXXXXXXXX.subdomain.mailee.me/contacts.xml)
            string url = string.Concat(Mailee.Config.UrlAPI, "contacts.xml");

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("contact[email]", this.Email));
            pars.Add(new RestParameter("contact[name]", this.Name));
            pars.Add(new RestParameter("contact[internal_id]", this.InternalId));
            pars.Add(new RestParameter("contact[company]", this.Company));
            pars.Add(new RestParameter("contact[position]", this.Position));
            pars.Add(new RestParameter("contact[sex]", this.Sex));
            pars.Add(new RestParameter("contact[birthday]", string.Format("{0:yyyy-MM-dd}", this.Birthday)));
            pars.Add(new RestParameter("contact[age]", this.Age));
            pars.Add(new RestParameter("contact[phone]", this.Phone));
            pars.Add(new RestParameter("contact[mobile]", this.Mobile));
            pars.Add(new RestParameter("contact[address]", this.Address));
            pars.Add(new RestParameter("contact[notes]", this.Notes));

            foreach (KeyValuePair<string, string> dynamicValue in this.DynamicValues)
                pars.Add(new RestParameter(string.Format("contact[dynamic_attributes][{0}]", dynamicValue.Key), dynamicValue.Value));

            //Post Data
            string result = Mailee.Rest.post(url, pars);

            #region Fill Contact Data

            //Checks if the xml is valid
            bool isValidXml = Mailee.Util.IsValidXML(result);

            if (isValidXml == true)
            {
                //Create XML
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

                //Load XML
                xmlDoc.LoadXml(result);

                //Get Contact
                System.Xml.XmlNodeList xmlContacts = xmlDoc.GetElementsByTagName("contact");

                if (xmlContacts.Count > 0)
                {
                    System.Xml.XmlNode xmlContact = xmlContacts[0];

                    //Set properties
                    this.Id = Mailee.Util.parseInt(xmlContact.ChildNodes[13].InnerText);
                }

            }

            #endregion

            return result;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Unsubscribe to list
        /// </summary>
        /// <param name="listId">List Id</param>
        public string Unsubscribe(int listId)
        {
            //URL (PUT) (api.XXXXXXXXXXXXX.subdomain.mailee.me/contacts/ID/list_unsubscribe.xml)
            string url = string.Format("{0}contacts/{1}/list_unsubscribe.xml", Mailee.Config.UrlAPI, this.Id);

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("list_id", listId));

            //Post Data
            string result = Mailee.Rest.put(url, pars);

            return result;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Makes an HTTP POST
        /// </summary>
        /// <param name="url">URL</param>
        /// <param name="parameters">Parameters</param>
        public static string post(string url, List<RestParameter> parameters)
        {
            string result = null;

            try {

                //We use the HttpUtility class from the System.Web namespace
                Uri address = new Uri(url);

                //Create the web request
                HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;

                //Set type to POST
                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";

                //Build Parameters
                StringBuilder data = new StringBuilder();

                for (int x = 0; x < parameters.Count; x++)
                {
                    if (x != 0)
                        data.Append("&");

                    data.AppendFormat("{0}={1}", HttpUtility.UrlEncode(parameters[x].Name), HttpUtility.UrlEncode(Util.parseString(parameters[x].Value)));
                }

                //Create a byte array of the data we want to send
                byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());

                //Set the content length in the request headers
                request.ContentLength = byteData.Length;

                //Write data
                using (Stream postStream = request.GetRequestStream())
                {
                    postStream.Write(byteData, 0, byteData.Length);
                }

                //Get response
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    //Status
                    int statusCode = (int)response.StatusCode;
                    string statusDescription = Util.parseString(response.StatusDescription);

                    //Get the response stream
                    StreamReader reader = new StreamReader(response.GetResponseStream());

                    //Return data
                    result = reader.ReadToEnd();
                }

            }
            catch (WebException ex)
            {
                //Handle Errors
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    HttpWebResponse response = ex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        //Get StatusCode and StatusDescription
                        int statusCode = (int)response.StatusCode;
                        string statusDescription = Mailee.Util.parseString(response.StatusDescription);

                        //Get the response stream
                        StreamReader reader = new StreamReader(response.GetResponseStream());

                        //Return data
                        string errorMessage = reader.ReadToEnd();

                        //Throw Exception
                        throw new RestExcepction(errorMessage, statusCode, statusDescription);
                    }
                }
            }

            return result;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Makes an HTTP PUT
        /// </summary>
        /// <param name="url">URL</param>
        /// <param name="parameters">Parameters</param>
        public static string put(string url, List<RestParameter> parameters)
        {
            //Add parameter '_method=put'
            parameters.Add(new RestParameter("_method", "put"));

            //Make HTTP Post
            return post(url, parameters);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Update existing List
        /// </summary>
        private string update()
        {
            //URL (PUT) (api.XXXXXXXXXXXXX.subdomain.mailee.me/lists)
            string url = string.Format("{0}lists/{1}.xml", Mailee.Config.UrlAPI, this.Id);

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("list[id]", this.Id));
            pars.Add(new RestParameter("list[name]", this.Name));
            pars.Add(new RestParameter("list[company]", this.Company));
            pars.Add(new RestParameter("list[site]", this.Site));
            pars.Add(new RestParameter("list[facebook]", this.Facebook));
            pars.Add(new RestParameter("list[twitter]", this.Twitter));
            pars.Add(new RestParameter("list[address]", this.Address));
            pars.Add(new RestParameter("list[phone]", this.Phone));
            pars.Add(new RestParameter("list[description]", this.Description));
            pars.Add(new RestParameter("list[active]", this.Active.ToString().ToLower()));

            //Post Data
            string result = Mailee.Rest.put(url, pars);

            return result;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Update existing Contact
        /// </summary>
        private string update()
        {
            //URL (PUT) (api.XXXXXXXXXXXXX.subdomain.mailee.me/contacts.xml)
            string url = string.Format("{0}contacts/{1}.xml", Mailee.Config.UrlAPI, this.Id);

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("contact[id]", this.Id));
            pars.Add(new RestParameter("contact[email]", this.Email));
            pars.Add(new RestParameter("contact[name]", this.Name));
            pars.Add(new RestParameter("contact[internal_id]", this.InternalId));
            pars.Add(new RestParameter("contact[company]", this.Company));
            pars.Add(new RestParameter("contact[position]", this.Position));
            pars.Add(new RestParameter("contact[sex]", this.Sex));
            pars.Add(new RestParameter("contact[birthday]", string.Format("{0:yyyy-MM-dd}", this.Birthday)));
            pars.Add(new RestParameter("contact[age]", this.Age));
            pars.Add(new RestParameter("contact[phone]", this.Phone));
            pars.Add(new RestParameter("contact[mobile]", this.Mobile));
            pars.Add(new RestParameter("contact[address]", this.Address));
            pars.Add(new RestParameter("contact[notes]", this.Notes));

            foreach (KeyValuePair<string, string> dynamicValue in this.DynamicValues)
                pars.Add(new RestParameter(string.Format("contact[dynamic_attributes][{0}]", dynamicValue.Key), dynamicValue.Value));

            //Post Data
            string result = Mailee.Rest.put(url, pars);

            return result;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Update existing Mesage
        /// </summary>
        private string update()
        {
            //URL (PUT) (api.XXXXXXXXXXXXX.subdomain.mailee.me/messages)
            string url = string.Format("{0}messages/{1}.xml", Mailee.Config.UrlAPI, this.Id);

            //Create url params
            List<RestParameter> pars = new List<RestParameter>();

            pars.Add(new RestParameter("message[title]", this.Title));
            pars.Add(new RestParameter("message[subject]", this.Subject));
            pars.Add(new RestParameter("message[from_name]", this.FromName));
            pars.Add(new RestParameter("message[from_email]", this.FromEmail));
            pars.Add(new RestParameter("message[analytics]", this.Analytics.ToString().ToLower()));

            if (this.ReplyEmail != string.Empty)
                pars.Add(new RestParameter("message[reply_email]", this.ReplyEmail));

            if (this.Html != string.Empty)
                pars.Add(new RestParameter("message[html]", this.Html));

            if (this.TemplateId != 0)
            {
                pars.Add(new RestParameter("message[template_id]", this.TemplateId));

                foreach (KeyValuePair<int, string> item in this.Edit)
                    pars.Add(new RestParameter(string.Format("message[edit][{0}]", item.Key), item.Value));

                foreach (KeyValuePair<int, string> item in this.Repeats)
                    pars.Add(new RestParameter(string.Format("message[repeats][{0}]", item.Key), item.Value));
            }

            if (this.Emails != string.Empty)
                pars.Add(new RestParameter("message[emails]", this.Emails));

            if (this.ListId != 0)
            {
                pars.Add(new RestParameter("message[list_id]", this.ListId));

                if (this.SegmentId > 0)
                    pars.Add(new RestParameter("message[segment_id]", this.SegmentId));
            }

            //Post Data
            string result = Mailee.Rest.put(url, pars);

            return result;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Find all Lists
        /// </summary>
        public static List<Mailee.List> findAll()
        {
            List<Mailee.List> lists = new List<Mailee.List>();

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/lists)
            string url = string.Concat(Mailee.Config.UrlAPI, "lists.xml");

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Create XML
            XmlDocument xmlDoc = new XmlDocument();

            //Load XML
            xmlDoc.LoadXml(htmlReponse);

            //Get Lists
            XmlNodeList xmlLists = xmlDoc.GetElementsByTagName("list");

            //Each Lists
            foreach (XmlNode xmlList in xmlLists)
            {
                //Create new List
                Mailee.List newList = new Mailee.List();

                //Set properties
                newList.Active = Mailee.Util.parseBool(xmlList.ChildNodes[0].InnerText);
                newList.Address = xmlList.ChildNodes[1].InnerText;
                newList.ClientId = Mailee.Util.parseInt(xmlList.ChildNodes[2].InnerText);
                newList.Company = xmlList.ChildNodes[3].InnerText;
                newList.CreatedAt = Mailee.Util.parseDateTime(xmlList.ChildNodes[4].InnerText);
                newList.DeletedAt = Mailee.Util.parseDateTime(xmlList.ChildNodes[5].InnerText);
                newList.Description = xmlList.ChildNodes[6].InnerText;
                newList.Facebook = xmlList.ChildNodes[7].InnerText;
                newList.Id = Mailee.Util.parseInt(xmlList.ChildNodes[8].InnerText);
                newList.ListsContactsCount = Mailee.Util.parseInt(xmlList.ChildNodes[10].InnerText);
                newList.Name = xmlList.ChildNodes[11].InnerText;
                newList.Phone = xmlList.ChildNodes[12].InnerText;
                newList.Site = xmlList.ChildNodes[13].InnerText;
                newList.Total = Mailee.Util.parseInt(xmlList.ChildNodes[14].InnerText);
                newList.Twitter = xmlList.ChildNodes[15].InnerText;

                //Add List
                lists.Add(newList);
            }

            return lists;
        }