HealthITAU / pyconnectwise

A library for simplifying interactions with the ConnectWise Manage API in Python
https://healthit.com.au
GNU General Public License v3.0
42 stars 7 forks source link

Issue with patch requests #15

Closed EMoonArchiTech closed 9 months ago

EMoonArchiTech commented 9 months ago

Hi All, I'm attempting a patch request to the CompanyConfigurationsIdEndpoint endpoint, but am encountering an issue with the typing of what data I'm allowed to pass through. The ConnectWise API specifies that patch requests have to come through as an array containing the data ([ ] brackets around the json {} dict) for the patch request to be accepted, but due to the chain of type annotations from CompanyConfigurationsIdEndpoint .patch() down to the base _make_request() function, data cannot be passed through to the requests function as a List.

See below for CW docs on patch requests & the format they need to follow: https://developer.connectwise.com/Best_Practices/PSA_API_Requests?mt-learningpath=manage#Patch

Here's someone from reddit solving this issue quite a while ago, passing an array of dicts into the json field, which it also looks like the _make_request function is using to pass 'data' args into.

What would be the best way to approach fixing this? just changing the input types on _make_requests to also accept List[Dict[...]]?

Yoshify commented 9 months ago

Hrm I feel like I already had this type annotated as a union of list[dict[...]] | dict[..] but I don't see it in the commit history. Maybe I'm just imagining things.

This'll be an easy fix, I'll get around to making a PR soon.

Yoshify commented 9 months ago

This is fixed alongside the improvements to typing in 0.5.0 - please feel free to re-open if you have any more issues :)