Esempio n. 1
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Runs the Rtm.test.echo method and returned an array of <see cref="XmlElement"/> items.
        /// </summary>
        /// <param name="echoParameter">The parameter to pass to the method.</param>
        /// <param name="echoValue">The value to pass to the method with the parameter.</param>
        /// <returns>An array of <see cref="XmlElement"/> items.</returns>
        /// <remarks>
        /// The APi Key has been removed from the returned array and will not be shown.
        /// </remarks>
        /// <example>
        /// <code>
        /// XmlElement[] elements = Rtm.TestEcho("&amp;param=value");
        /// foreach(XmlElement element in elements)
        /// {
        ///		if( element.Name = "method" )
        ///			Console.WriteLine("Method = " + element.InnerXml);
        ///		if( element.Name = "param" )
        ///			Console.WriteLine("Param = " + element.InnerXml);
        /// }
        /// </code>
        /// </example>
        public XmlElement[] TestEcho(string echoParameter, string echoValue)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "Rtm.test.echo");
            parameters.Add("api_key", apiKey);
            if (echoParameter != null && echoParameter.Length > 0)
            {
                parameters.Add(echoParameter, echoValue);
            }

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                // Remove the api_key element from the array.
                XmlElement[] elements = new XmlElement[response.AllElements.Length - 1];
                int          c        = 0;
                foreach (XmlElement element in response.AllElements)
                {
                    if (element.Name != "api_key")
                    {
                        elements[c++] = element;
                    }
                }
                return(elements);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 2
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Sets the priority on a task
        /// </summary>
        /// <param name="listID">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="taskSeriesID">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="taskID">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="priority">
        /// A <see cref="System.String"/>
        /// </param>
        public List TasksSetPriority(string timeline, string listID, string taskSeriesID, string taskID, string priority)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.setPriority");
            parameters.Add("timeline", timeline);
            parameters.Add("list_id", listID);
            parameters.Add("taskseries_id", taskSeriesID);
            parameters.Add("task_id", taskID);
            if (priority.CompareTo("N") != 0)
            {
                parameters.Add("priority", priority);
            }

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.List);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 3
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Deletes a note
        /// </summary>
        /// <param name="timeline">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="noteID">
        /// A <see cref="System.String"/>
        /// </param>
        public void NotesDelete(string timeline, string noteID)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.notes.delete");
            parameters.Add("timeline", timeline);
            parameters.Add("note_id", noteID);

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status != ResponseStatus.OK)
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 4
0
File: Rtm.cs Progetto: nolith/tasque
        public string TimelineCreate()
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.timelines.create");
            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.Timeline);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 5
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Retrieve a temporary FROB from the Rtm service, to be used in redirecting the
        /// user to the Rtm web site for authentication. Only required for desktop authentication.
        /// </summary>
        /// <remarks>
        /// Pass the FROB to the <see cref="AuthCalcUrl"/> method to calculate the url.
        /// </remarks>
        /// <example>
        /// <code>
        /// string frob = Rtm.AuthGetFrob();
        /// string url = Rtm.AuthCalcUrl(frob, AuthLevel.Read);
        ///
        /// // redirect the user to the url above and then wait till they have authenticated and return to the app.
        ///
        /// Auth auth = Rtm.AuthGetToken(frob);
        ///
        /// // then store the auth.Token for later use.
        /// string token = auth.Token;
        /// </code>
        /// </example>
        /// <returns>The FROB.</returns>
        public string AuthGetFrob()
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.auth.getFrob");

            RtmNet.Response response = GetResponse(parameters);
            if (response.Status == ResponseStatus.OK)
            {
                return(response.AllElements[0].InnerText);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 6
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Gets a list of contacts for the logged in user.
        /// Requires authentication.
        /// </summary>
        /// <returns>An instance of the <see cref="Contacts"/> class containing the list of contacts.</returns>
        public Lists ListsGetList()
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.lists.getList");
            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.Lists);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 7
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Gets a list of the given users contact, or those that are publically avaiable.
        /// </summary>
        /// <param name="userId">The Id of the user who's contacts you want to return.</param>
        /// <returns>An instance of the <see cref="Contacts"/> class containing the list of contacts.</returns>
        public Contacts ContactsGetPublicList(string userId)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.contacts.getPublicList");
            parameters.Add("user_id", userId);
            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.Contacts);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 8
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Test the logged in state of the current Filckr object.
        /// </summary>
        /// <returns>The <see cref="FoundUser"/> object containing the username and userid of the current user.</returns>
        public FoundUser TestLogin()
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "Rtm.test.login");

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(new FoundUser(response.AllElements[0]));
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 9
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Checks a authentication token with the Rtm service to make
        /// sure it is still valid.
        /// </summary>
        /// <param name="token">The authentication token to check.</param>
        /// <returns>The <see cref="Auth"/> object detailing the user for the token.</returns>
        public Auth AuthCheckToken(string token)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.auth.checkToken");
            parameters.Add("auth_token", token);

            RtmNet.Response response = GetResponse(parameters);
            if (response.Status == ResponseStatus.OK)
            {
                Auth auth = new Auth(response.AllElements[0]);
                return(auth);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 10
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Gets the full token details for a given mini token, entered by the user following a
        /// web based authentication.
        /// </summary>
        /// <param name="miniToken">The mini token.</param>
        /// <returns>An instance <see cref="Auth"/> class, detailing the user and their full token.</returns>
        public Auth AuthGetFullToken(string miniToken)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.auth.getFullToken");
            parameters.Add("mini_token", miniToken.Replace("-", ""));
            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                Auth auth = new Auth(response.AllElements[0]);
                return(auth);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Converts the response string (in XML) into the <see cref="Response"/> object.
        /// </summary>
        /// <param name="responseString">The response from Rtm.</param>
        /// <returns>A <see cref="Response"/> object containing the details of the </returns>
        internal static Response Deserialize(string responseString)
        {
            XmlSerializer serializer = GetSerializer(typeof(RtmNet.Response));

            try {
                // Deserialise the web response into the Rtm response object
                StringReader    responseReader = new StringReader(responseString);
                RtmNet.Response response       = (RtmNet.Response)serializer.Deserialize(responseReader);
                responseReader.Close();
                return(response);
            } catch (InvalidOperationException ex) {
                // Serialization error occurred!
                throw new ResponseXmlException("Invalid response received from Rtm.", ex);
            } catch (System.Xml.XmlException ex) {
                // Serialization error occurred!
                throw new ResponseXmlException("Fail to deserialize response stream.", ex);
            }
        }
Esempio n. 12
0
File: Rtm.cs Progetto: nolith/tasque
        public List TasksAdd(string timeline, string name)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.add");
            parameters.Add("timeline", timeline);
            parameters.Add("name", name);

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.List);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 13
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Add a selection of tags to a photo.
        /// </summary>
        /// <param name="photoId">The photo id of the photo.</param>
        /// <param name="tags">An string of comma delimited tags.</param>
        /// <returns>True if the tags are added successfully.</returns>
        public void TasksAddTags(string photoId, string tags)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.addTags");
            parameters.Add("photo_id", photoId);
            parameters.Add("tags", tags);

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return;
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 14
0
File: Rtm.cs Progetto: nolith/tasque
        public List TasksDelete(string timeline, string listID, string taskSeriesID, string taskID)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.delete");
            parameters.Add("timeline", timeline);
            parameters.Add("list_id", listID);
            parameters.Add("taskseries_id", taskSeriesID);
            parameters.Add("task_id", taskID);

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.List);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 15
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Modifies an existing note
        /// </summary>
        /// <param name="timeline">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="noteID">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="noteTitle">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="noteText">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="Note"/>
        /// </returns>
        public Note NotesEdit(string timeline, string noteID, string noteTitle, string noteText)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.notes.edit");
            parameters.Add("timeline", timeline);
            parameters.Add("note_id", noteID);
            parameters.Add("note_title", noteTitle);
            parameters.Add("note_text", noteText);

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.Note);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 16
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Gets a list of contacts for the logged in user.
        /// Requires authentication.
        /// </summary>
        /// <returns>An instance of the <see cref="Contacts"/> class containing the list of contacts.</returns>
        public Tasks TasksGetList(string listID)
        {
            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.tasks.getList");
            if (listID != null)
            {
                parameters.Add("list_id", listID);
            }

            RtmNet.Response response = GetResponse(parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.Tasks);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 17
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// After the user has authenticated your application on the Rtm web site call this
        /// method with the FROB (either stored from <see cref="AuthGetFrob"/> or returned in the URL
        /// from the Rtm web site) to get the users token.
        /// </summary>
        /// <param name="frob">The string containing the FROB.</param>
        /// <returns>A <see cref="Auth"/> object containing user and token details.</returns>
        public Auth AuthGetToken(string frob)
        {
            if (sharedSecret == null)
            {
                throw new SignatureRequiredException();
            }

            Hashtable parameters = new Hashtable();

            parameters.Add("method", "rtm.auth.getToken");
            parameters.Add("frob", frob);

            RtmNet.Response response = GetResponse(parameters);
            if (response.Status == ResponseStatus.OK)
            {
                Auth auth = new Auth(response.AllElements[0]);
                return(auth);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }
Esempio n. 18
0
File: Rtm.cs Progetto: nolith/tasque
        /// <summary>
        /// Can be used to call unsupported methods in the Rtm API.
        /// </summary>
        /// <remarks>
        /// Use of this method is not supported.
        /// The way the RtmNet API Library works may mean that some methods do not return an expected result
        /// when using this method.
        /// </remarks>
        /// <param name="method">The method name, e.g. "Rtm.test.null".</param>
        /// <param name="parameters">A list of parameters. Note, api_key is added by default and is not included. Can be null.</param>
        /// <returns>An array of <see cref="XmlElement"/> instances which is the expected response.</returns>
        public XmlElement[] TestGeneric(string method, NameValueCollection parameters)
        {
            Hashtable _parameters = new Hashtable();

            if (parameters != null)
            {
                foreach (string key in parameters.AllKeys)
                {
                    _parameters.Add(key, parameters[key]);
                }
            }
            _parameters.Add("method", method);

            RtmNet.Response response = GetResponse(_parameters);

            if (response.Status == ResponseStatus.OK)
            {
                return(response.AllElements);
            }
            else
            {
                throw new RtmApiException(response.Error);
            }
        }