freshbooks / freshbooks-python-sdk

FreshBooks API wrapper
MIT License
9 stars 4 forks source link

FilterBuilder doesn't seem to filter "active" clients correctly #42

Closed L422Y closed 2 years ago

L422Y commented 2 years ago
fb_filter = FilterBuilder()
fb_filter.boolean("active", True)
clients = freshbooks_client.clients.list(account_id, builders=[fb_filter])
clients = clients.data['clients']

I expected this to only return active / non-archived clients... but the list doesn't seem to change whether I use the filter or not, any ideas? The docs are pretty vague on this unfortunately...

amcintosh commented 2 years ago

Hi.
Our accounting endpoints don't have an "active" filter. They use a vis_state property to show their status with 0=active, 1=deleted, and 2=archived. This is documented here. By defaults the list method returns all active and archived clients.

You can specify only active clients with:

from freshbooks import FilterBuilder, VisState

fb_filter = FilterBuilder()
fb_filter.equals("vis_state", VisState.ACTIVE)
clients = freshbooks_client.clients.list(account_id, builders=[fb_filter])

You can see a list of the search filters available on the client endpoint here under "Searches / Filters".

Hope that helps.

L422Y commented 2 years ago

Great, thanks!

This Filters documentation somewhat indirectly suggests / implies that there's an active property, so that's where I was getting confused.

amcintosh commented 2 years ago

Indeed it does. Thanks. I'll address that.