<?php
// connection.php

define("MT5_SERVER_IP", "176.126.66.38");
define("MT5_SERVER_PORT", 443);
define("MT5_SERVER_WEB_LOGIN", "1060");
define("MT5_SERVER_WEB_PASSWORD", "Api@1234");
define("MT5_TIMEOUT", 10); // seconds

include_once __DIR__ . "/mt5_api/mt5_api.php";  // MTWebAPI class

class MT5Connection {
    public $api;

    public function __construct() {
        $this->api = new MTWebAPI("WebAPI", "./logs", true);
    }

    public function connect(): bool {
        $ret = $this->api->Connect(
            MT5_SERVER_IP,
            MT5_SERVER_PORT,
            MT5_TIMEOUT,
            MT5_SERVER_WEB_LOGIN,
            MT5_SERVER_WEB_PASSWORD
        );
        return $ret === MTRetCode::MT_RET_OK;
    }

    public function lastError(): int {
        return $this->api->LastError();
    }
}
?>
