USAGE - Warafux/personalNotesApiConnectorCSharp GitHub Wiki
How to use PersonalNotesApiConnectorCSHarp
Every public method has some arguments and always a callback function which takes 2 arguments, a bool (indicating the result of the query) and a string (which is an unparsed JSON response).
Methods
getStatus(Action<bool, string> callback)
This function will ask to the api the status of the client (with its token, empty string by default). When the response is ready, the callback function will be called.
createUser(string username, string password, string email, Action<bool, string> callback)
Creates a new user. Username must be unique, aswell as the email. Password must pass some security policies. If the password doesn't meet the required parameters, the return message will say what is needed in order to continue.
attemptLogin(string username, string password, Action<bool, string> callback)
This fucntion will perform a login attempt with the indicated username and password. When the query response is ready, the callback function will be called.
Important: If the login is correct, the api will return a TOKEN, which must be saved with the setter setToken() in order to perform more actions.
setToken(string token)
This will save the introduced token into the class so it will be automatically introduced with future queries.
getNotes(Action<bool, string> callback)
This query will ask for all the notes created by the user that requested the token. That implies that a token must be present when using this query.
newNote(string newTitle, string newText, Action<bool, string> callback)
Given a title and a text, the api will create a note. The owner will be the same as the user that requested the token.
editNote(string noteId, string newTitle, string newText, Action<bool, string> callback)
Given a id of the note (note.getId()), a new title and a new text, the api will edit the referenced note to the new content. The user can only edit those notes that belongs to him.
deleteNote(string noteId, Action<bool, string> callback)
Given a id of a note, this will be deleted. Only if exists and the note belongs to the token owner.