<?php

namespace App\Models\DTO\Movie;
use JsonSerializable;

class CompanyParams implements JsonSerializable
{
    public string $key;

    public function __construct(
        public int $curPage = 1,
        public int $itemPerPage = 20,
        public string|null $companyNm = null,
        public string|null $ceoNm = null,
        public string|null $companyPartCd = null,
        public string $companyCd = ""
    ) {
        $this->key = KOBIS_API_1;
    }

    public function jsonSerialize(): array
    {
        return [
            'curPage' => $this->curPage,
            'itemPerPage' => $this->itemPerPage,
            'companyNm' => $this->companyNm,
            'ceoNm' => $this->ceoNm,
            'companyPartCd' => $this->companyPartCd,
            'companyCd' => $this->companyCd
        ];
    }

    public function toArray(): array
    {
        return [
            'key' => $this->key,
            'curPage' => $this->curPage,
            'itemPerPage' => $this->itemPerPage,
            'companyNm' => $this->companyNm,
            'ceoNm' => $this->ceoNm,
            'companyPartCd' => $this->companyPartCd,
            'companyCd' => $this->companyCd
        ];
    }

    public function toJson(): string|false
    {
        return json_encode([
            'curPage' => $this->curPage,
            'itemPerPage' => $this->itemPerPage,
            'companyNm' => $this->companyNm,
            'ceoNm' => $this->ceoNm,
            'companyPartCd' => $this->companyPartCd,
            'companyCd' => $this->companyCd
        ]);
    }
}
