1010
1111
1212# YNABClient is a minimal client for the YNAB API
13- class YNABClient () :
13+ class YNABClient :
1414 """
1515 A class for interacting with the YNAB API to sync transactions.
1616
@@ -78,7 +78,8 @@ def set_transactions_synced(self, transactions) -> None:
7878 {
7979 "id" : t ["id" ],
8080 "flag_color" : YNAB_SYNCED_COLOR ,
81- } for t in transactions
81+ }
82+ for t in transactions
8283 ]
8384 }
8485 response = self .request .patch (
@@ -91,7 +92,7 @@ def set_transactions_synced(self, transactions) -> None:
9192
9293
9394# SplitwiseClient is a minimal client for the Splitwise API
94- class SplitwiseClient () :
95+ class SplitwiseClient :
9596 base_url = "https://secure.splitwise.com/api/v3.0"
9697
9798 def __init__ (self , api_key , group_id ):
@@ -127,10 +128,14 @@ def sync(account_config: dict) -> None:
127128 )
128129
129130 # Get all transactions from YNAB since yesterday
130- since_date = (datetime .now ().date () - timedelta (days = 1 )).isoformat ()
131+ since_date = (
132+ datetime .now ().date () - timedelta (days = int (os .environ .get ("SINCE_DAYS" , 1 )))
133+ ).isoformat ()
131134 ynab_transactions = ynab .get_queued_transactions (since_date = since_date )
132135 expensed_transactions = []
133136
137+ logging .debug (ynab_transactions )
138+
134139 # Create expenses in Splitwise
135140 for yt in ynab_transactions :
136141 print (
@@ -166,7 +171,7 @@ def main(config: dict):
166171
167172
168173if __name__ == "__main__" :
169- logging .basicConfig (level = logging . INFO )
174+ logging .basicConfig (level = os . environ . get ( "LOGLEVEL" , " INFO" ). upper () )
170175 logging .info ("Starting YNAB to Splitwise sync" )
171176
172177 # Load config
0 commit comments