<?php

namespace api\classes;

use api\classes\API;

require_once 'API.php';

class API_companies extends API
{
    public function updateCompanyState(): void
    {
        $query = "UPDATE companies SET company_state = ? WHERE company_uuid = ?";
        $stmt = $this->prepareStatement($query);
        $stmt->bind_param('ss', $this->data['company_state'], $this->data['company_uuid']);
        if ($this->executeStatement($stmt)) {
            $this->apiOutput(200, ['success' => 'company state successfully updated']);
        }
    }

    public function getCompanies(): array
    {
        list($query, $types, $params) = $this->buildDynamicQuery('companies');

        $items = $this->generalGetFunction($query, $types, $params, false, 'Companies');

        return ($items);
    }
}