<commit_before><?php
namespace Perimeterx;

class PerimeterxS2SValidator
{
    const RISK_API_ENDPOINT = '/api/v1/risk';
    /**
     * @var string
     */
    private $pxAuthToken;

    /**
     * @var PerimeterxContext
     */
    private $pxCtx;

    /**
     * @var object - perimeterx configuration object
     */
    private $pxConfig;

    /**
     * @var PerimeterxHttpClient
     */
    private $httpClient;

    /**
     * @param PerimeterxContext - perimeterx context
     * @param array - perimeterx configurations
     */
    public function __construct($pxCtx, $pxConfig)
    {
        $this->pxConfig = $pxConfig;
        $this->pxAuthToken = $pxConfig['auth_token'];
        $this->httpClient = $pxConfig['http_client'];
        $this->pxCtx = $pxCtx;
    }

    private function sendRiskRequest()
    {
        $requestBody = [
            'request' => [
                'ip' => $this->pxCtx->getIp(),
                'headers' => $this->formatHeaders(),
                'uri' => $this->pxCtx->getUri(),
                'url' => $this->pxCtx->getFullUrl()
            ],
            'additional' => [
                's2s_call_reason' => $this->pxCtx->getS2SCallReason(),
                'module_version' => $this->pxConfig['sdk_name'],
                'http_method' => $this->pxCtx->getHttpMethod(),
                'http_version' => $this->pxCtx->getHttpVersion()
            ]
        ];

        $vid = $this->pxCtx->getVid();
        if (!isset($vid)) {
            $requestBody['vid'] = $vid;
        }
        $headers = [
            'Authorization' => 'Bearer ' . $this->pxConfig['auth_token'],
            'Content-Type' => 'application/json'
        ];

        if (isset($this->pxConfig['custom_risk_handler'])) {
            $response = $this>pxConfig['custom_risk_handler']($this->pxConfig['perimeterx_server_host'] . self::RISK_API_ENDPOINT, 'POST', $requestBody, $headers);
        } else {
            $response = $this->httpClient->send(self::RISK_API_ENDPOINT, 'POST', $requestBody, $headers);
        }
        return $response;
    }

    /**
     * @return array
     */
    private function formatHeaders()
    {<commit_msg>add missing api_timeout to risk call<commit_after><?php
namespace Perimeterx;

class PerimeterxS2SValidator
{
    const RISK_API_ENDPOINT = '/api/v1/risk';
    /**
     * @var string
     */
    private $pxAuthToken;

    /**
     * @var PerimeterxContext
     */
    private $pxCtx;

    /**
     * @var object - perimeterx configuration object
     */
    private $pxConfig;

    /**
     * @var PerimeterxHttpClient
     */
    private $httpClient;

    /**
     * @param PerimeterxContext - perimeterx context
     * @param array - perimeterx configurations
     */
    public function __construct($pxCtx, $pxConfig)
    {
        $this->pxConfig = $pxConfig;
        $this->pxAuthToken = $pxConfig['auth_token'];
        $this->httpClient = $pxConfig['http_client'];
        $this->pxCtx = $pxCtx;
    }

    private function sendRiskRequest()
    {
        $requestBody = [
            'request' => [
                'ip' => $this->pxCtx->getIp(),
                'headers' => $this->formatHeaders(),
                'uri' => $this->pxCtx->getUri(),
                'url' => $this->pxCtx->getFullUrl()
            ],
            'additional' => [
                's2s_call_reason' => $this->pxCtx->getS2SCallReason(),
                'module_version' => $this->pxConfig['sdk_name'],
                'http_method' => $this->pxCtx->getHttpMethod(),
                'http_version' => $this->pxCtx->getHttpVersion()
            ]
        ];

        $vid = $this->pxCtx->getVid();
        if (!isset($vid)) {
            $requestBody['vid'] = $vid;
        }
        $headers = [
            'Authorization' => 'Bearer ' . $this->pxConfig['auth_token'],
            'Content-Type' => 'application/json'
        ];

        if (isset($this->pxConfig['custom_risk_handler'])) {
            $response = $this>pxConfig['custom_risk_handler']($this->pxConfig['perimeterx_server_host'] . self::RISK_API_ENDPOINT, 'POST', $requestBody, $headers);
        } else {
            $response = $this->httpClient->send(self::RISK_API_ENDPOINT, 'POST', $requestBody, $headers, $this->pxConfig['api_timeout']);
        }
        return $response;
    }

    /**
     * @return array
     */
    private function formatHeaders()
    {
{'fraction_non_alphanumeric': 0.15833903718913986, 'fraction_numerical': 0.0018252338580880675, 'mean_word_length': 2.0192837465564737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 80, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '902610', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1337, 'n_words': 210}