/// <summary> /// Retrieves the user's current session based on the token. /// </summary> /// <param name="token">The user's current token.</param> /// <returns>Returns the token or returns null if not valid.</returns> internal dynamic Autherisation(string token) { // Define the paramater object and fill in the token. dynamic parameterObject = new ExpandoObject(); parameterObject.tokenId = token; // Send the API request. RestClient restClient = new RestClient("authenticate/token", HttpVerb.GET); HttpJsonResponse responseObject = restClient.SendRequest(parameterObject); // Return the API response. return(responseObject.ResponseCode == HttpStatusCode.OK ? responseObject.ResponseBody : null); }
/// <summary> /// Retrieves user authentication based on the given credentials. /// </summary> /// <param name="login">The email or username of the account to login to.</param> /// <param name="password">The user pass.</param> /// <returns>Returns the token or returns null if not valid.</returns> internal dynamic Autherisation(string login, string password) { // Define the paramater object and fill in the login and password data. dynamic parameterObject = new ExpandoObject(); if (IsValidEmail(login)) { parameterObject.email = login; } else { parameterObject.username = login; } parameterObject.password = password; // Send the API request. RestClient restClient = new RestClient("authenticate", HttpVerb.POST); HttpJsonResponse responseObject = restClient.SendRequest(parameterObject); // Return the API response. return(responseObject.ResponseCode == HttpStatusCode.OK ? responseObject.ResponseBody : null); }