pymonzo
pymonzo copied to clipboard
Support for custom categories
At the moment getting transactions that have custom categories doesn't appear to be supported.
Monzo supports custom categories as part of the Plus plan (src).
When running monzo_api.transactions.list()
I get the following error:
self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for MonzoTransaction
category
Input should be 'general', 'eating_out', 'expenses', 'transport', 'cash', 'bills', 'entertainment', 'shopping', 'holidays', 'groceries', 'income', 'savings' or 'transfers' [type=enum, input_value='family', input_type=str]
In this case it's because a new category - "family" - has been added. However, I can see via the API playground that custom categories are encoded like this - "category_0000AeR8A0F6XTLXKTDADB" and this won't be supported by an enum.
Would be great to be able to still get transactions even if the categories don't exist in the enum. Maybe warn instead?
Thanks for the project, this is great!
Hi!
Thanks for reporting (and the kind words).
I'm not sure if Pydantic will play nicely with a Any
and Enum
union, but this needs to get fixed either way. I'll try to look into it soon.