<?php

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

class BoxOfficeParams implements JsonSerializable
{
    public string $key;

    public function __construct(
        public string $targetDt = "",
        public string|null $weekGb = null,
        public string|null $itemPerPage = null,
        public string|null $multiMovieYn = null,
        public string|null $repNationCd = null,
        public string|null $wideAreaCd = null
    ) {
        $this->key = KOBIS_API_1;
        $this->weekGb = "0";
        $this->itemPerPage = "10";
    }

    public function jsonSerialize(): array
    {
        return [
            'targetDt' => $this->targetDt,
            'weekGb' => $this->weekGb,
            'itemPerPage' => $this->itemPerPage,
            'multiMovieYn' => $this->multiMovieYn,
            'repNationCd' => $this->repNationCd,
            'wideAreaCd' => $this->wideAreaCd
        ];
    }

    public function toArray(): array
    {
        return [
            'key' => $this->key,
            'targetDt' => $this->targetDt,
            'weekGb' => $this->weekGb,
            'itemPerPage' => $this->itemPerPage,
            'multiMovieYn' => $this->multiMovieYn,
            'repNationCd' => $this->repNationCd,
            'wideAreaCd' => $this->wideAreaCd
        ];
    }

    public function toJson(): string|false
    {
        return json_encode([
            'targetDt' => $this->targetDt,
            'weekGb' => $this->weekGb,
            'itemPerPage' => $this->itemPerPage,
            'multiMovieYn' => $this->multiMovieYn,
            'repNationCd' => $this->repNationCd,
            'wideAreaCd' => $this->wideAreaCd
        ]);
    }
}
