ilovepdf / ilovepdf-php

iLovePDF Rest Api - PHP Library (https://developer.ilovepdf.com)
146 stars 39 forks source link

Guzzle response missusage #48

Closed flohw closed 2 months ago

flohw commented 2 months ago

Hello,

I use your library inside a Symfony project and set a webhook to be able to mark the contract signed and assign signed files to my contract in my DB. I wanted to use the SignatureManagement::getSignatureStatus(string $signatureId) method but I get the following warning message : Undefined property: GuzzleHttp\\Psr7\\Response::$body (in SignatureManagement.php:48)

The installed Guzzle version is 7.8.1. The right way to get the response content with guzzle is $response->getBody()->getContents() which in your case should be json_enocoded. The same apply to the other lines where ->body is used like in getSignaturesList():31

I can provide a patch for this single error but I am not sure about the compatibility.

Let me know if I need to open a PR for this.

Thank you

[EDIT]: After some other inspection it appears that the whole file is not using response from guzzle properly. The headers property used at line 29 should be a getHeaders() call and maybe the usage should be updated. Let me know if you need help for this. I am not available for the next week but will be happy to help on the different updates to fix these issues.

As a workaround for now I instantiate a SignatureManagement with my private et secret key. Then I use the Symfony HttpClient to call the requestreview endpoint and use the SignatureManagement::getJWT() method to provide the Authorization header.

maztch commented 2 months ago

Thanks for reporting the issue. I'll try to check it and find a way to make it compatible.

maztch commented 2 months ago

This should be solved on #49

flohw commented 2 months ago

I updated the library. It works as expected. Thanks.