diff --git a/Classes/Endpoint/AbstractEndpoint.php b/Classes/Endpoint/AbstractEndpoint.php new file mode 100644 index 0000000..d69b432 --- /dev/null +++ b/Classes/Endpoint/AbstractEndpoint.php @@ -0,0 +1,27 @@ + $text, 'wiki' => $wiki ]; - $options['json'] = array_filter($options['json']); + $options['json'] = $this->removeNullValues($options['json']); $response = $this->client->request(self::BASE_URI . '/markdown', 'POST', $options); return (string)$response->getBody(); diff --git a/Classes/Endpoint/Repositories.php b/Classes/Endpoint/Repositories.php index 1b2b4dd..cf52e67 100644 --- a/Classes/Endpoint/Repositories.php +++ b/Classes/Endpoint/Repositories.php @@ -9,7 +9,7 @@ use Avency\Gitea\Client; /** * Repositories endpoint */ -class Repositories implements EndpointInterface +class Repositories extends AbstractEndpoint implements EndpointInterface { const BASE_URI = 'api/v1/repos'; @@ -79,7 +79,7 @@ class Repositories implements EndpointInterface ] ]; - $options['json'] = array_filter($options['json']); + $options['json'] = $this->removeNullValues($options['json']); $response = $this->client->request(self::BASE_URI . '/migrate', 'POST', $options); return \GuzzleHttp\json_decode($response->getBody(), true); } @@ -134,7 +134,7 @@ class Repositories implements EndpointInterface 'sort' => $sort, 'order' => $order, ]; - $options['query'] = array_filter($options['query']); + $options['query'] = $this->removeNullValues($options['query']); $response = $this->client->request(self::BASE_URI . '/search', 'GET', $options); return \GuzzleHttp\json_decode($response->getBody(), true); }