diff --git a/src/Responses/Files/CreateResponse.php b/src/Responses/Files/CreateResponse.php index bba4cf46..e01197c1 100644 --- a/src/Responses/Files/CreateResponse.php +++ b/src/Responses/Files/CreateResponse.php @@ -54,7 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self $attributes['filename'], $attributes['purpose'], $attributes['status'], - $attributes['status_details'], + $attributes['status_details'] ?? null, $meta, ); } diff --git a/src/Responses/Files/RetrieveResponse.php b/src/Responses/Files/RetrieveResponse.php index 3564b4c8..d3cb2450 100644 --- a/src/Responses/Files/RetrieveResponse.php +++ b/src/Responses/Files/RetrieveResponse.php @@ -54,7 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self $attributes['filename'], $attributes['purpose'], $attributes['status'], - $attributes['status_details'], + $attributes['status_details'] ?? null, $meta, ); } diff --git a/src/Responses/FineTunes/RetrieveResponseFile.php b/src/Responses/FineTunes/RetrieveResponseFile.php index b76a1e60..01aa3fd5 100644 --- a/src/Responses/FineTunes/RetrieveResponseFile.php +++ b/src/Responses/FineTunes/RetrieveResponseFile.php @@ -46,7 +46,7 @@ public static function from(array $attributes): self $attributes['filename'], $attributes['purpose'], $attributes['status'], - $attributes['status_details'], + $attributes['status_details'] ?? null, ); } diff --git a/tests/Responses/Files/RetrieveResponse.php b/tests/Responses/Files/RetrieveResponse.php index e678e9f1..89002e18 100644 --- a/tests/Responses/Files/RetrieveResponse.php +++ b/tests/Responses/Files/RetrieveResponse.php @@ -50,6 +50,17 @@ ->meta()->toBeInstanceOf(MetaInformation::class); }); +test('from with status_details missing', function () { + $data = fileResource(); + unset($data['status_details']); + + $result = RetrieveResponse::from($data, meta()); + + expect($result) + ->toBeInstanceOf(RetrieveResponse::class) + ->statusDetails->toBeNull(); +}); + test('as array accessible', function () { $result = RetrieveResponse::from(fileResource(), meta());