zamzar / zamzar-php

Official PHP library for the Zamzar API
MIT License
4 stars 3 forks source link

Job#exports returns array; not Zamzar\Export #15

Open louismrose opened 6 months ago

louismrose commented 6 months ago

Expected Behaviour

In the following:

$job = $this->client()->jobs->get(1234)->waitForCompletion();
foreach ($job->exports as $export) {
    print_r($export);
}

I expected $export to be of type Zamzar\Export.

Current Behaviour

$export is of type array:

(
    [id] => 1
    [url] => s3://example-bucket/thumbnails/example-0.png
    [status] => successful
)

Possible Solution

I think this could be due to a slight inaccuracy in the property map for Job. I believe this line should change:

-  'export' => Export::class,
+  'exports' => [Export::class],

Steps to Reproduce

  1. Create an API job with an export (or look up the ID of an existing one)
  2. Run the code in the "expected behaviour section"
  3. Observe that $export is of type array

Environment

louismrose commented 6 months ago

This could be a breaking change due to the change in return type. (Callers will now receive an Export when they might previously have been indexing into an array).

We could either:

louismrose commented 5 months ago

We discussed this as a team today, and we'd like to fix this properly behind a breaking change. We're going to target v3 of the SDK for this fix.