update phpDocs

This commit is contained in:
Martz
2023-02-18 19:21:13 +01:00
parent 54f064093c
commit 98ae821c59

View File

@@ -2,20 +2,43 @@
namespace Pb;
/**
*
*/
class Collection
{
/**
* @var string
*/
private string $collection;
/**
* @var string
*/
private string $url;
/**
* @var string
*/
private static string $token = '';
/**
* @param string $url
* @param string $collection
*/
public function __construct(string $url, string $collection)
{
$this->url = $url;
$this->collection = $collection;
}
public function getFullList(int $batch = 200, array $queryParams = []){
/**
* @param int $batch
* @param array $queryParams
* @return mixed
*/
public function getFullList(int $batch = 200, array $queryParams = [])
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/" . $this->collection . "/records");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@@ -32,11 +55,36 @@ class Collection
return json_decode($output, JSON_FORCE_OBJECT);
}
public function getFirstListItem(string $filter, array $queryParams = []){
/**
* @param string $filter
* @param array $queryParams
* @return void
*/
public function getFirstListItem(string $filter, array $queryParams = [])
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url . "/api/collections/" . $this->collection . "/records?perPage=&page=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (self::$token != '') {
$headers = array(
'Content-Type:application/json',
'Authorization: ' . self::$token
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output, JSON_FORCE_OBJECT);
}
public function create(array $bodyParams = [],array $queryParams = []){
/**
* @param array $bodyParams
* @param array $queryParams
* @return void
*/
public function create(array $bodyParams = [], array $queryParams = [])
{
$ch = curl_init();
if (self::$token != '') {
@@ -52,11 +100,17 @@ class Collection
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($bodyParams));
$output = curl_exec($ch);
var_dump($output);
curl_close($ch);
}
public function update(string $recordId, array $bodyParams = [],array $queryParams = []){
/**
* @param string $recordId
* @param array $bodyParams
* @param array $queryParams
* @return void
*/
public function update(string $recordId, array $bodyParams = [], array $queryParams = [])
{
$ch = curl_init();
if (self::$token != '') {
@@ -72,10 +126,16 @@ class Collection
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($bodyParams));
$output = curl_exec($ch);
var_dump($output);
curl_close($ch);
}
public function delete(string $recordId, array $queryParams = []){
/**
* @param string $recordId
* @param array $queryParams
* @return void
*/
public function delete(string $recordId, array $queryParams = []):void
{
$ch = curl_init();
if (self::$token != '') {
@@ -93,10 +153,21 @@ class Collection
curl_close($ch);
}
public function getOne(string $recordId, array $queryParams = []){
/**
* @param string $recordId
* @param array $queryParams
* @return void
*/
public function getOne(string $recordId, array $queryParams = [])
{
// Todo: implibment logic
}
/**
* @param string $email
* @param string $password
* @return void
*/
public function authAsAdmin(string $email, string $password)
{
$ch = curl_init();