From 54f064093c53b171e372aa9d8817a4783ea92f82 Mon Sep 17 00:00:00 2001 From: Martz Date: Sat, 18 Feb 2023 18:06:02 +0100 Subject: [PATCH] add delete logic and rename authWithPassword to authAsAdmin --- src/Collection.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Collection.php b/src/Collection.php index 442bb54..33313cb 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -76,14 +76,28 @@ class Collection curl_close($ch); } public function delete(string $recordId, array $queryParams = []){ + $ch = curl_init(); + if(self::$token != ''){ + $headers = array( + 'Content-Type:application/json', + 'Authorization: '.self::$token + ); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + + curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/".$this->collection."/records/".$recordId); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); + $output = curl_exec($ch); + curl_close($ch); } public function getOne(string $recordId, array $queryParams = []){ } - public function authWithPassword(string $email, string $password) + public function authAsAdmin(string $email, string $password) { $ch = curl_init();