Beispiel #1
0
        /// <summary>
        /// GetCurrentUser
        /// </summary>
        /// <param name="consumerKey">OAuth consumerKey.</param>
        /// <param name="consumerSecret">OAuth consumerSecret.</param>
        /// <param name="accessToken">OAuth accessToken.</param>
        /// <param name="accessTokenSecret">OAuth accessTokenSecret.</param>
        /// <returns>Dictionary</returns>
        public static User GetCurrentUser(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            PlatformClient client   = new PlatformClient(PlatformConfig.GetCurrentUserUrl());
            string         response = client.GetResponse(consumerKey, consumerSecret, accessToken, accessTokenSecret);

            XmlDocument         xmldoc = CoreHelper.ParseResponseIntoXml(response);
            XmlNamespaceManager nsmgr  = new XmlNamespaceManager(xmldoc.NameTable);

            nsmgr.AddNamespace("api", "http://platform.intuit.com/api/v1");

            XmlNode node = xmldoc.SelectSingleNode("//api:UserResponse", nsmgr);

            if (node == null)
            {
                throw GetPlatformException(xmldoc, nsmgr);
            }
            else
            {
                User user = new User();
                user.FirstName    = node.SelectSingleNode("//api:FirstName", nsmgr).InnerText;
                user.LastName     = node.SelectSingleNode("//api:LastName", nsmgr).InnerText;
                user.EmailAddress = node.SelectSingleNode("//api:EmailAddress", nsmgr).InnerText;
                user.IsVerified   = node.SelectSingleNode("//api:IsVerified", nsmgr).InnerText.Equals("true") ? true : false;
                return(user);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Disconnect a user from QBO.
        /// </summary>

        /// <param name="consumerKey">OAuth consumerKey.</param>
        /// <param name="consumerSecret">OAuth consumerSecret.</param>
        /// <param name="accessToken">OAuth accessToken.</param>
        /// <param name="accessTokenSecret">OAuth accessTokenSecret.</param>
        /// <returns>void.</returns>
        public static void Disconnect(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            PlatformClient client   = new PlatformClient(PlatformConfig.GetDisconnectUrl());
            string         response = client.GetResponse(consumerKey, consumerSecret, accessToken, accessTokenSecret);

            ParseDisconnectResponse(response);
        }
Beispiel #3
0
        /// <summary>
        /// Reconnect
        /// </summary>
        /// <param name="xmldoc">xmldoc</param>
        /// <param name="nsmgr">nameSpaceManager</param>
        /// <returns>Dictionary</returns>
        public static Dictionary <string, string> Reconnect(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
        {
            PlatformClient client   = new PlatformClient(PlatformConfig.GetReconnectUrl());
            string         response = client.GetResponse(consumerKey, consumerSecret, accessToken, accessTokenSecret);

            XmlDocument         xmldoc = CoreHelper.ParseResponseIntoXml(response);
            XmlNamespaceManager nsmgr  = new XmlNamespaceManager(xmldoc.NameTable);

            nsmgr.AddNamespace("api", "http://platform.intuit.com/api/v1");

            XmlNode node = xmldoc.SelectSingleNode("//api:ErrorCode", nsmgr);

            if (node != null && (!node.InnerText.Equals("0")))
            {
                throw GetPlatformException(xmldoc, nsmgr);
            }
            else
            {
                Dictionary <string, string> oauthTokens = new Dictionary <string, string>();

                oauthTokens.Add("OAuthToken", xmldoc.SelectSingleNode("//api:OAuthToken", nsmgr).InnerText);
                oauthTokens.Add("OAuthTokenSecret", xmldoc.SelectSingleNode("//api:OAuthTokenSecret", nsmgr).InnerText);
                return(oauthTokens);
            }
        }