Пример #1
0
        public static void UpdateOrCreateKeyValue(LootLockerGetPersistentStoragRequest data, Action <LootLockerGetPersistentStoragResponse> onComplete)
        {
            string json = "";

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

            EndPointClass endPoint = LootLockerEndPoints.current.updateOrCreateKeyValue;

            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, onComplete: (serverResponse) =>
            {
                LootLockerGetPersistentStoragResponse response = new LootLockerGetPersistentStoragResponse();
                if (string.IsNullOrEmpty(serverResponse.Error))
                {
                    response      = JsonConvert.DeserializeObject <LootLockerGetPersistentStoragResponse>(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);
        }
Пример #2
0
        public void UpdateOrCreateKeyValue()
        {
            LootLockerGetPersistentStoragRequest data = new LootLockerGetPersistentStoragRequest();

            for (int i = 0; i < dataToSave.Count; i++)
            {
                data.AddToPayload(dataToSave[i]);
            }

            LootLockerSDKManager.UpdateOrCreateKeyValue(data, (getPersistentStoragResponse) =>
            {
                if (getPersistentStoragResponse.success)
                {
                    labelText  = "Success\n" + getPersistentStoragResponse.text;
                    dataToSave = getPersistentStoragResponse.payload.ToList();
                }
                else
                {
                    labelText = "Failed\n" + getPersistentStoragResponse.text;
                }
            });
        }