public void MakeApiCall(string apiEndPoint, object args, HttpRequestContainer.ActionSuccessHandler successCallback, HttpRequestContainer.ActionErrorHandler errorCallback, Dictionary <string, string> extraHeaders = null, string method = HttpRequestContainerType.POST, bool allowQueueing = false, bool toJson = true) { HttpRequestContainer request = new HttpRequestContainer() { apiEndPoint = apiEndPoint, Payload = Encoding.UTF8.GetBytes(JsonUtility.ToJson(args)), urlCall = _apiSettings.MakeApiUrl(apiEndPoint), CallbackError = errorCallback, CallbackSuccess = successCallback, Headers = extraHeaders ?? new Dictionary <string, string>(), RequestTimeout = _apiSettings.RequestTimeout, RequestKeepAlive = _apiSettings.RequestKeepAlive, Method = method }; if (allowQueueing && _apiCallQueue != null) { for (var i = _apiCallQueue.Count - 1; i >= 0; i--) { if (_apiCallQueue[i].apiEndPoint == apiEndPoint) { _apiCallQueue.RemoveAt(i); } } _apiCallQueue.Add(request); } else { _internalRequestApi.MakeApiCall(request); } }
// call the api private void MakeApiCall(string apiEndPoint, HttpRequestArgs args, HttpRequestContainer.ActionSuccessHandler successCallback, HttpRequestContainer.ActionErrorHandler errorCallback, bool allowQueueing = false, string requestType = HttpRequestContainerType.POST) { if (m_internalHttpApi != null) { Dictionary <string, string> extraHeaders = new Dictionary <string, string>(); args = args ?? new HttpRequestArgs(); // steam app id args.data.Add("appId", "480"); m_internalHttpApi.MakeApiCall(apiEndPoint, args, successCallback, errorCallback, extraHeaders, requestType, allowQueueing); } }