public static void SendRequest(string endpoint, HTTPMethods method, ApiContainer responseContainer = null, Dictionary <string, object> requestParams = null, bool authenticationRequired = true, bool disableCache = false, float cacheLifetime = 3600f, int retryCount = 2, CredentialsBundle credentials = null) { if (Logger.DebugLevelIsEnabled(DebugLevel.API)) { Logger.LogFormat(DebugLevel.API, "Requesting {0} {1} {2} disableCache: {3} retryCount: {4}", method, endpoint, (requestParams == null) ? "{{}}" : Json.Encode(requestParams).Replace("{", "{{").Replace("}", "}}"), disableCache.ToString(), retryCount.ToString()); } UpdateDelegator.Dispatch(delegate { SendRequestInternal(endpoint, method, responseContainer, requestParams, authenticationRequired, disableCache, cacheLifetime, retryCount, credentials); }); }
public unsafe static T Fetch <T>(string id, Action <ApiContainer> onSuccess = null, Action <ApiContainer> onFailure = null, bool disableCache = false) where T : ApiModel, ApiCacheObject, new() { id = id?.Trim(); T val = new T(); val.id = id; T model = (T)val; if (!disableCache && ApiCache.Fetch(id, ref *(T *)(&model))) { if (onSuccess != null) { UpdateDelegator.Dispatch(delegate { onSuccess(new ApiModelContainer <T>((T)model)); }); } return((T)model); } model.Fetch(onSuccess, onFailure, null, disableCache); return((T)model); }