<commit_before><?php
namespace xoxzo\cloudphp;
require 'vendor/autoload.php';

use \GuzzleHttp\Client as HttpClient;
use \GuzzleHttp\Exception\TransferException as TransferException;

define("XOXZO_HTTP_EXCEPTION", 499);

class XoxzoResponse
{
    public $errors;

    public $messages;

    function __construct($errors, $messages = array())
    {
        $this->errors = $errors;
        $this->messages = $messages;
    }
}

class XoxzoClient
{
    private $sid;
    private $auth_token;

    function __construct($sid, $auth_token)
    {
        $basic_auth_data = ['auth' => [$sid, $auth_token]];
        $this->client = new HttpClient();
        $api_host = "https://api.xoxzo.com";
        $this->xoxzo_api_sms_url = $api_host . "/sms/messages/";
        $this->xoxzo_api_voice_simple_url = $api_host . "/voice/simple/playback/";
        $this->xoxzo_api_dins_url = $api_host . "/voice/dins/";
        $this->guzzle_options = ['http_errors' => false] + $basic_auth_data;
    }

    private function handleException($e)
    {
        if ($e->hasResponse()) {
            $resp = $e->getResponse();
            $stat = $resp->getStatusCode();
            $msgs = $resp->getBody()->getContents();
        }
        else {
            $stat = XOXZO_HTTP_EXCEPTION;
            $msgs = $e->getHandlerContext() ['error'];
        }

        return (new XoxzoResponse($stat, $msgs));
    }

    private function parse($resp)
    {
        $stat = $resp->getStatusCode();
        if (($stat == 200) or ($stat == 201)) {
            $stat = null;
        }

        $msgs = json_decode($resp->getBody());
        return (new XoxzoResponse($stat, $msgs));
    }

    public function send_sms($message, $recipient, $sender)
    {
        $params = ['form_params' => ['message' => $message, 'recipient' => $recipient, 'sender' => $sender]];
        try {
            $resp = $this->client->post($this->xoxzo_api_sms_url, $this->guzzle_options + $params);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_sms_delivery_status($msgid)
    {
        $url = $this->xoxzo_api_sms_url . $msgid;
        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_sent_sms_list($sent_date="")
    {
        if ($sent_date != "") {
            $url = $this->xoxzo_api_sms_url . '?sent_date' . $sent_date;
        }
        else {
            $url = $this->xoxzo_api_sms_url;
        }

        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function call_simple_playback($caller, $recipient, $recording_url)
    {
        $params = ['form_params' => ['caller' => $caller, 'recipient' => $recipient, 'recording_url' => $recording_url]];
        try {
            $resp = $this->client->post($this->xoxzo_api_voice_simple_url, $this->guzzle_options + $params);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function call_tts_playback($caller, $recipient, $tts_message, $tts_lang)
    {
        $params = ['form_params' => ['caller' => $caller, 'recipient' => $recipient, 'tts_message' => $tts_message, 'tts_lang' => $tts_lang]];
        try {
            $resp = $this->client->post($this->xoxzo_api_voice_simple_url, $this->guzzle_options + $params);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_simple_playback_status($callid)
    {
        $url = $this->xoxzo_api_voice_simple_url . $callid;
        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_din_list($search_string="")
    {
        if ($search_string != "") {
            $url = $this->xoxzo_api_dins_url . "?" . $search_string;
        } else {
            $url = $this->xoxzo_api_dins_url;

        }
        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }<commit_msg>Change endpoint<commit_after><?php
namespace xoxzo\cloudphp;
require 'vendor/autoload.php';

use \GuzzleHttp\Client as HttpClient;
use \GuzzleHttp\Exception\TransferException as TransferException;

define("XOXZO_HTTP_EXCEPTION", 499);

class XoxzoResponse
{
    public $errors;

    public $messages;

    function __construct($errors, $messages = array())
    {
        $this->errors = $errors;
        $this->messages = $messages;
    }
}

class XoxzoClient
{
    private $sid;
    private $auth_token;

    function __construct($sid, $auth_token)
    {
        $basic_auth_data = ['auth' => [$sid, $auth_token]];
        $this->client = new HttpClient();
        $api_host = "https://api.xoxzo.com";
        $this->xoxzo_api_sms_url = $api_host . "/sms/messages/";
        $this->xoxzo_api_call_url = $api_host . "/calls/";
        $this->xoxzo_api_voice_simple_url = $api_host . "/voice/simple/playbacks/";
        $this->xoxzo_api_dins_url = $api_host . "/voice/dins/";
        $this->guzzle_options = ['http_errors' => false] + $basic_auth_data;
    }

    private function handleException($e)
    {
        if ($e->hasResponse()) {
            $resp = $e->getResponse();
            $stat = $resp->getStatusCode();
            $msgs = $resp->getBody()->getContents();
        }
        else {
            $stat = XOXZO_HTTP_EXCEPTION;
            $msgs = $e->getHandlerContext() ['error'];
        }

        return (new XoxzoResponse($stat, $msgs));
    }

    private function parse($resp)
    {
        $stat = $resp->getStatusCode();
        if (($stat == 200) or ($stat == 201)) {
            $stat = null;
        }

        $msgs = json_decode($resp->getBody());
        return (new XoxzoResponse($stat, $msgs));
    }

    public function send_sms($message, $recipient, $sender)
    {
        $params = ['form_params' => ['message' => $message, 'recipient' => $recipient, 'sender' => $sender]];
        try {
            $resp = $this->client->post($this->xoxzo_api_sms_url, $this->guzzle_options + $params);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_sms_delivery_status($msgid)
    {
        $url = $this->xoxzo_api_sms_url . $msgid;
        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_sent_sms_list($sent_date="")
    {
        if ($sent_date != "") {
            $url = $this->xoxzo_api_sms_url . '?sent_date' . $sent_date;
        }
        else {
            $url = $this->xoxzo_api_sms_url;
        }

        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function call_simple_playback($caller, $recipient, $recording_url)
    {
        $params = ['form_params' => ['caller' => $caller, 'recipient' => $recipient, 'recording_url' => $recording_url]];
        try {
            $resp = $this->client->post($this->xoxzo_api_voice_simple_url, $this->guzzle_options + $params);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function call_tts_playback($caller, $recipient, $tts_message, $tts_lang)
    {
        $params = ['form_params' => ['caller' => $caller, 'recipient' => $recipient, 'tts_message' => $tts_message, 'tts_lang' => $tts_lang]];
        try {
            $resp = $this->client->post($this->xoxzo_api_voice_simple_url, $this->guzzle_options + $params);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_simple_playback_status($callid)
    {
        $url = $this->xoxzo_api_call_url . $callid;
        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
    }

    public function get_din_list($search_string="")
    {
        if ($search_string != "") {
            $url = $this->xoxzo_api_dins_url . "?" . $search_string;
        } else {
            $url = $this->xoxzo_api_dins_url;

        }
        try {
            $resp = $this->client->get($url, $this->guzzle_options);
            return $this->parse($resp);
        }
        catch(TransferException $e) {
            return $this->handleException($e);
        }
{'fraction_non_alphanumeric': 0.1567867616254713, 'fraction_numerical': 0.0018852115626309175, 'mean_word_length': 2.2011397921555482, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 152, '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': '2928881', 'n_tokens_mistral': 3164, 'n_tokens_neox': 3053, 'n_words': 504}