ms32035 / firefly-iii-client Goto Github PK
View Code? Open in Web Editor NEWPython client for Firefly III API. Please read .generator/Readme.md
Python client for Firefly III API. Please read .generator/Readme.md
no matter what i do it keeps claiming its None, and I can't figure out why.
the format I am using is the same as the model.
update = {"data": {"attributes": {"active": True,
"apply_rules": True,
"description": "",
"first_date": date.date(),
"latest_date": None,
"meta": None,
"notes": "",
"recurrence_repetitions": [{ "id" : 3,
"moment": "10",
"occurrences": [datetime.date(2019, 10, 10),
datetime.date(2019, 11, 10),
datetime.date(2019, 12, 10),
datetime.date(2020, 1, 10),
datetime.date(2020, 2, 10)],
"skip": 0,
"type": "monthly",
"weekend": 1}],
"repeat_until": None,
"repetitions": 0,
"title": "תשלום אשראי",
"transaction_type": "transfer",
"transaction_type_id": 3,
"transactions": [{"amount": float(re.search(r"(?<=סכום )\d{1,3}(,{0,1}\d{3})*(\.\d+)?", text)[0].replace(",","")),
"currency_code": "ILS",
"currency_decimal_places": 2,
"currency_id": 23,
"currency_symbol": "₪",
"description": "mothly_י",
"destination_id": 7,
"destination_name": "Credit Card",
"foreign_amount": None,
"foreign_currency_code": None,
"foreign_currency_decimal_places": None,
"foreign_currency_id": None,
"foreign_currency_symbol": None,
"meta": [],
"source_id": 1,
"source_name": "Bank"}]},
"id": 1,
"type": "recurrences",
}}
api_instance = firefly_iii_client.RecurrencesApi(firefly_iii_client.ApiClient(configuration))
id = 1 # int | The ID of the recurring transaction.
recurrence_update = firefly_iii_client.RecurrenceUpdate(update)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-182-6b134959f229> in <module>
----> 1 recurrence_update = firefly_iii_client.RecurrenceUpdate(update)
~/anaconda3/lib/python3.7/site-packages/firefly_iii_client/models/recurrence_update.py in __init__(self, active, apply_rules, description, first_date, nr_of_repetitions, piggy_bank_id, repeat_until, repetitions, tags, title, transactions, type)
85 if description is not None:
86 self.description = description
---> 87 self.first_date = first_date
88 if nr_of_repetitions is not None:
89 self.nr_of_repetitions = nr_of_repetitions
~/anaconda3/lib/python3.7/site-packages/firefly_iii_client/models/recurrence_update.py in first_date(self, first_date)
186 """
187 if first_date is None:
--> 188 raise ValueError("Invalid value for `first_date`, must not be `None`") # noqa: E501
189
190 self._first_date = first_date
ValueError: Invalid value for `first_date`, must not be `None`
https://api-docs.firefly-iii.org/#/data/destroyData
PS. Maybe update to 1.4.0?
Hi,
could you please update the Repo with the new Api 1.4.0
Best Regards and thx for sharing this project
Theo
Hi,
I noticed that pypi doesn't have the latest version of this package: https://pypi.org/project/Firefly-III-API-Client/#history
Could a new pypi release be made with the latest build?
Thanks,
The new Build 2.0.12.0 Fails in config
configuration = firefly_iii_client.Configuration(
host=user_input[CONF_URL] + "/api",
access_token=user_input[CONF_ACCESS_TOKEN],
)
File "/home/usr/lib/python3.12/site-packages/pydantic/main.py", line 171, in __init__
self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 3 validation errors for Configuration
editable
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.6/v/missing
title
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.6/v/missing
value
Field required [type=missing, input_value={}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.6/v/missing
^CFound 2 non-daemonic threads.
Hi,
I'm using a private instance of Firefly behind a https proxy. This proxy has a custom CA which need to be manually installed on the os. Now it doesn't seem to work with python so I was wondering if there is a config for disabling the certificate check in the api client.
can not find a way to turn off self.local_vars_configuration.client_side_validation without change the source code
self.access_token = access_token
because of this
configuration = firefly_iii_client.Configuration(host = "https://demo.firefly-iii.org")
would not work, it only work with
configuration
= firefly_iii_client.configuration.Configuration(host = "https://demo.firefly-iii.org")`
It seems there is a bug in the generator, it doesn't handle some attributes which can be null correctly. I think its a bug because the OpenAPI looks good to me (s. below). The module complains for GET requests on non liability Asset that the attributes are not set (i.e. null).
So far I found these:
Account
PiggyBank
For your convenience I attach the fixed Python script:
Account:
[...]
class Account(ModelNormal):
[...]
@cached_property
def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
return {
'name': (str,), # noqa: E501
'type': (str,), # noqa: E501
'account_number': (str, none_type,), # noqa: E501
'account_role': (str, none_type,), # noqa: E501
'active': (bool,), # noqa: E501
'bic': (str, none_type,), # noqa: E501
'created_at': (datetime,), # noqa: E501
'credit_card_type': (str, none_type,), # noqa: E501
'currency_code': (str,), # noqa: E501
'currency_decimal_places': (int,), # noqa: E501
'currency_id': (str,), # noqa: E501
'currency_symbol': (str,), # noqa: E501
'current_balance': (str, none_type,), # noqa: E501
'current_balance_date': (datetime,), # noqa: E501
'current_debt': (str,none_type,), # noqa: E501
'iban': (str, none_type,), # noqa: E501
'include_net_worth': (bool,), # noqa: E501
'interest': (str, none_type,), # noqa: E501
'interest_period': (str, none_type,), # noqa: E501
'latitude': (float, none_type,), # noqa: E501
'liability_direction': (str, none_type,), # noqa: E501
'liability_type': (str, none_type,), # noqa: E501
'longitude': (float, none_type,), # noqa: E501
'monthly_payment_date': (datetime, none_type,), # noqa: E501
'notes': (str, none_type,), # noqa: E501
'opening_balance': (str,), # noqa: E501
'opening_balance_date': (datetime, none_type,), # noqa: E501
'order': (int, none_type,), # noqa: E501
'updated_at': (datetime,), # noqa: E501
'virtual_balance': (str,), # noqa: E501
'zoom_level': (int, none_type,), # noqa: E501
}
[...]
PiggyBank:
[...]
class PiggyBank(ModelNormal):
[...]
@cached_property
def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
return {
'account_id': (str,), # noqa: E501
'name': (str,), # noqa: E501
'target_amount': (str,), # noqa: E501
'account_name': (str,), # noqa: E501
'active': (bool,), # noqa: E501
'created_at': (datetime,), # noqa: E501
'currency_code': (str,), # noqa: E501
'currency_decimal_places': (int,), # noqa: E501
'currency_id': (str,), # noqa: E501
'currency_symbol': (str,), # noqa: E501
'current_amount': (str,), # noqa: E501
'left_to_save': (str,), # noqa: E501
'notes': (str, none_type,), # noqa: E501
'object_group_id': (str, none_type,), # noqa: E501
'object_group_order': (int, none_type,), # noqa: E501
'object_group_title': (str, none_type,), # noqa: E501
'order': (int,), # noqa: E501
'percentage': (float,), # noqa: E501
'save_per_month': (str,), # noqa: E501
'start_date': (datetime, none_type,), # noqa: E501
'target_date': (datetime, none_type,), # noqa: E501
'updated_at': (datetime,), # noqa: E501
}
[...]
The validation of incoming message is too strict when compared to what is allowed (or more like what is being sent) in firefly iii.
The following is the traceback when I was requesting some account information from my firefly iii instance.
Traceback (most recent call last):
......
File "....../lib/python3.9/site-packages/firefly_iii_client/paths/v1_accounts/get.py", line 380, in list_account
return self._list_account_oapg(
File "....../lib/python3.9/site-packages/firefly_iii_client/paths/v1_accounts/get.py", line 316, in _list_account_oapg
api_response = response_for_status.deserialize(response, self.api_client.configuration)
File "....../lib/python3.9/site-packages/firefly_iii_client/api_client.py", line 952, in deserialize
deserialized_body = body_schema.from_openapi_data_oapg(
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 2450, in from_openapi_data_oapg
return super().from_openapi_data_oapg(arg, _configuration=_configuration)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 494, in from_openapi_data_oapg
path_to_schemas = cls.__get_new_cls(arg, validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 412, in __get_new_cls
other_path_to_schemas = cls._validate_oapg(arg, validation_metadata=validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1674, in _validate_oapg
other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1615, in __validate_args
other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1426, in _validate_oapg
other_path_to_schemas = cls.__validate_items(arg, validation_metadata=updated_vm)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1351, in __validate_items
other_path_to_schemas = item_cls._validate_oapg(
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1674, in _validate_oapg
other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1615, in __validate_args
other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1674, in _validate_oapg
other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 1615, in __validate_args
other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata)
File "....../lib/python3.9/site-packages/firefly_iii_client/schemas.py", line 911, in _validate_oapg
raise ApiValueError("Invalid value {} passed in to {}, allowed_values={}".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys()))
firefly_iii_client.exceptions.ApiValueError: Invalid value <NoneClass: None> passed in to <class 'firefly_iii_client.model.account_role_property.AccountRoleProperty'>, allowed_values=dict_keys(['defaultAsset', 'sharedAsset', 'savingAsset', 'ccAsset', 'cashWalletAsset', 'null'])
Pretty much it's complaining that the incoming message contains the value None
, which is not allowed in-accordance to the openapi schema.
Everything works fine if I were to comment out the block of code within _validate_oapg
, i.e., in firefly_iii_client/schemas.py
line 897
class EnumBase:
@classmethod
def _validate_oapg(
cls,
arg,
validation_metadata: ValidationMetadata,
) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]:
"""
EnumBase _validate_oapg
Validates that arg is in the enum's allowed values
"""
- try:
- cls.MetaOapg.enum_value_to_name[arg]
- except KeyError:
- raise ApiValueError("Invalid value {} passed in to {}, allowed_values={}".format(arg, cls,
+ # try:
+ # cls.MetaOapg.enum_value_to_name[arg]
+ # except KeyError:
+ # raise ApiValueError("Invalid value {} passed in to {}, allowed_values={}".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys()))
return super()._validate_oapg(arg, validation_metadata=validation_metadata)
I think perhaps the problem is that the openapi schema is not complete? It would be great if we can disable the validation function for incoming (and optionally, outgoing) message. (because I think firefly iii server would already do its own data validation, so we don't have to do it in the client side?)
Me again, the problem child. Thanks for your work on getting the v2 api updated.
Unfortunately I'm receiving this error when I'm trying to list accounts.
File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/paths/v1_accounts/get.py", line 380, in list_account return self._list_account_oapg( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/paths/v1_accounts/get.py", line 316, in _list_account_oapg api_response = response_for_status.deserialize(response, self.api_client.configuration) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/api_client.py", line 952, in deserialize deserialized_body = body_schema.from_openapi_data_oapg( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 2452, in from_openapi_data_oapg return super().from_openapi_data_oapg(arg, _configuration=_configuration) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 494, in from_openapi_data_oapg path_to_schemas = cls.__get_new_cls(arg, validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 412, in __get_new_cls other_path_to_schemas = cls._validate_oapg(arg, validation_metadata=validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1676, in _validate_oapg other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1617, in __validate_args other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1428, in _validate_oapg other_path_to_schemas = cls.__validate_items(arg, validation_metadata=updated_vm) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1353, in __validate_items other_path_to_schemas = item_cls._validate_oapg( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1676, in _validate_oapg other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1617, in __validate_args other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1676, in _validate_oapg other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 1617, in __validate_args other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Documents/scripts/firefly_email_importer/venv/lib64/python3.11/site-packages/firefly_iii_client/schemas.py", line 913, in _validate_oapg raise ApiValueError(f"Invalid value {arg} passed in to {cls}, allowed_values={cls.MetaOapg.enum_value_to_name.keys()}") firefly_iii_client.exceptions.ApiValueError: Invalid value <NoneClass: None> passed in to <class 'firefly_iii_client.model.account_role_property.AccountRoleProperty'>, allowed_values=dict_keys(['defaultAsset', 'sharedAsset', 'savingAsset', 'ccAsset', 'cashWalletAsset', 'null'])
I'm following the example code in the newly generated docs. (here)
I copied the example from here exactly as-is and got a NameError.
Traceback (most recent call last):
File "/Users/danielcooper/Developer/ListTransactionsByAccount.py", line 31, in
start = dateutil_parser('Mon Sep 17 00:00:00 UTC 2018').date() # date | A date formatted YYYY-MM-DD. (optional)
^^^^^^^^^^^^^^^
NameError: name 'dateutil_parser' is not defined
I was able to resolve this by adding
from dateutil.parser import parse as dateutil_parser
after line 1
I believe it's supposed to say:
"pip install Firefly-III-API-Client"
instead of
"pip install firefly-iii-client"
When I run the example code, besides from the dateutil_parser
which I needed to import and change to parser.parse
. I always get an ApiException
for the TransactionSplit
model. It doesn't matter if I want to store a transaction or get them.
This is the error I get when I just use the example code but also every other code.
firefly_iii_client.exceptions.ApiAttributeError: TransactionSplit has no attribute 'external_uri' at ['received_data']['data'][0]['attributes']['transactions'][0]['external_uri']
It seems to be that external_uri
is not defined but the server sends it back which leads to the exception.
May somebody be able to change that or show me my mistake?
Hello,
Would it be possible to update this library to match the latest v2 of the API?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.