public LootLockerServerRequest(string endpoint, LootLockerHTTPMethod httpMethod = LootLockerHTTPMethod.GET, byte[] upload = null, string uploadName = null, string uploadType = null, Dictionary <string, string> body = null, Dictionary <string, string> extraHeaders = null, bool useAuthToken = true, LootLocker.LootLockerEnums.LootLockerCallerRole callerRole = LootLocker.LootLockerEnums.LootLockerCallerRole.User, bool isFileUpload = true)
        {
            this.retryCount   = 0;
            this.endpoint     = endpoint;
            this.httpMethod   = httpMethod;
            this.payload      = null;
            this.upload       = upload;
            this.uploadName   = uploadName;
            this.uploadType   = uploadType;
            this.jsonPayload  = null;
            this.extraHeaders = extraHeaders != null && extraHeaders.Count == 0 ? null : extraHeaders; // Force extra headers to null if empty dictionary was supplied
            this.queryParams  = null;
            this.adminCall    = callerRole;
            this.form         = new WWWForm();

            foreach (var kvp in body)
            {
                this.form.AddField(kvp.Key, kvp.Value);
            }

            this.form.AddBinaryData("file", upload, uploadName);

            bool isNonPayloadMethod = (this.httpMethod == LootLockerHTTPMethod.GET || this.httpMethod == LootLockerHTTPMethod.HEAD || this.httpMethod == LootLockerHTTPMethod.OPTIONS);

            if (this.payload != null && isNonPayloadMethod)
            {
                LootLockerSDKManager.DebugMessage("WARNING: Payloads should not be sent in GET, HEAD, OPTIONS, requests. Attempted to send a payload to: " + this.httpMethod.ToString() + " " + this.endpoint);
            }
        }
Example #2
0
        public static void GettingASingleEvent(LootLockerGetRequest data, Action <LootLockerSingleEventResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.gettingASingleEvent;

            string getVariable = string.Format(endPoint.endPoint, data.getRequests[0]);

            LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
            {
                LootLockerSingleEventResponse response = new LootLockerSingleEventResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response      = JsonConvert.DeserializeObject <LootLockerSingleEventResponse>(serverResponse.text);
                    response.text = serverResponse.text;
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.text    = serverResponse.text;
                    response.success = serverResponse.success;
                    response.Error   = serverResponse.Error; response.statusCode = serverResponse.statusCode;
                    onComplete?.Invoke(response);
                }
            }, true);
        }
Example #3
0
        public static void UpdatingAnAssetCandidate(LootLockerCreatingOrUpdatingAnAssetCandidateRequest data, LootLockerGetRequest getRequests, Action <LootLockerUserGenerateContentResponse> onComplete)
        {
            EndPointClass requestEndPoint = LootLockerEndPoints.current.updatingAnAssetCandidate;
            string        json            = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }

            string endPoint = string.Format(requestEndPoint.endPoint, getRequests.getRequests[0]);

            LootLockerServerRequest.CallAPI(endPoint, requestEndPoint.httpMethod, json, (serverResponse) =>
            {
                LootLockerUserGenerateContentResponse response = new LootLockerUserGenerateContentResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerUserGenerateContentResponse>(serverResponse.text);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, true, LootLocker.LootLockerEnums.LootLockerCallerRole.User);
        }
Example #4
0
        public static void OpenALootBox(LootLockerGetRequest data, Action <LootLockerOpenLootBoxResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.current.deleteKeyValuePair;

            string getVariable = string.Format(endPoint.endPoint, data.getRequests[0]);

            LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
            {
                LootLockerOpenLootBoxResponse response = new LootLockerOpenLootBoxResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response      = JsonConvert.DeserializeObject <LootLockerOpenLootBoxResponse>(serverResponse.text);
                    response.text = serverResponse.text;
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.text    = serverResponse.text;
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, true);
        }
        public static void Verify(LootLockerVerifyRequest data, Action <LootLockerVerifyResponse> onComplete)
        {
            string json = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }

            EndPointClass endPoint = LootLockerEndPoints.current.playerVerification;

            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
            {
                LootLockerVerifyResponse response = new LootLockerVerifyResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerVerifyResponse>(serverResponse.text);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, false);
        }
Example #6
0
        public static void CallDomainAuthAPI(string endPoint, LootLockerHTTPMethod httpMethod, string body = null, Action <LootLockerResponse> onComplete = null)
        {
            if (LootLockerConfig.current.domainKey.ToString().Length == 0)
            {
                #if UNITY_EDITOR
                LootLockerSDKManager.DebugMessage("LootLocker domain key must be set in settings", true);
                #endif
                onComplete?.Invoke(LootLockerResponseFactory.Error <LootLockerResponse>("LootLocker domain key must be set in settings"));

                return;
            }

            Dictionary <string, string> headers = new Dictionary <string, string>();
            headers.Add("domain-key", LootLockerConfig.current.domainKey);

            if (LootLockerConfig.current.developmentMode)
            {
                headers.Add("is-development", "true");
            }

            LootLockerBaseServerAPI.I.SwitchURL(LootLockerCallerRole.Base);

            new LootLockerServerRequest(endPoint, httpMethod, body, headers, callerRole: LootLockerCallerRole.Base).Send((response) =>
            {
                onComplete?.Invoke(response);
            });
        }
Example #7
0
        public static void UpdateKeyValuePairById(LootLockerGetRequest lootLockerGetRequest, LootLockerCreateKeyValuePairRequest data, Action <LootLockerAssetDefaultResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.current.updateKeyValuePairById;
            string        json     = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }

            string getVariable = string.Format(endPoint.endPoint, lootLockerGetRequest.getRequests[0], lootLockerGetRequest.getRequests[1]);

            LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, json, onComplete: (serverResponse) =>
            {
                LootLockerAssetDefaultResponse response = new LootLockerAssetDefaultResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response      = JsonConvert.DeserializeObject <LootLockerAssetDefaultResponse>(serverResponse.text);
                    response.text = serverResponse.text;
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.text    = serverResponse.text;
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, true);
        }
Example #8
0
        public static void CallAPI(string endPoint, LootLockerHTTPMethod httpMethod, string body = null, Action <LootLockerResponse> onComplete = null, bool useAuthToken = true, LootLocker.LootLockerEnums.LootLockerCallerRole callerRole = LootLocker.LootLockerEnums.LootLockerCallerRole.User)
        {
#if UNITY_EDITOR
            LootLockerSDKManager.DebugMessage("Caller Type: " + callerRole.ToString());
#endif

            Dictionary <string, string> headers = new Dictionary <string, string>();

            if (useAuthToken)
            {
                headers = new Dictionary <string, string>();
                headers.Add(callerRole == LootLocker.LootLockerEnums.LootLockerCallerRole.Admin ? "x-auth-token" : "x-session-token", callerRole == LootLocker.LootLockerEnums.LootLockerCallerRole.Admin ? LootLockerConfig.current.adminToken : LootLockerConfig.current.token);
            }

            if (LootLockerConfig.current != null)
            {
                headers.Add(LootLockerConfig.current.dateVersion.key, LootLockerConfig.current.dateVersion.value);
            }

            LootLockerBaseServerAPI.I.SwitchURL(callerRole);

            new LootLockerServerRequest(endPoint, httpMethod, body, headers, callerRole: callerRole).Send((response) =>
            {
                onComplete?.Invoke(response);
            });
        }
Example #9
0
        public static void GettingAllEvents(Action <LootLockerEventResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.current.gettingAllEvents;

            string getVariable = endPoint.endPoint;

            LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
            {
                LootLockerEventResponse response = new LootLockerEventResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response      = JsonConvert.DeserializeObject <LootLockerEventResponse>(serverResponse.text);
                    response.text = serverResponse.text;
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    response.text    = serverResponse.text;
                    onComplete?.Invoke(response);
                }
            }, true);
        }
Example #10
0
        public static void GetAssetsById(LootLockerGetRequest data, Action <LootLockerAssetResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.current.getAssetsById;

            string builtAssets = data.getRequests.First();

            if (data.getRequests.Count > 0)
            {
                for (int i = 1; i < data.getRequests.Count; i++)
                {
                    builtAssets += "," + data.getRequests[i];
                }
            }


            string getVariable = string.Format(endPoint.endPoint, builtAssets);

            LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
            {
                LootLockerAssetResponse response = new LootLockerAssetResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response      = JsonConvert.DeserializeObject <LootLockerAssetResponse>(serverResponse.text);
                    response.text = serverResponse.text;
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, true);
        }
Example #11
0
        public static void GetAssetListWithCount(LootLockerGetRequest data, Action <LootLockerAssetResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.current.gettingAssetListWithCount;

            string getVariable = string.Format(endPoint.endPoint, data.getRequests[0]);

            LootLockerServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
            {
                LootLockerAssetResponse response = new LootLockerAssetResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response      = JsonConvert.DeserializeObject <LootLockerAssetResponse>(serverResponse.text);
                    response.text = serverResponse.text;
                    if (response != null)
                    {
                        LootLockerAssetRequest.lastId = response.assets.Last()?.id != null ? response.assets.Last().id : 0;
                    }
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, true);
        }
Example #12
0
        public static void Session(LootLockerGetRequest data, Action <LootLockerSessionResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.current.authenticationRequest;

            string json = "";

            if (data == null)
            {
                return;
            }
            else
            {
                json = JsonConvert.SerializeObject(data);
            }
            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
            {
                LootLockerSessionResponse response = new LootLockerSessionResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerSessionResponse>(serverResponse.text);
                    LootLockerConfig.current.UpdateToken(response.session_token, (data as LootLockerSessionRequest)?.player_identifier);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, false);
        }
Example #13
0
 public void StartingAMission()
 {
     LootLockerSDKManager.StartingAMission(missionId, (response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #14
0
 public void GettingAllMissions()
 {
     LootLockerSDKManager.GettingAllMissions((response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #15
0
 public void SubmittingACrashLog()
 {
     LootLockerSDKManager.SubmittingACrashLog(logFilePath, game_version, type_identifier, local_crash_time, (response) =>
     {
         if (!response.hasError)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #16
0
 public void GettingASingleAssetCandidate()
 {
     LootLockerSDKManager.GettingASingleAssetCandidate(assetId, (response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful" + response.asset_candidate.asset_id);
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #17
0
 public void ListingAssetCandidates()
 {
     LootLockerSDKManager.ListingAssetCandidates((response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #18
0
 public void CreatingAnAssetCandidate()
 {
     LootLockerSDKManager.CreatingAnAssetCandidate(assetName, (response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     }, context_id: sendContextId ? 21 : -1);
 }
Example #19
0
 public void UpdatingAnAssetCandidate()
 {
     LootLockerSDKManager.UpdatingAnAssetCandidate(assetId, markAssetAsComplete, (response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     }, name: assetName);
 }
Example #20
0
 public void AddingFilesToAssetCandidates()
 {
     LootLockerSDKManager.AddingFilesToAssetCandidates(assetId, filePath, fileName, filePurpose, (response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #21
0
 public void RemovingFilesFromAssetCandidates()
 {
     LootLockerSDKManager.RemovingFilesFromAssetCandidates(assetId, fileId, (response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful");
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
         }
     });
 }
Example #22
0
 public void GettingAllMaps()
 {
     LootLockerSDKManager.GettingAllMaps((response) =>
     {
         if (response.success)
         {
             LootLockerSDKManager.DebugMessage("Successful got assets" + response.text);
         }
         else
         {
             LootLockerSDKManager.DebugMessage("failed to get assets : " + response.Error, true);
         }
     });
 }
        protected override void RefreshTokenAndCompleteCall(LootLockerServerRequest cacheServerRequest, Action <LootLockerResponse> OnServerResponse)
        {
            if (activeConfig != null && activeConfig.platform == LootLockerGenericConfig.platformType.Steam)
            {
                LootLockerSDKManager.DebugMessage("Token has expired, And token refresh not supported in Steam calls", true);
                LootLockerResponse res = new LootLockerResponse();
                res.statusCode = 401;
                res.Error      = "Token Expired";
                res.hasError   = true;
                OnServerResponse?.Invoke(res);
                return;
            }

            var sessionRequest = new LootLockerSessionRequest(activeConfig.deviceID);

            LootLockerAPIManager.Session(sessionRequest, (response) =>
            {
                if (response.success)
                {
                    Dictionary <string, string> headers = new Dictionary <string, string>();
                    headers.Add("x-session-token", activeConfig.token);
                    cacheServerRequest.extraHeaders = headers;
                    if (cacheServerRequest.retryCount < 4)
                    {
                        SendRequest(cacheServerRequest, OnServerResponse);
                        cacheServerRequest.retryCount++;
                    }
                    else
                    {
                        LootLockerSDKManager.DebugMessage("Session refresh failed", true);
                        LootLockerResponse res = new LootLockerResponse();
                        res.statusCode         = 401;
                        res.Error    = "Token Expired";
                        res.hasError = true;
                        OnServerResponse?.Invoke(res);
                    }
                }
                else
                {
                    LootLockerSDKManager.DebugMessage("Session refresh failed", true);
                    LootLockerResponse res = new LootLockerResponse();
                    res.statusCode         = 401;
                    res.Error    = "Token Expired";
                    res.hasError = true;
                    OnServerResponse?.Invoke(res);
                }
            });
        }
Example #24
0
        public static void SubmittingACrashLog(LootLockerSubmittingACrashLogRequest data, Action <LootLockerResponse> onComplete)
        {
            EndPointClass requestEndPoint = LootLockerEndPoints.submittingACrashLog;

            Dictionary <string, string> formData = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(data.game_version))
            {
                formData.Add("game_version", data.game_version);
            }
            if (!string.IsNullOrEmpty(data.type_identifier))
            {
                formData.Add("type_identifier", data.type_identifier);
            }
            if (!string.IsNullOrEmpty(data.local_crash_time))
            {
                formData.Add("local_crash_time", data.local_crash_time);
            }

            if (string.IsNullOrEmpty(data.logFileName))
            {
                string[] splitFilePath   = data.logFilePath.Split(new char[] { '\\', '/' });
                string   defaultFileName = splitFilePath[splitFilePath.Length - 1];
                data.logFileName = defaultFileName;
            }

            LootLockerServerRequest.UploadFile(requestEndPoint.endPoint, requestEndPoint.httpMethod, System.IO.File.ReadAllBytes(data.logFilePath),
                                               data.logFileName, "application/zip", formData, onComplete: (serverResponse) =>
            {
                LootLockerResponse response = new LootLockerResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerResponse>(serverResponse.text);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.success = serverResponse.success;
                    response.Error   = serverResponse.Error; response.statusCode = serverResponse.statusCode;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: false);
        }
Example #25
0
        public static void AddingFilesToAssetCandidates(LootLockerAddingFilesToAssetCandidatesRequest data, LootLockerGetRequest getRequests, Action <LootLockerUserGenerateContentResponse> onComplete)
        {
            EndPointClass requestEndPoint = LootLockerEndPoints.current.addingFilesToAssetCandidates;

            string endPoint = string.Format(requestEndPoint.endPoint, getRequests.getRequests[0]);

            Dictionary <string, string> formData = new Dictionary <string, string>();

            formData.Add("purpose", data.filePurpose.ToString());

            if (string.IsNullOrEmpty(data.fileName))
            {
                string[] splitFilePath   = data.filePath.Split(new char[] { '\\', '/' });
                string   defaultFileName = splitFilePath[splitFilePath.Length - 1];
                data.fileName = defaultFileName;
            }

            if (string.IsNullOrEmpty(data.fileContentType))
            {
                data.fileContentType = "multipart/form-data";
            }
            byte[] fileData = System.IO.File.ReadAllBytes(data.filePath);

            LootLockerServerRequest.UploadFile(endPoint, requestEndPoint.httpMethod, fileData, data.fileName, data.fileContentType,
                                               formData, (serverResponse) =>
            {
                LootLockerUserGenerateContentResponse response = new LootLockerUserGenerateContentResponse();

                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerUserGenerateContentResponse>(serverResponse.text);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: true, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.User);
        }
        protected IEnumerator DoDownloadTexture2D(string url, System.Action <Texture2D> OnComplete = null)
        {
            using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(url))
            {
                www.SetRequestHeader("Access-Control-Allow-Headers", "Accept, X-Access-Token, X-Application-Name, X-Request-Sent-Time");
                www.SetRequestHeader("Access-Control-Allow-Credentials", "true");
                www.SetRequestHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD");
                www.SetRequestHeader("Access-Control-Allow-Origin", "*");

                yield return(www.SendWebRequest());

                Texture2D texture = DownloadHandlerTexture.GetContent(www);

                if (texture == null)
                {
                    LootLockerSDKManager.DebugMessage("Texture download failed for: " + url, true);
                }

                OnComplete?.Invoke(texture);
            }
        }
Example #27
0
        public void FinishingAMission()
        {
            LootLockerFinishingPayload finishingPayload = new LootLockerFinishingPayload()
            {
                finish_score     = finishScore,
                finish_time      = finishTime,
                checkpoint_times = checkpointTimes.ToArray()
            };

            LootLockerSDKManager.FinishingAMission(missionId, startingMissionSignature, playerId, finishingPayload, (response) =>
            {
                if (response.success)
                {
                    LootLockerSDKManager.DebugMessage("Successful");
                }
                else
                {
                    LootLockerSDKManager.DebugMessage("failed: " + response.Error, true);
                }
            });
        }
        public LootLockerServerRequest(string endpoint, LootLockerHTTPMethod httpMethod = LootLockerHTTPMethod.GET, string payload = null, Dictionary <string, string> extraHeaders = null, Dictionary <string, string> queryParams = null, bool useAuthToken = true, LootLocker.LootLockerEnums.LootLockerCallerRole callerRole = LootLocker.LootLockerEnums.LootLockerCallerRole.User)
        {
            this.retryCount   = 0;
            this.endpoint     = endpoint;
            this.httpMethod   = httpMethod;
            this.jsonPayload  = payload;
            this.upload       = null;
            this.uploadName   = null;
            this.uploadType   = null;
            this.payload      = null;
            this.extraHeaders = extraHeaders != null && extraHeaders.Count == 0 ? null : extraHeaders; // Force extra headers to null if empty dictionary was supplied
            this.queryParams  = queryParams != null && queryParams.Count == 0 ? null : queryParams;
            this.adminCall    = callerRole;
            bool isNonPayloadMethod = (this.httpMethod == LootLockerHTTPMethod.GET || this.httpMethod == LootLockerHTTPMethod.HEAD || this.httpMethod == LootLockerHTTPMethod.OPTIONS);

            this.form = null;
            if (!string.IsNullOrEmpty(jsonPayload) && isNonPayloadMethod)
            {
                LootLockerSDKManager.DebugMessage("WARNING: Payloads should not be sent in GET, HEAD, OPTIONS, requests. Attempted to send a payload to: " + this.httpMethod.ToString() + " " + this.endpoint);
            }
        }
Example #29
0
        public static void ListingAssetCandidates(Action <LootLockerListingAssetCandidatesResponse> onComplete)
        {
            EndPointClass requestEndPoint = LootLockerEndPoints.current.listingAssetCandidates;

            LootLockerServerRequest.CallAPI(requestEndPoint.endPoint, requestEndPoint.httpMethod, onComplete: (serverResponse) =>
            {
                LootLockerListingAssetCandidatesResponse response = new LootLockerListingAssetCandidatesResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerListingAssetCandidatesResponse>(serverResponse.text);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: true, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.User);
        }
Example #30
0
        public static void RemovingFilesFromAssetCandidates(LootLockerGetRequest data, Action <LootLockerUserGenerateContentResponse> onComplete)
        {
            EndPointClass requestEndPoint = LootLockerEndPoints.current.removingFilesFromAssetCandidates;

            string endPoint = string.Format(requestEndPoint.endPoint, data.getRequests[0], data.getRequests[1]);

            LootLockerServerRequest.CallAPI(endPoint, requestEndPoint.httpMethod, onComplete: (serverResponse) =>
            {
                LootLockerUserGenerateContentResponse response = new LootLockerUserGenerateContentResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    LootLockerSDKManager.DebugMessage(serverResponse.text);
                    response = JsonConvert.DeserializeObject <LootLockerUserGenerateContentResponse>(serverResponse.text);
                    onComplete?.Invoke(response);
                }
                else
                {
                    response.message = serverResponse.message;
                    response.Error   = serverResponse.Error;
                    onComplete?.Invoke(response);
                }
            }, useAuthToken: true, callerRole: LootLocker.LootLockerEnums.LootLockerCallerRole.User);
        }