File: D:/HostingSpaces/farmfun/reserveren.farmfun.be/app/Komma/Teamleader/Endpoints/DealEndpoint.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\Deal;
use App\Komma\Teamleader\TeamleaderApi;
use GuzzleHttp\Psr7\Request;
final class DealEndpoint extends Endpoint
{
protected string $resourceClass = Deal::class;
/**
* Get a list of the recipes
*
* @param array $params
* @return ApiResponse
* @throws ApiException
*/
public function list(array $params = []): ApiResponse
{
$apiResponse = new ApiResponse($this->resourceClass, 'list');
$apiResponse->setApiPath('deals.list');
return $apiResponse->fill(
$this->apiClient->send(
new Request(
TeamleaderApi::HTTP_GET,
$apiResponse->getApiPath(),
$this->buildHttpHeaders(),
json_encode($params)
)
)
);
}
/**
* Get a deal by its id
*
* @param string $id
* @return ApiResponse
* @throws ApiException
*/
public function info(string $id): ApiResponse
{
$apiResponse = new ApiResponse($this->resourceClass, 'detail');
$apiResponse->setApiPath('deals.info');
return $apiResponse->fill(
$this->apiClient->send(
new Request(
TeamleaderApi::HTTP_GET,
$apiResponse->getApiPath(),
$this->buildHttpHeaders(),
json_encode(['id' => $id])
)
)
);
}
/**
* Get list of sources
*
* @return mixed
* @throws ApiException
*/
public function sources()
{
return $this->apiClient->sendSimple(
new Request(
TeamleaderApi::HTTP_GET,
'dealSources.list',
$this->buildHttpHeaders(),
)
);
}
/**
* Get list of phases
*
* @return mixed
* @throws ApiException
*/
public function phases()
{
return $this->apiClient->sendSimple(
new Request(
TeamleaderApi::HTTP_GET,
'dealPhases.list',
$this->buildHttpHeaders(),
)
);
}
/**
* @param array $dealData
* @return ApiResponse
* @throws ApiException
*/
public function create(array $dealData): ApiResponse
{
$apiResponse = new ApiResponse($this->resourceClass, 'detail');
$apiResponse->setApiPath('deals.create');
return $apiResponse->fill(
$this->apiClient->send(
new Request(
TeamleaderApi::HTTP_POST,
$apiResponse->getApiPath(),
$this->buildHttpHeaders(),
json_encode($dealData)
)
)
);
}
}