Description
Description
Currently all enqueued tasks are returned as an array without defined structure, so basically we cannot be sure that is safe to access any data from it.
As I've seen structure can differ per task status, but I could be mistaken.
This idea came up to my mind after I've seen https://github.com/meilisearch/meilisearch-js/blob/main/src/enqueued-task.ts
Basic example
class EnqueuedTask implements \ArrayAccess
{
private int $taskUid;
private string indexUid;
private string $status; // 'succeeded'|'processing'|'failed'|'enqueued'|'canceled'; // this could be class constants and later migrated to enums after bumping up php requirement to 8+
private string $type; // ...
private DateTimeImmutable $enqueuedAt;
}
This could act as a base, and if response data is really different per task status, then we could extend this object into many ones with more additional information. another approach of course would be just add all data to EnqueuedTask
and for consumers to check status before accessing it
Other
This is related to #573
To break things less the returned lets say EnqueuedTask
object could implement the ArrayAccess
interface so array access would still work, it would just break things if someone has extended any of Endpoint classes.