Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Handle Root Warnings and Access the Responses from Queries #913

Merged
merged 1 commit into from
May 5, 2024

Conversation

patrickmallen
Copy link
Contributor

Hi.
@p4vel mentioned in #888 there is a bug when accessing the warnings at the root of the response, because of the change mentioned here: https://developer.xero.com/documentation/api/efficient-data-retrieval

However, I don't think their solution is in keeping with how the system currently works, and I think adding it to the list of elements is likely going to lead to some issues with how other users are parsing the data.
As such, I've added it as a private property under the responses (similar to the root error).
I've also added proper handling for the json response, which I don't believe their solution would have worked with.
I've added a small unit test for this and confirmed that it did work.

Given the documentation indicates that this comes up in the query section, I've also added a private property on the query to save the response during the execution of the query, and a public method for accessing it.
This should allow users to access the response and parse any warnings that may have come through, while handling the content of the response as they like (and shouldn't interrupt any current implementations).

While I was doing this I noticed some issues with the inconsistent PHP versioning.
For example: in the Application file the private attributes on lines 32 to 35 (e.g. $lastApiCall) are all typed properties, however typed properties are not supported until PHP 7.4 (which is inconsistent with the composer PHP version of >=5.5.0).

I wasn't aware of whether you would want to update the composer version or remove the conflicts, so I've left them be for now.
If you'd like, I can make another pull request with the requisite change, should you tell me.

…ponses on the query. Added test for my changes.
@calcinai calcinai merged commit 7606149 into calcinai:master May 5, 2024
@calcinai
Copy link
Owner

calcinai commented May 5, 2024

Looks good to me. I think there's value in exposing those as properties regardless, given how the API has changed over the years.

I think we need to bump to PHP 8 anyway TBH, but this is probably not the right place to do that.

@p4veI
Copy link

p4veI commented Jun 21, 2024

I understand this fixed the issue I addressed in #888 ?

@patrickmallen
Copy link
Contributor Author

It should have done. Though in a slightly different way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants