<commit_before><?php

/**
 * This is a lib to crawl the Academic Network Systems.
 * You can achieve easely the querying of grade/schedule/cet/free classroom ...
 * 
 * @author <NAME> <<EMAIL>>
 * @link https://github.com/lndj/Lcrawl
 * @license  MIT
 */ 

namespace Lndj\Traits;

/**
 * This is a trait to build get & post request.
 */
trait BuildRequest {

   /**
    * Build the get request.
    * 
    * @param type|string $uri 
    * @param type|array $param 
    * @param type|array $headers 
    * @param type|bool $isAsync 
    * @return type
    */
    public function buildGetRequest($uri, $param = [], $headers = [], $isAsync = false)
    {
        $query_param = array_merge(['xh' => $this->stu_id], $param);
        $query = [
            'query' => $query_param,
            'headers' => $headers,
        ];
        if ($this->cacheCookie) {
            $query['cookies'] = $this->getCookie();
        }
        //If use getAll(), use the Async request.
        return $isAsync 
        ? $this->client->getAsync($uri, $query) 
        : $this->client->get($uri, $query);
    }

    public function buildPostRequest($uri, $query, $param, $headers = [], $isAsync = false)
    {
        //TODO
        $query_param = array_merge(['xh' => $this->stu_id], $query);
        $post = [
            'query' => $query_param,
            'headers' => $headers,
            'form_params' => $param,
        ];

        //If opened cookie cache
        if ($this->cacheCookie) {
            $post['cookies'] = $this->getCookie();
        }

        //If use getAll(), use the Async request.
        return $isAsync 
        ? $this->client->postAsync($uri, $post) 
        : $this->client->post($uri, $post);
    }
}<commit_msg>del wrong doc //TODO<commit_after><?php

/**
 * This is a lib to crawl the Academic Network Systems.
 * You can achieve easely the querying of grade/schedule/cet/free classroom ...
 * 
 * @author <NAME> <<EMAIL>>
 * @link https://github.com/lndj/Lcrawl
 * @license  MIT
 */ 

namespace Lndj\Traits;

/**
 * This is a trait to build get & post request.
 */
trait BuildRequest {

   /**
    * Build the get request.
    * 
    * @param type|string $uri 
    * @param type|array $param 
    * @param type|array $headers 
    * @param type|bool $isAsync 
    * @return type
    */
    public function buildGetRequest($uri, $param = [], $headers = [], $isAsync = false)
    {
        $query_param = array_merge(['xh' => $this->stu_id], $param);
        $query = [
            'query' => $query_param,
            'headers' => $headers,
        ];
        if ($this->cacheCookie) {
            $query['cookies'] = $this->getCookie();
        }
        //If use getAll(), use the Async request.
        return $isAsync 
        ? $this->client->getAsync($uri, $query) 
        : $this->client->get($uri, $query);
    }

    public function buildPostRequest($uri, $query, $param, $headers = [], $isAsync = false)
    {
        $query_param = array_merge(['xh' => $this->stu_id], $query);
        $post = [
            'query' => $query_param,
            'headers' => $headers,
            'form_params' => $param,
        ];

        //If opened cookie cache
        if ($this->cacheCookie) {
            $post['cookies'] = $this->getCookie();
        }

        //If use getAll(), use the Async request.
        return $isAsync 
        ? $this->client->postAsync($uri, $post) 
        : $this->client->post($uri, $post);
    }
}
{'fraction_non_alphanumeric': 0.16502605674580198, 'fraction_numerical': 0.0, 'mean_word_length': 2.0548187444739168, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 2, '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': '5871727', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1071, 'n_words': 266}