File: D:/HostingSpaces/farmfun/reserveren.farmfun.be/app/Komma/Teamleader/Endpoints/QuotationEndpoint.php
<?php
namespace App\Komma\Teamleader\Endpoints;
use App\Komma\Teamleader\Base\ApiException;
use App\Komma\Teamleader\Base\ApiResponse;
use App\Komma\Teamleader\Base\Endpoint;
use App\Komma\Teamleader\Resources\Quotation;
use App\Komma\Teamleader\TeamleaderApi;
use GuzzleHttp\Psr7\Request;
final class QuotationEndpoint extends Endpoint
{
protected string $resourceClass = Quotation::class;
/**
* Get a list of the quotations
*
* @param array $params
* @return ApiResponse
* @throws ApiException
*/
public function list(array $params = []): ApiResponse
{
$apiResponse = new ApiResponse($this->resourceClass, 'list');
$apiResponse->setApiPath('quotations.list');
return $apiResponse->fill(
$this->apiClient->send(
new Request(
TeamleaderApi::HTTP_GET,
$apiResponse->getApiPath(),
$this->buildHttpHeaders(),
json_encode($params)
)
)
);
}
/**
* Get a quotation by its id
*
* @param string $id
* @return ApiResponse
* @throws ApiException
*/
public function info(string $id): ApiResponse
{
$apiResponse = new ApiResponse($this->resourceClass, 'detail');
$apiResponse->setApiPath('quotations.info');
return $apiResponse->fill(
$this->apiClient->send(
new Request(
TeamleaderApi::HTTP_GET,
$apiResponse->getApiPath(),
$this->buildHttpHeaders(),
json_encode(['id' => $id])
)
)
);
}
/**
* @param array $quotationData
* @return ApiResponse
* @throws ApiException
*/
public function create(array $quotationData): ApiResponse
{
$apiResponse = new ApiResponse($this->resourceClass, 'detail');
$apiResponse->setApiPath('quotations.create');
return $apiResponse->fill(
$this->apiClient->send(
new Request(
TeamleaderApi::HTTP_POST,
$apiResponse->getApiPath(),
$this->buildHttpHeaders(),
json_encode($quotationData)
)
)
);
}
}