<commit_before><?php
/*
 * FlowrouteNumbersLib
 *
 * This file was automatically generated for flowroute by APIMATIC BETA v2.0 on 02/12/2016
 */

namespace FlowrouteNumbersLib;
use FlowrouteNumbersLib\APIException;
use FlowrouteNumbersLib\APIHelper;
use FlowrouteNumbersLib\Configuration;
use Unirest\Unirest;

class CustomAuthUtility {
    /**
    * Appends the necessary Custom Authentication credentials for making this authorized call
    * @param HttpRequest $request The out going request to access the resource
    */
    public static function appendCustomAuthParams(
        $method = 'GET',
        $query_url=NULL,
        $headers=array(),
        $body='')
    {

        if (!isset($query_url)) { $query_url = Configuration::$BASEURI; }
        $timestamp = gmdate('Y-m-d\TH:i:s');
        $headers['X-Timestamp'] = $timestamp;
        $parsedurl = parse_url($query_url);
        if (strlen($body) > 0) {
            $body_md5 = md5($body);
        } else {
            $body_md5 = '';
        }
        if (isset($parsedurl['query'])) {
            parse_str($parsedurl['query'], $qparray);
            $qp = natsort($qparray);
            $qp = http_build_query($qp);
        } else {
            $qp = '';
        }
        
        $canonicalUri = $parsedurl['scheme'] . '://' . $parsedurl['host'] . $parsedurl['path'] . PHP_EOL . $qp;
        $message_string = $timestamp . PHP_EOL;
        $message_string .= $method . PHP_EOL;
        $message_string .= $body_md5 . PHP_EOL . $canonicalUri;
        $message_string = utf8_encode($message_string);
        $signature = hash_hmac('sha1', $message_string, Configuration::$password);

        print "Generating the request" . PHP_EOL;
        switch (strtoupper($method)) {
            case 'GET':
                $request = Unirest::get($query_url, $headers, NULL, Configuration::$username, $signature);
                break;
            case 'POST':
                $request = Unirest::post($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            case 'PUT':
                $request = Unirest::put($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            case 'PATCH':
                $request = Unirest::patch($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            case 'DELETE':
                $request = Unirest::delete($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            default:
                trigger_error("Invalid method supplied.", E_USER_ERROR);<commit_msg>Fix query param builder.<commit_after><?php
/*
 * FlowrouteNumbersLib
 *
 * This file was automatically generated for flowroute by APIMATIC BETA v2.0 on 02/12/2016
 */

namespace FlowrouteNumbersLib;
use FlowrouteNumbersLib\APIException;
use FlowrouteNumbersLib\APIHelper;
use FlowrouteNumbersLib\Configuration;
use Unirest\Unirest;

class CustomAuthUtility {
    /**
    * Appends the necessary Custom Authentication credentials for making this authorized call
    * @param HttpRequest $request The out going request to access the resource
    */
    public static function appendCustomAuthParams(
        $method = 'GET',
        $query_url=NULL,
        $headers=array(),
        $body='')
    {

        if (!isset($query_url)) { $query_url = Configuration::$BASEURI; }
        $timestamp = gmdate('Y-m-d\TH:i:s');
        $headers['X-Timestamp'] = $timestamp;
        $parsedurl = parse_url($query_url);
        if (strlen($body) > 0) {
            $body_md5 = md5($body);
        } else {
            $body_md5 = '';
        }
        if (isset($parsedurl['query'])) {
            parse_str($parsedurl['query'], $qparray);
            $qp = http_build_query($qparray);
        } else {
            $qp = '';
        }
        
        $canonicalUri = $parsedurl['scheme'] . '://' . $parsedurl['host'] . $parsedurl['path'] . PHP_EOL . $qp;
        $message_string = $timestamp . PHP_EOL;
        $message_string .= $method . PHP_EOL;
        $message_string .= $body_md5 . PHP_EOL . $canonicalUri;
        $message_string = utf8_encode($message_string);
        $signature = hash_hmac('sha1', $message_string, Configuration::$password);

        switch (strtoupper($method)) {
            case 'GET':
                $request = Unirest::get($query_url, $headers, NULL, Configuration::$username, $signature);
                break;
            case 'POST':
                $request = Unirest::post($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            case 'PUT':
                $request = Unirest::put($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            case 'PATCH':
                $request = Unirest::patch($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            case 'DELETE':
                $request = Unirest::delete($query_url, $headers, $body_md5, Configuration::$username, $signature);
                break;
            default:
                trigger_error("Invalid method supplied.", E_USER_ERROR);
{'fraction_non_alphanumeric': 0.1322488038277512, 'fraction_numerical': 0.008038277511961723, 'mean_word_length': 2.3737895416397676, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2234680', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1497, 'n_words': 323}