class GameServer {
    
    createPlayer(playerName, mobileNumber) {
        console.warn("createplayer")

    let axiosConfig = {
        headers: {
            'Access-Control-Allow-Origin': '*',
            'Content-Type':'application/json'
        }
      }
        let data = {
                 name: playerName,
                 mobile_no: mobileNumber,   
        };

        axios.post(`${k_BASE_URL}registration`,data,axiosConfig).then(function (response) {              
                 g_playerToken = response.data.token;
            }).catch(function (error) {
                 console.log("response",error)
            });
    }
    
    sendOtp(otpNumber) {
        console.warn("sendotp");
        let axiosConfig = {
            headers: {
                'Authorization': 'Bearer '+ g_playerToken,
                'Access-Control-Allow-Origin': '*',
                'Content-Type':'application/json'
            }
        }
        var otp = "otp=" + otpNumber;

        axios.get(`${k_BASE_URL}otp?otp=${otpNumber}`,axiosConfig).then(function (response) {  
            console.log("otpSent",response.status)         
            g_OtpStatus =  response.status;
            checkOtpValidation(g_OtpStatus);
        }).catch(function (error) {
             console.log(error)
        });
    }

    resendOtp(){
       let axiosConfig = {
          headers : {
                'Authorization': 'Bearer '+ g_playerToken,
                'Access-Control-Allow-Origin': '*',
                'Content-Type':'application/json;charset=UTF-8',
            }
        }
        let data = {
            }

            axios.post(`${k_BASE_URL}resendotp`, data,axiosConfig).then(function (response) {              
            console.warn("resend", response);
        }).catch(function (error) {
            console.log(error)
        });
    }

    getKetchupScore() {
        let axiosConfig = {
            headers: {
                'Authorization': 'Bearer '+ g_playerToken,
                'Access-Control-Allow-Origin': '*',
                'Content-Type':'application/json'
            }
        }

        let dataKetchup = {

        }

        axios.post(`${k_BASE_URL}giveshakescore`, dataKetchup,axiosConfig).then(function (response) {              
            g_gameId = response.data.game_id;
            console.log("ketchup",response)
            g_cashBack  = response.data.paytm_cash
        }).catch(function (error) {
            console.log("error",error)
        });
    }

    sendPaytm (paytmNumber) {

        var paytmData = {
                "game_id": g_gameId,
                "paytm_no":paytmNumber
        }

        let axiosConfig = {
            headers: {
                'Access-Control-Allow-Origin': '*',
                'Content-Type':'application/json',
                'Authorization': 'Bearer '+ g_playerToken
            }
        }

        axios.post(`${k_BASE_URL}claimreward`, paytmData,axiosConfig).then(function (response) {              
            console.warn("claimReward", response);
            g_gameId = response.data.game_id;
        }).catch(function (error) {
            console.log("error",error)
        });

    }
}


g_gameServer =  new GameServer();

