/// <summary> /// Makes the data request to the API for a single item /// </summary> /// <param name="requestEnum">Enum data type that tells what kind of request is needed</param> /// <param name="id">Id for the specific item that is required</param> /// <returns>JSON string for the single item</returns> internal static T LoadData <T>(GetCalls requestEnum, int?id = null) { string requestString = id.HasValue ? GetDataRequests.RetrieveGetStringRequest(requestEnum, (int)id) : GetDataRequests.RetrieveGetStringRequest(requestEnum); string jsonData = LoadGetRequest(requestString); return(FromJson <T>(jsonData)); }
public void ClearStatistics() { GetCalls.Clear(); GetMultipleCalls.Clear(); PutMultipleCalls.Clear(); PutCalls.Clear(); UnlockMultipleCalls.Clear(); LockMultipleCalls.Clear(); }
/// <summary></summary> public Task <object> GetAsync(object key, CancellationToken cancellationToken) { try { GetCalls.Add(key); return(Task.FromResult <object>(_hashtable[key])); } catch (Exception ex) { return(Task.FromException <object>(ex)); } }
/// <summary> /// Creates the GET request string that is then consumed by the windows form. /// </summary> /// <param name="requestEnum">Enum value passed in to identify the request that is needed</param> /// <returns>String containing the URL for a GET request</returns> internal static string RetrieveGetStringRequest(GetCalls requestEnum) { string getString = ""; switch (requestEnum) { case GetCalls.ListOfOrgs: getString = "http://api.uoltt.org/api/v4/organizations"; break; case GetCalls.ListOfShips: getString = "http://api.uoltt.org/api/v4/ships"; break; case GetCalls.ListOfUsers: getString = "http://api.uoltt.org/api/v4/users"; break; } return(getString); }
/// <summary> /// Overload of <see cref="RetrieveGetStringRequest(GetCalls)"/> that takes an Id to call invididual items /// rather than a full list of items /// </summary> /// <param name="requestEnum">Enum value passed in to identify the request that is needed</param> /// <param name="id">ID value of the item that is requested from the Enum request</param> /// <returns>String containing the URL for a GET request</returns> internal static string RetrieveGetStringRequest(GetCalls requestEnum, int id) { string getString = ""; switch (requestEnum) { case GetCalls.IndividualOrg: getString = "http://api.uoltt.org/api/v4/organizations/" + id; break; case GetCalls.IndividualShip: getString = "http://api.uoltt.org/api/v4/ships/" + id; break; case GetCalls.IndividualUser: getString = "http://api.uoltt.org/api/v4/users/" + id; break; } return(getString); }
/// <summary></summary> public object Get(object key) { GetCalls.Add(key); return(_hashtable[key]); }