HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Teamleader/Endpoints/CompanyEndpoint.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\Company;
use App\Komma\Teamleader\TeamleaderApi;
use GuzzleHttp\Psr7\Request;

final class CompanyEndpoint extends Endpoint
{
    protected string $resourceClass = Company::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('companies.list');

        return $apiResponse->fill(
            $this->apiClient->send(
                new Request(
                    TeamleaderApi::HTTP_GET,
                    $apiResponse->getApiPath(),
                    $this->buildHttpHeaders(),
                    json_encode($params)
                )
            )
        );
    }

    /**
     * @param array $companyData
     * @return ApiResponse
     * @throws ApiException
     */
    public function add(array $companyData): ApiResponse
    {
        $apiResponse = new ApiResponse($this->resourceClass, 'detail');
        $apiResponse->setApiPath('companies.add');

        return $apiResponse->fill(
            $this->apiClient->send(
                new Request(
                    TeamleaderApi::HTTP_POST,
                    $apiResponse->getApiPath(),
                    $this->buildHttpHeaders(),
                    json_encode($companyData)
                )
            )
        );
    }

    /**
     * Get a company by its id
     *
     * @param string $id
     * @return ApiResponse
     * @throws ApiException
     */
    public function info(string $id): ApiResponse
    {
        $apiResponse = new ApiResponse($this->resourceClass, 'detail');
        $apiResponse->setApiPath('companies.info');

        return $apiResponse->fill(
            $this->apiClient->send(
                new Request(
                    TeamleaderApi::HTTP_GET,
                    $apiResponse->getApiPath(),
                    $this->buildHttpHeaders(),
                    json_encode(['id' => $id])
                )
            )
        );
    }
}