From 9395a61af6881bc1dccda50ca42de2d07a5906eb Mon Sep 17 00:00:00 2001 From: Ingmar Szmais Date: Wed, 28 Aug 2019 15:15:03 +0200 Subject: [PATCH] fixed patch request handling and some typos --- PlagScan/API.php | 2 +- PlagScan/Helper/Documents.php | 8 ++++++-- PlagScan/Helper/Repository.php | 2 +- PlagScan/Helper/Submissions.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PlagScan/API.php b/PlagScan/API.php index b7518bf..bb222cb 100644 --- a/PlagScan/API.php +++ b/PlagScan/API.php @@ -61,7 +61,7 @@ class API $url .= '?access_token=' . $accessToken; } - if ($requestType === 'GET') { + if ($requestType === 'GET' || $requestType === 'PATCH') { foreach ($data as $key => $value) { $url .= '&' . $key . '=' . $value; } diff --git a/PlagScan/Helper/Documents.php b/PlagScan/Helper/Documents.php index df09dad..539f87a 100644 --- a/PlagScan/Helper/Documents.php +++ b/PlagScan/Helper/Documents.php @@ -29,17 +29,21 @@ class Documents extends Base } /** - * @param string $data + * @param string $fileData * @param bool $plain + * @param int $userID * @return array|string */ - public function add(string $fileData, bool $plain = false) + public function add(string $fileData, bool $plain, int $userID = 0) { if ($plain) { $data['textdata'] = $fileData; } else { $data['fileUpload'] = $fileData; } + if($userID){ + $data['userID'] = $userID; + } return $this->handler->request('documents', 'POST', $this->accessToken, $data); } diff --git a/PlagScan/Helper/Repository.php b/PlagScan/Helper/Repository.php index fb5f4a1..deb8a3c 100644 --- a/PlagScan/Helper/Repository.php +++ b/PlagScan/Helper/Repository.php @@ -25,6 +25,6 @@ class Repository extends Base */ public function delete(int $docID) { - return $this->handler->request('submissions/documents/' . $docID, 'DELETE', $this->accessToken); + return $this->handler->request('repositories/documents/' . $docID, 'DELETE', $this->accessToken); } } \ No newline at end of file diff --git a/PlagScan/Helper/Submissions.php b/PlagScan/Helper/Submissions.php index 5a8a749..8687c57 100644 --- a/PlagScan/Helper/Submissions.php +++ b/PlagScan/Helper/Submissions.php @@ -70,7 +70,7 @@ class Submissions extends Base */ public function change(int $submissionID, array $changes) { - return $this->handler->request('submission/' . $submissionID, 'PATCH', $this->accessToken, $changes); + return $this->handler->request('submissions/' . $submissionID, 'PATCH', $this->accessToken, $changes); } /** -- GitLab