Exemple #1
0
        /// <summary>
        /// Create the SubscriberImportJob using the WEB API subscriber_imports.
        /// </summary>
        /// <param name="subscriberImportJob"></param>
        /// <returns>A XML string of a Poppulo Status Entity</returns>
        public async Task <string> CreateSubscriberImportJobAsync(string subscriberImportJob)
        {
            string MyReturn = string.Empty;

            // Documentation: https://developer.poppulo.com/api-calls/api-create-subscriber-import-job.html

            string MyURL = BaseURL + string.Format(@"{0}/subscriber_imports", AccountCode);

            // load the subscriberImportJob to a xml
            if (!PoppuloAPIClient.IsXML(subscriberImportJob))
            {
                throw new Exception("XML for CreateSubscriberImportJobAsync is not a XML document Please review.");
            }

            using (HttpResponseMessage r = await HTTPClientSendAsync(url: MyURL, method: HttpMethod.Post, bodyData: subscriberImportJob, bodyDataEncoding: PoppuloBodyDataEncoding, bodyDataMediaType: PoppuloBodyDataMediaType))
            {
                using (HttpContent c = r.Content)
                {
                    MyReturn = await c.ReadAsStringAsync();
                }
            }

            // Update the SubscriberImportLink
            SubscriberImportLink = string.Empty;

            // load the returned xml
            XmlDocument XmlSubscriberImport = new XmlDocument();

            XmlSubscriberImport.LoadXml(MyReturn);

            // Get the SubscriberImportLink
            SubscriberImportLink = XmlSubscriberImport.SelectSingleNode("/status/resources_created/link/@href").Value;

            return(MyReturn);
        }
Exemple #2
0
        /// <summary>
        /// Create Subscriber Tag
        /// </summary>
        /// <param name="subscriberEmailAddress"></param>
        /// <param name="tagName"></param>
        /// <returns></returns>
        public async Task <string> CreateSubscriberTagAsync(string subscriberEmailAddress, string tagName)
        {
            // Documentation: https://developer.poppulo.com/api-calls/api-create-subscriber-tag.html

            string MyURL = BaseURL + AccountCode + @"/subscriber/" + subscriberEmailAddress + @"/tags";

            StringBuilder MyTag = new StringBuilder(PoppuloAPIClient.XML_Subscriber_Tag_Template);

            MyTag.Replace("{AccountCode}", AccountCode);
            MyTag.Replace("{tagName}", Uri.EscapeDataString(tagName));

            if (!PoppuloAPIClient.IsXML(MyTag.ToString()))
            {
                throw new Exception("XML for CreateSubscriberTagAsync is not a XML document Please review.");
            }

            using (HttpResponseMessage r = await HTTPClientSendAsync(url: MyURL, method: HttpMethod.Post, bodyData: MyTag.ToString(), bodyDataEncoding: PoppuloBodyDataEncoding, bodyDataMediaType: PoppuloBodyDataMediaType))
            {
                using (HttpContent c = r.Content)
                {
                    return(await c.ReadAsStringAsync());
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Update Tag
        /// </summary>
        /// <param name="tagName">Existing tag</param>
        /// <param name="newTagName">New tag name</param>
        /// <param name="newTagDescription">New tag description</param>
        /// <returns></returns>
        public async Task <string> UpdateTagAsync(string tagName, string newTagName, string newTagDescription)
        {
            // Documentation : https://developer.poppulo.com/api-calls/api-update-tag.html

            string MyURL = BaseURL + AccountCode + @"/tag/" + tagName;

            StringBuilder MyTag = new StringBuilder(PoppuloAPIClient.XML_Tag_Template);

            MyTag.Replace("{Name}", newTagName);
            MyTag.Replace("{Description}", newTagDescription);

            if (!PoppuloAPIClient.IsXML(MyTag.ToString()))
            {
                throw new Exception("XML for UpdateTagAsync is not a XML document Please review.");
            }

            using (HttpResponseMessage r = await HTTPClientSendAsync(url: MyURL, method: HttpMethod.Put, bodyData: MyTag.ToString(), bodyDataEncoding: PoppuloBodyDataEncoding, bodyDataMediaType: PoppuloBodyDataMediaType))
            {
                using (HttpContent c = r.Content)
                {
                    return(await c.ReadAsStringAsync());
                }
            }
        }