mirror of
https://github.com/anikeen-com/id.git
synced 2026-03-14 14:16:31 +00:00
refactored code
Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace Anikeen\Id\ApiOperations;
|
||||
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Helpers\Paginator;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait Delete
|
||||
{
|
||||
abstract public function delete(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
/**
|
||||
* Delete a resource from the API.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
abstract public function delete(string $path, array $payload = [], array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace Anikeen\Id\ApiOperations;
|
||||
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Helpers\Paginator;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait Get
|
||||
{
|
||||
abstract public function get(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
/**
|
||||
* Get a resource from the API.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
abstract public function get(string $path, array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace Anikeen\Id\ApiOperations;
|
||||
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Helpers\Paginator;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait Post
|
||||
{
|
||||
abstract public function post(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
/**
|
||||
* Make a POST request to the API.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
abstract public function post(string $path, array $payload = [], array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
namespace Anikeen\Id\ApiOperations;
|
||||
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Helpers\Paginator;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait Put
|
||||
{
|
||||
abstract public function put(string $path = '', array $parameters = [], Paginator $paginator = null): Result;
|
||||
/**
|
||||
* Make a PUT request to the API.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
abstract public function put(string $path, array $payload = [], array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
19
src/Id/ApiOperations/Request.php
Normal file
19
src/Id/ApiOperations/Request.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\ApiOperations;
|
||||
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Helpers\Paginator;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait Request
|
||||
{
|
||||
/**
|
||||
* Make a request to the API.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
abstract public function request(string $method, string $path, null|array $payload = null, array $parameters = [], Paginator $paginator = null): Result;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ trait Validation
|
||||
/**
|
||||
* @throws RequestRequiresMissingParametersException
|
||||
*/
|
||||
public function validateRequired(array $parameters, array $required)
|
||||
public function validateRequired(array $parameters, array $required): void
|
||||
{
|
||||
if (!Arr::has($parameters, $required)) {
|
||||
throw RequestRequiresMissingParametersException::fromValidateRequired($parameters, $required);
|
||||
|
||||
Reference in New Issue
Block a user