Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.3 kB
4
Indexable
Never
 WWWForm wWWForm = new WWWForm();
        wWWForm.AddField("email", userNameIF.text.Trim());
        wWWForm.AddField("password", passwordIF.text.Trim());

        ApiRequestObject apiRequestObject = new ApiRequestObject();
        apiRequestObject.aPIType = APIType.Post;
        apiRequestObject.url = FortuneWheelConstant.apiEndpoints[(int)FortuneWheelAPIRequest.Login];
        apiRequestObject.formData = wWWForm;

        ApiHandler.apiHandler.MakeRequest(apiRequestObject, (error, response) =>
        {
            if (error)
            {
                MessageHandler.messageHandler.ShowSingleButtonPopUp("Please try again later", null);
                return;
            }

            Debug.Log(response);
            var data = JsonUtility.FromJson<LoginData>(response);

            if (data.message != "success")
            {
                MessageHandler.messageHandler.ShowSingleButtonPopUp($"{data.message}", null);
                return;
            }

            DataSaveManager.dataSaveManager.SaveData("token", data.api_token);
            DataSaveManager.dataSaveManager.SaveData("userID", data.user_id);
            AppEvents.TriggerOnUserDataLoad(data.api_token, data.user_id);

        });
Leave a Comment