<?php
namespace boru\boruai\Openai\Stream\Response;

use boru\boruai\Openai\Stream\StreamEvent;

class Queued extends StreamEvent {
    const TYPE = 'response.queued';
    private $id;
    private $response;

    public function id($id=null) {
        if ($id) {
            $this->id = $id;
        }
        return $this->id;
    }

    public function response($responseObject=null) {
        if ($responseObject) {
            $this->response = $responseObject;
        }
        return $this->response;
    }

    public function toArray() {
        $result = [
            'type' => $this->type(),
            'id' => $this->id(),
            'response' => null,
        ];
        if (is_object($this->response) && method_exists($this->response, 'toArray')) {
            $result['response'] = $this->response->toArray();
        } else {
            $result['response'] = $this->response;
        }
        return $result;
    }
}
