<commit_before><?php

class Ladesk
{
    public function __construct($url, $key)
    {
        $this->api_key = $key;
        $this->url = $url . '/api/index.php';
        $this->public_url = $url . '/index.php?type=my_tickets&cid=';
    }

    public function getApplicationStatus()
    {
        return $this->call('GET', 'application/status');
    }

    public function getChatsOverview()
    {
        $result = $this->call('GET', 'chats/overview');
        return $result['chatsOverview'];
    }

    public function getCallsOverview()
    {
        $result = $this->call('GET', 'calls/overview');
        return $result['callsOverview'];
    }

    public function getCompanies()
    {
        $result = $this->call('GET', 'companies');
        return $result['companies'];
    }

    public function getCompany($id)
    {
        $result = $this->call('GET', 'companies/' . $id);
        return $result;
    }

    public function getTags()
    {
        $result = $this->call('GET', 'tags');
        return $result['tags'];
    }

    public function getConversations($params = array())
    {
        $result = $this->call('GET', 'conversations', $params);
        return $result['conversations'];
    }

    public function getConversation($id)
    {
        $result = $this->call('GET', 'conversations/' . $id);
        return $result;
    }

    public function getConversationMessages($id)
    {
        $result = $this->call('GET', 'conversations/' . $id . '/messages');
        return $result;
    }

    public function getConversationTags($id)
    {
        $result = $this->call('GET', 'conversations/' . $id . '/tags');
        return $result;
    }

    public function getDepartments()
    {
        $result = $this->call('GET', 'departments');
        return $result['departments'];
    }

    public function getDepartment($id)
    {
        $result = $this->call('GET', 'departments/' . $id);
        return $result;
    }

    public function getDepartmentIdByName($name)
    {
        $departments = $this->getDepartments();
        foreach ($departments as $k => $v) {
            if (strtolower($v['name']) == strtolower($name)) {
                return $departments[$k]['departmentid'];
            }
        }
        throw new Exception('Department was not found');
    }

    public function getAgent($id)
    {
        return $this->call('GET', 'agents/' . $id);
    }

    public function getAgentsFromDepartment($id)
    {
        $result = $this->call('GET', 'departments/' . $id . '/agents');
        return $result;
    }

    public function getAgentOnlineStatus()
    {
        $result = $this->call('GET', 'onlinestatus/agents');
        return $result['agentsOnlineStates'];
    }

    public function getDepartmentOnlineStatus()
    {
        $result = $this->call('GET', 'onlinestatus/departments');
        return $result['departmentsOnlineStates'];
    }

    public function getCustomers($param = array())
    {
        $result = $this->call('GET', 'customers/', $param);
        return $result['customers'];
    }

    public function getCustomer($id)
    {
        return $this->call('GET', 'customers/' . $id);
    }

    public function getTag($id)
    {
        return $this->call('GET', 'tags/' . $id);
    }

    public function getCustomersGroups()
    {
        $result = $this->call('GET', 'customersgroups/');
        return $result['groups'];
    }

    public function getCustomersGroup($id)
    {
        return $this->call('GET', 'customersgroups/' . $id);
    }

    public function getCustomerGroups($id)
    {
        $result = $this->call('GET', 'customers/' . $id . '/groups');
        return $result['groups'];
    }

    public function getSuggestionCategories()
    {
        $result = $this->call('GET', 'suggestioncategories/');
        return $result['suggestioncategories'];
    }

    public function getCallsAgentAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/calls/agentsavailability', $params);
        return $result['agentsavailability'];
    }

    public function getTicketsAgentAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/tickets/agentsavailability', $params);
        return $result['agentsavailability'];
    }

    public function getChatAgentAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/agentsavailability', $params);
        return $result['agentsavailability'];
    }

    public function getCallsAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/availability', $params);
        return $result['availability'];
    }

    public function getChatsAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/availability', $params);
        return $result['availability'];
    }

    public function getCallsLoadReport($params = array())
    {
        $result = $this->call('GET', 'reports/calls/load', $params);
        return $result['loads'];
    }

    public function getTicketsLoadReport($params = array())
    {
        $result = $this->call('GET', 'reports/tickets/load', $params);
        return $result['loads'];
    }

    public function getChatsLoadReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/load', $params);
        return $result['loads'];
    }

    public function getCallsSLAComplianceReport($params = array())
    {
        $result = $this->call('GET', 'reports/calls/slacompliance', $params);
        return $result['slacompliances'];
    }

    public function getTicketsSLAComplianceReport($params = array())
    {
        $result = $this->call('GET', 'reports/tickets/slacompliance', $params);
        return $result['slacompliances'];
    }

    public function getChatsSLAComplianceReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/slacompliance', $params);
        return $result['slacompliances'];
    }

    public function getCallsSLALogReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/calls/slalog', $params);
        return $result['slalogs'];
    }

    public function getTicketsSLALogReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/tickets/slalog', $params);
        return $result['slalogs'];
    }

    public function getChatsSLALogReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/chats/slalog', $params);
        return $result['slalogs'];
    }

    public function getRankingAgentsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/ranking', $params);
        return $result['ranks'];
    }

    public function getTagsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/tags', $params);
        return $result['tags'];
    }

    public function getDepartmentsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/departments', $params);
        return $result['departments'];
    }

    public function getChannelsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/channels', $params);
        return $result['channels'];
    }

    public function getAgentsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/agents', $params);
        return $result['agents'];
    }

    public function getKnowledgebases()
    {
        $result = $this->call('GET', 'knowledgebase/knowledgebases');
        return $result['knowledgebases'];
    }

    public function getKnowledgebaseArticles()
    {
        $result = $this->call('GET', 'knowledgebase/entries');
        return $result['entries'];
    }

    public function getWidgets()
    {
        $result = $this->call('GET', 'widgets');
        return $result['widgets'];
    }

    public function getWidget($id)
    {
        $result = $this->call('GET', 'widgets/' . $id);
        return $result;
    }

    public function getFile($id)
    {
        $result = $this->call('GET', 'files/' . $id);
        return $result;
    }

    public function createConversation($data = array())
    {
        $result = $this->call('POST', 'conversations', $data);<commit_msg>Allow additional params to be passed to getKnowledgebaseArticles method<commit_after><?php

class Ladesk
{
    public function __construct($url, $key)
    {
        $this->api_key = $key;
        $this->url = $url . '/api/index.php';
        $this->public_url = $url . '/index.php?type=my_tickets&cid=';
    }

    public function getApplicationStatus()
    {
        return $this->call('GET', 'application/status');
    }

    public function getChatsOverview()
    {
        $result = $this->call('GET', 'chats/overview');
        return $result['chatsOverview'];
    }

    public function getCallsOverview()
    {
        $result = $this->call('GET', 'calls/overview');
        return $result['callsOverview'];
    }

    public function getCompanies()
    {
        $result = $this->call('GET', 'companies');
        return $result['companies'];
    }

    public function getCompany($id)
    {
        $result = $this->call('GET', 'companies/' . $id);
        return $result;
    }

    public function getTags()
    {
        $result = $this->call('GET', 'tags');
        return $result['tags'];
    }

    public function getConversations($params = array())
    {
        $result = $this->call('GET', 'conversations', $params);
        return $result['conversations'];
    }

    public function getConversation($id)
    {
        $result = $this->call('GET', 'conversations/' . $id);
        return $result;
    }

    public function getConversationMessages($id)
    {
        $result = $this->call('GET', 'conversations/' . $id . '/messages');
        return $result;
    }

    public function getConversationTags($id)
    {
        $result = $this->call('GET', 'conversations/' . $id . '/tags');
        return $result;
    }

    public function getDepartments()
    {
        $result = $this->call('GET', 'departments');
        return $result['departments'];
    }

    public function getDepartment($id)
    {
        $result = $this->call('GET', 'departments/' . $id);
        return $result;
    }

    public function getDepartmentIdByName($name)
    {
        $departments = $this->getDepartments();
        foreach ($departments as $k => $v) {
            if (strtolower($v['name']) == strtolower($name)) {
                return $departments[$k]['departmentid'];
            }
        }
        throw new Exception('Department was not found');
    }

    public function getAgent($id)
    {
        return $this->call('GET', 'agents/' . $id);
    }

    public function getAgentsFromDepartment($id)
    {
        $result = $this->call('GET', 'departments/' . $id . '/agents');
        return $result;
    }

    public function getAgentOnlineStatus()
    {
        $result = $this->call('GET', 'onlinestatus/agents');
        return $result['agentsOnlineStates'];
    }

    public function getDepartmentOnlineStatus()
    {
        $result = $this->call('GET', 'onlinestatus/departments');
        return $result['departmentsOnlineStates'];
    }

    public function getCustomers($param = array())
    {
        $result = $this->call('GET', 'customers/', $param);
        return $result['customers'];
    }

    public function getCustomer($id)
    {
        return $this->call('GET', 'customers/' . $id);
    }

    public function getTag($id)
    {
        return $this->call('GET', 'tags/' . $id);
    }

    public function getCustomersGroups()
    {
        $result = $this->call('GET', 'customersgroups/');
        return $result['groups'];
    }

    public function getCustomersGroup($id)
    {
        return $this->call('GET', 'customersgroups/' . $id);
    }

    public function getCustomerGroups($id)
    {
        $result = $this->call('GET', 'customers/' . $id . '/groups');
        return $result['groups'];
    }

    public function getSuggestionCategories()
    {
        $result = $this->call('GET', 'suggestioncategories/');
        return $result['suggestioncategories'];
    }

    public function getCallsAgentAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/calls/agentsavailability', $params);
        return $result['agentsavailability'];
    }

    public function getTicketsAgentAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/tickets/agentsavailability', $params);
        return $result['agentsavailability'];
    }

    public function getChatAgentAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/agentsavailability', $params);
        return $result['agentsavailability'];
    }

    public function getCallsAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/availability', $params);
        return $result['availability'];
    }

    public function getChatsAvailabilityReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/availability', $params);
        return $result['availability'];
    }

    public function getCallsLoadReport($params = array())
    {
        $result = $this->call('GET', 'reports/calls/load', $params);
        return $result['loads'];
    }

    public function getTicketsLoadReport($params = array())
    {
        $result = $this->call('GET', 'reports/tickets/load', $params);
        return $result['loads'];
    }

    public function getChatsLoadReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/load', $params);
        return $result['loads'];
    }

    public function getCallsSLAComplianceReport($params = array())
    {
        $result = $this->call('GET', 'reports/calls/slacompliance', $params);
        return $result['slacompliances'];
    }

    public function getTicketsSLAComplianceReport($params = array())
    {
        $result = $this->call('GET', 'reports/tickets/slacompliance', $params);
        return $result['slacompliances'];
    }

    public function getChatsSLAComplianceReport($params = array())
    {
        $result = $this->call('GET', 'reports/chats/slacompliance', $params);
        return $result['slacompliances'];
    }

    public function getCallsSLALogReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/calls/slalog', $params);
        return $result['slalogs'];
    }

    public function getTicketsSLALogReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/tickets/slalog', $params);
        return $result['slalogs'];
    }

    public function getChatsSLALogReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/chats/slalog', $params);
        return $result['slalogs'];
    }

    public function getRankingAgentsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/ranking', $params);
        return $result['ranks'];
    }

    public function getTagsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/tags', $params);
        return $result['tags'];
    }

    public function getDepartmentsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/departments', $params);
        return $result['departments'];
    }

    public function getChannelsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/channels', $params);
        return $result['channels'];
    }

    public function getAgentsReport($date_from, $date_to, $otherparams = array())
    {
        $params = array(
            'date_from' => $date_from,
            'date_to' => $date_to
        );
        $params = array_merge($params, $otherparams);
        $result = $this->call('GET', 'reports/agents', $params);
        return $result['agents'];
    }

    public function getKnowledgebases()
    {
        $result = $this->call('GET', 'knowledgebase/knowledgebases');
        return $result['knowledgebases'];
    }

    public function getKnowledgebaseArticles($params = array())
    {
        $result = $this->call('GET', 'knowledgebase/entries', $params);
        return $result['entries'];
    }

    public function getWidgets()
    {
        $result = $this->call('GET', 'widgets');
        return $result['widgets'];
    }

    public function getWidget($id)
    {
        $result = $this->call('GET', 'widgets/' . $id);
        return $result;
    }

    public function getFile($id)
    {
        $result = $this->call('GET', 'files/' . $id);
        return $result;
    }

    public function createConversation($data = array())
    {
        $result = $this->call('POST', 'conversations', $data);
{'fraction_non_alphanumeric': 0.16225300468527196, 'fraction_numerical': 0.0, 'mean_word_length': 2.5343772498200146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 141, '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': '1493888', 'n_tokens_mistral': 6038, 'n_tokens_neox': 5784, 'n_words': 1123}