示例#1
0
        public static void Ping(Action <LootLockerPingResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.ping;

            LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, null, ((serverResponse) =>
            {
                LootLockerPingResponse response = new LootLockerPingResponse();
                if (string.IsNullOrEmpty(serverResponse.Error) && serverResponse.text != null)
                {
                    DefaultContractResolver contractResolver = new DefaultContractResolver
                    {
                        NamingStrategy = new SnakeCaseNamingStrategy()
                    };

                    response = JsonConvert.DeserializeObject <LootLockerPingResponse>(serverResponse.text, new JsonSerializerSettings
                    {
                        ContractResolver = contractResolver,
                        Formatting = Formatting.Indented
                    });

                    if (response == null)
                    {
                        response = LootLockerResponseFactory.Error <LootLockerPingResponse>("error deserializing server response");
                        onComplete?.Invoke(response);
                        return;
                    }
                }

                response.text = serverResponse.text;
                response.success = serverResponse.success;
                response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode;
                onComplete?.Invoke(response);
            }));
        }
示例#2
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);
            });
        }
示例#3
0
        public static void WhiteLabelLogin(LootLockerWhiteLabelUserRequest input, Action <LootLockerWhiteLabelLoginResponse> onComplete)
        {
            EndPointClass endPoint = LootLockerEndPoints.whiteLabelLogin;

            string json = "";

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

            LootLockerServerRequest.CallDomainAuthAPI(endPoint.endPoint, endPoint.httpMethod, json, ((serverResponse) =>
            {
                LootLockerWhiteLabelLoginResponse response = new LootLockerWhiteLabelLoginResponse();
                if (string.IsNullOrEmpty(serverResponse.Error) && serverResponse.text != null)
                {
                    DefaultContractResolver contractResolver = new DefaultContractResolver
                    {
                        NamingStrategy = new SnakeCaseNamingStrategy()
                    };

                    response = JsonConvert.DeserializeObject <LootLockerWhiteLabelLoginResponse>(serverResponse.text, new JsonSerializerSettings
                    {
                        ContractResolver = contractResolver,
                        Formatting = Formatting.Indented
                    });

                    if (response == null)
                    {
                        response = LootLockerResponseFactory.Error <LootLockerWhiteLabelLoginResponse>("error deserializing server response");
                        onComplete?.Invoke(response);
                        return;
                    }
                }

                response.text = serverResponse.text;
                response.success = serverResponse.success;
                response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode;
                onComplete?.Invoke(response);
            }));
        }