<commit_before><?php namespace SeBuDesign\BuckarooJson;

use GuzzleHttp\Client;
use SeBuDesign\BuckarooJson\Partials\Data;

class RequestBase
{
    use Data;

    /**
     * The Buckaroo website key
     *
     * @var string
     */
    protected $sWebsiteKey;

    /**
     * The Buckaroo secret key
     *
     * @var string
     */
    protected $sSecretKey;

    /**
     * Is this a test transaction?
     *
     * @var boolean
     */
    protected $bTesting = false;

    /**
     * The Buckaroo endpoint
     *
     * @var string
     */
    protected $aRequestData = [
        'base_uri' => 'https://checkout.buckaroo.nl/json/',
        'headers' => [
            'Content-Type' => 'application/json'
        ],
    ];

    /**
     * The HTTP Client
     *
     * @var Client
     */
    protected $oHttpClient;

    /**
     * Transaction constructor.
     *
     * @param string $sWebsiteKey The Buckaroo Website Key
     * @param string $sSecretKey  The Buckaroo Secret Key
     */
    public function __construct($sWebsiteKey, $sSecretKey)
    {
        $this->sWebsiteKey = $sWebsiteKey;
        $this->sSecretKey = $sSecretKey;
        $this->oHttpClient = new Client();
    }

    /**
     * Set the attributes for a test Transaction
     *
     * @return $this
     */
    public function putInTestMode()
    {
        $this->bTesting = true;
        $this->aRequestData['base_uri'] = 'https://testcheckout.buckaroo.nl/json/';

        return $this;
    }

    protected function getAuthorizationHeader($sContent, $sCall, $sMethod)
    {
        $sContent = base64_encode(
            md5($sContent, true)
        );

        $iTime = time();

        $sNonce = sprintf('%04x%04x%04x%04x%04x%04x%04x%04x',

            // 32 bits for "time_low"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),

            // 16 bits for "time_mid"
            mt_rand(0, 0xffff),

            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand(0, 0x0fff) | 0x4000,

            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand(0, 0x3fff) | 0x8000,

            // 48 bits for "node"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)<commit_msg>In case of a get request skip encryption<commit_after><?php namespace SeBuDesign\BuckarooJson;

use GuzzleHttp\Client;
use SeBuDesign\BuckarooJson\Partials\Data;

class RequestBase
{
    use Data;

    /**
     * The Buckaroo website key
     *
     * @var string
     */
    protected $sWebsiteKey;

    /**
     * The Buckaroo secret key
     *
     * @var string
     */
    protected $sSecretKey;

    /**
     * Is this a test transaction?
     *
     * @var boolean
     */
    protected $bTesting = false;

    /**
     * The Buckaroo endpoint
     *
     * @var string
     */
    protected $aRequestData = [
        'base_uri' => 'https://checkout.buckaroo.nl/json/',
        'headers' => [
            'Content-Type' => 'application/json'
        ],
    ];

    /**
     * The HTTP Client
     *
     * @var Client
     */
    protected $oHttpClient;

    /**
     * Transaction constructor.
     *
     * @param string $sWebsiteKey The Buckaroo Website Key
     * @param string $sSecretKey  The Buckaroo Secret Key
     */
    public function __construct($sWebsiteKey, $sSecretKey)
    {
        $this->sWebsiteKey = $sWebsiteKey;
        $this->sSecretKey = $sSecretKey;
        $this->oHttpClient = new Client();
    }

    /**
     * Set the attributes for a test Transaction
     *
     * @return $this
     */
    public function putInTestMode()
    {
        $this->bTesting = true;
        $this->aRequestData['base_uri'] = 'https://testcheckout.buckaroo.nl/json/';

        return $this;
    }

    protected function getAuthorizationHeader($sContent, $sCall, $sMethod)
    {
        if (!empty($sContent)) {
            $sContent = base64_encode(
                md5($sContent, true)
            );
        }

        $iTime = time();

        $sNonce = sprintf('%04x%04x%04x%04x%04x%04x%04x%04x',

            // 32 bits for "time_low"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),

            // 16 bits for "time_mid"
            mt_rand(0, 0xffff),

            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand(0, 0x0fff) | 0x4000,

            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand(0, 0x3fff) | 0x8000,

            // 48 bits for "node"
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
{'fraction_non_alphanumeric': 0.11961920529801325, 'fraction_numerical': 0.02566225165562914, 'mean_word_length': 1.8164335664335665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 4, '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': '2182442', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1525, 'n_words': 362}