<?php

class AuraGaming {

    function launch($agent_code, $agent_token, $user_code, $provider_code, $game_code, $lang) {
        $postArray = [
            'method' => 'game_launch',
            'agent_code' => $agent_code, 
            'agent_token' => $agent_token,
            'user_code' => $user_code,
            'provider_code' => $provider_code,
            'game_code' => $game_code,
            'lang' => $lang
        ];
        return $this->send_request($postArray);
    }
    
    function money_info($agent_code, $agent_token) {
        $postArray = [
            'method' => 'money_info', 
            'agent_code' => $agent_code, 
            'agent_token' => $agent_token
        ];
        return $this->send_request($postArray);
    }
    
    function provider($agent_code, $agent_token) {
        $postArray = [
            'method' => 'provider_list', 
            'agent_code' => $agent_code, 
            'agent_token' => $agent_token
        ];
        return $this->send_request($postArray);
    }
    
    function gamelist($agent_code, $agent_token, $provider_code) {
        $postArray = [
            'method' => 'game_list', 
            'agent_code' => $agent_code, 
            'agent_token' => $agent_token,
            'provider_code' => $provider_code
        ];
        return $this->send_request($postArray);
    }
    
    function send_request($postArray) {
        $jsonData = json_encode($postArray);
        $headerArray = ['Content-Type: application/json'];
        
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'https://api.nexusggr.com/');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);

        $res = curl_exec($ch);
        if (curl_errno($ch)) {
            $error_msg = curl_error($ch);
            curl_close($ch);
            return json_encode(['status' => 0, 'msg' => 'Curl Error: ' . $error_msg]);
        }
        curl_close($ch);
        
        return $res;
    }
} 

$AG = new AuraGaming();

$agent_code = "kedai909";
$agent_token = "e22fc9aedad424b1bc84657e78356534";
$agent_secret = "3f9f208c80ba7ee27467d599290d3f1f";
?>
