<commit_before><?php
$cid = 'Your client ID from user settings';
$cs = 'Your client secret from user settings';

include_once 'v2/iDoklad.php';
            
use malcanek\iDoklad\iDoklad;
use malcanek\iDoklad\auth\iDokladCredentials;
use malcanek\iDoklad\iDokladException;

try{
    $iDoklad = new iDoklad($cid, $cs, '');
    $iDoklad->setCredentialsCallback(function($credentials){
        file_put_contents('credentials.json', $credentials->toJson());
    });
    if(!file_exists('credentials.json') && empty($_GET['code'])){
        $iDoklad->authCCF();
    } 
    $credentials = new iDokladCredentials(file_get_contents('credentials.json'), true);
    $iDoklad->setCredentials($credentials);
    $request = new \malcanek\iDoklad\request\iDokladRequest('IssuedInvoices');
    $response = $iDoklad->sendRequest($request);
    echo '<pre>';
    print_r($response);
    echo '</pre>';
} catch (iDokladException $ex) {
    echo $ex->getMessage();
    echo $ex->getTraceAsString();
}<commit_msg>CCF repair If file not exists OR get code is empty, then authenticate<commit_after><?php
$cid = 'Your client ID from user settings';
$cs = 'Your client secret from user settings';

include_once 'v2/iDoklad.php';
            
use malcanek\iDoklad\iDoklad;
use malcanek\iDoklad\auth\iDokladCredentials;
use malcanek\iDoklad\iDokladException;

try{
    $iDoklad = new iDoklad($cid, $cs, '');
    $iDoklad->setCredentialsCallback(function($credentials){
        file_put_contents('credentials.json', $credentials->toJson());
    });
    if(!file_exists('credentials.json') || empty($_GET['code'])){
        $iDoklad->authCCF();
    } 
    $credentials = new iDokladCredentials(file_get_contents('credentials.json'), true);
    $iDoklad->setCredentials($credentials);
    $request = new \malcanek\iDoklad\request\iDokladRequest('IssuedInvoices');
    $response = $iDoklad->sendRequest($request);
    echo '<pre>';
    print_r($response);
    echo '</pre>';
} catch (iDokladException $ex) {
    echo $ex->getMessage();
    echo $ex->getTraceAsString();
}
{'fraction_non_alphanumeric': 0.15410305343511452, 'fraction_numerical': 0.0009541984732824427, 'mean_word_length': 3.888111888111888, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '2569126', 'n_tokens_mistral': 719, 'n_tokens_neox': 742, 'n_words': 124}