Exemplo n.º 1
0
    public static void ValidateStakeAmount(StakePayload payload, ResponseCallback callback, ResponseFallback fallback)
    {
        HttpClient httpClient = new HttpClient();

        Request request = new Request(HttpClient.Method.POST, Route.VALIDATE_STAKE_ROUTE, payload);

        httpClient.Request(
            request,
            (statusCode, response) => {
            ValidateStakeResponse validateResponse = Deserialize(response);
            callback(validateResponse);
        },
            (statusCode, error) => {
            if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
            {
                ValidationError validationError = ErrorDeserilizer.DeserializeValidationErrorData(error);
                fallback(statusCode, validationError);
            }
            else
            {
                GenericError genericError = ErrorDeserilizer.DeserializeGenericErrorData(error);
                fallback(statusCode, genericError);
            }
        }
            );
    }
Exemplo n.º 2
0
 public void ValidateUserCanStake()
 {
     menuManager.SetLoading(StakePanel);
     ValidateStake.ValidateStakeAmount(
         new StakePayload(StakeType.uid),
         (response) => {
         ValidateStakeResponse validateStakeResponse = (ValidateStakeResponse)response;
         State.CurrentStake = StakeType;
         SceneManager.LoadScene(sceneBuildIndex: Scenes.CONNECTING_TO_NETWORK_SCENE);
     },
         (statusCode, error) => {
         menuManager.UnSetLoading(StakePanel);
         if (statusCode == StatusCodes.CODE_VALIDATION_ERROR)
         {
             ValidationError validationError = (ValidationError)error;
             menuManager.StartCoroutine(menuManager.showPopUpT(validationError.errors.First().Value[0], "error"));
         }
         else
         {
             GenericError genericError = (GenericError)error;
             menuManager.StartCoroutine(menuManager.showPopUpT(genericError.message, "error"));
         }
     }
         );
 }
Exemplo n.º 3
0
    private static ValidateStakeResponse Deserialize(object response)
    {
        var responseJson = (string)response;

        var data = fsJsonParser.Parse(responseJson);

        object deserialized = null;

        serializer.TryDeserialize(data, typeof(ValidateStakeResponse), ref deserialized);

        ValidateStakeResponse serializedData = deserialized as ValidateStakeResponse;

        return(serializedData);
    }