<commit_before><?php

namespace RIPS\Connector\Requests\Application;

use RIPS\Connector\Requests\BaseRequest;

class UploadRequests extends BaseRequest
{
    /**
     * Build a uri for the request
     *
     * @param int $appId
     * @param int $uploadId
     * @return string
     */
    private function uri($appId, $uploadId = null)
    {
        return is_null($uploadId)
            ? "/applications/{$appId}/uploads"
            : "/applications/{$appId}/uploads/{$uploadId}";
    }

    /**
     * Get all uploads for an application
     *
     * @param int $appId
     * @param array $queryParams
     * @return \stdClass[]
     */
    public function getAll($appId, array $queryParams = [])
    {
        $response = $this->client->get($this->uri($appId), [
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }

    /**
     * Get upload for application by id
     *
     * @param int $appId
     * @param int $uploadId
     * @param array $queryParams
     * @return \stdClass
     */
    public function getById($appId, $uploadId, array $queryParams = [])
    {
        $response = $this->client->get($this->uri($appId, $uploadId), [
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }

    /**
     * Upload a new file
     *
     * @param int $appId
     * @param string $filename
     * @param string $filepath
     * @param array $queryParams
     * @return \stdClass
     */
    public function create($appId, $filename, $filepath, array $queryParams = [])
    {
        $response = $this->client->post($this->uri($appId), [
            'multipart' => [
                [
                    'name' => 'upload[file]',
                    'contents' => fopen($filepath, 'r'),
                    'filename' => $filename,
                ],
            ],
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }

    /**
     * Delete all uploads for an application
     *
     * @param int $appId
     * @param array $queryParams
     * @return void
     */
    public function deleteAll($appId, array $queryParams = [])
    {
        $response = $this->client->delete($this->uri($appId), [
            'query' => $queryParams,
        ]);

        $this->handleResponse($response, true);
    }

    /**
     * Delete an upload for an application by id
     *
     * @param int $appId
     * @param int $uploadId
     * @param array $queryParams
     * @return void
     */
    public function deleteById($appId, $uploadId, array $queryParams = [])
    {
        $response = $this->client->delete($this->uri($appId, $uploadId), [
            'query' => $queryParams,
        ]);

        $this->handleResponse($response, true);
    }
}
<commit_msg>Add call to get all uploads<commit_after><?php

namespace RIPS\Connector\Requests\Application;

use RIPS\Connector\Requests\BaseRequest;

class UploadRequests extends BaseRequest
{
    /**
     * Build a uri for the request
     *
     * @param int $appId
     * @param int $uploadId
     * @return string
     */
    private function uri($appId = null, $uploadId = null)
    {
        if (is_null($appId)) {
            return "/applications/uploads/all";
        }

        return is_null($uploadId)
            ? "/applications/{$appId}/uploads"
            : "/applications/{$appId}/uploads/{$uploadId}";
    }

    /**
     * Get all uploads for an application
     *
     * @param int|null $appId
     * @param array $queryParams
     * @return \stdClass[]
     */
    public function getAll($appId = null, array $queryParams = [])
    {
        $response = $this->client->get($this->uri($appId), [
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }

    /**
     * Get upload for application by id
     *
     * @param int $appId
     * @param int $uploadId
     * @param array $queryParams
     * @return \stdClass
     */
    public function getById($appId, $uploadId, array $queryParams = [])
    {
        $response = $this->client->get($this->uri($appId, $uploadId), [
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }

    /**
     * Upload a new file
     *
     * @param int $appId
     * @param string $filename
     * @param string $filepath
     * @param array $queryParams
     * @return \stdClass
     */
    public function create($appId, $filename, $filepath, array $queryParams = [])
    {
        $response = $this->client->post($this->uri($appId), [
            'multipart' => [
                [
                    'name' => 'upload[file]',
                    'contents' => fopen($filepath, 'r'),
                    'filename' => $filename,
                ],
            ],
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }

    /**
     * Delete all uploads for an application
     *
     * @param int $appId
     * @param array $queryParams
     * @return void
     */
    public function deleteAll($appId, array $queryParams = [])
    {
        $response = $this->client->delete($this->uri($appId), [
            'query' => $queryParams,
        ]);

        $this->handleResponse($response, true);
    }

    /**
     * Delete an upload for an application by id
     *
     * @param int $appId
     * @param int $uploadId
     * @param array $queryParams
     * @return void
     */
    public function deleteById($appId, $uploadId, array $queryParams = [])
    {
        $response = $this->client->delete($this->uri($appId, $uploadId), [
            'query' => $queryParams,
        ]);

        $this->handleResponse($response, true);
    }
}

{'fraction_non_alphanumeric': 0.14714558389727572, 'fraction_numerical': 0.0, 'mean_word_length': 1.9023162134944613, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '7381186', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1688, 'n_words': 377}