Esempio n. 1
0
        private List <object> loadObjects(PardotAPI.request request)
        {
            List <object> objects = new List <object>();

            if (request.response.isValid())
            {
                XmlNode data = request.response.xml.SelectSingleNode("/rsp/result");
                if (data == null)
                {
                    data = request.response.xml.SelectSingleNode("/rsp");
                }

                if (data != null && data.ChildNodes.Count > 0)
                {
                    foreach (XmlNode x in data.ChildNodes)
                    {
                        if (x.Name != "total_results")
                        {
                            objects.Add(loadObject(x));
                        }
                    }
                }
            }
            return(objects);
        }
Esempio n. 2
0
        public PardotAPI.request read(string thisIdentifierField, string thisIdentifier, Dictionary <string, string> parameters)
        {
            string url = string.Format(baseUrl + identifierUrl, interfaceName, "read", thisIdentifierField, thisIdentifier);

            PardotAPI.request request = new PardotAPI.request(url, getMessage(parameters), interfaceName);
            request.response.data = loadObjects(request);
            return(request);
        }
Esempio n. 3
0
        public PardotAPI.request query(string thisIdentifierField, string thisIdentifier, Dictionary <string, string> parameters)
        {
            string url = "";

            if (thisIdentifierField.notFilled() && thisIdentifier.notFilled())
            {
                url = string.Format(baseUrl, interfaceName, "query");
            }
            else
            {
                url = string.Format(baseUrl + identifierUrl, interfaceName, "query", thisIdentifierField, thisIdentifier);
            }
            PardotAPI.request request = new PardotAPI.request(url, getMessage(parameters), interfaceName);
            request.response.data = loadObjects(request);
            return(request);
        }
Esempio n. 4
0
        // ---------------------------------------------------
        // ------------ private & public methods -------------
        // ---------------------------------------------------

        private void create()
        {
            // create post data string
            string message = string.Format("email={0}&password={1}&user_key={2}", _email, _password, _user_key);

            PardotAPI.request request = new PardotAPI.request(_url, message, "authentication");

            // validate this was successful
            if (request.response.isValid())
            {
                // get the api_key from the response
                XmlNode key = request.response.xml.SelectSingleNode("/rsp/api_key");

                // set the hash and timestamp
                _hash      = key.InnerText;
                _timestamp = DateTime.Now;

                _status = "Token created successfully.";
            }
            else
            {
                _status = "Authentication failed. Response from server: " + request.response.message;
            }
        }