コード例 #1
0
 def __init__(self, api_key):
     configuration = ynab.Configuration()
     configuration.api_key["Authorization"] = api_key
     # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
     configuration.api_key_prefix["Authorization"] = "Bearer"
     self.configuration = configuration
     self.client = ApiClient(configuration)
コード例 #2
0
 def _configure_ynab_api(self):
     try:
         ynab_api_token = self.cfg['ynab']['api_token']
     except KeyError as e:
         field = e.args[0]
         msg = f'Field {field} is missing. YNAB access token needed. See ' \
               'config.yml.example file'
         raise ErrorInConfigFile(msg)
     configuration = ynab.Configuration()
     configuration.api_key['Authorization'] = ynab_api_token
     configuration.api_key_prefix['Authorization'] = 'Bearer'
コード例 #3
0
            for t in accounts_transactions_list[account_idx]:
                if getYnabSyncId(t) == getYnabSyncId(compare):
                    reference = [a for a in account_references if a.id == accounts[account_idx]['account']]

                    d = {}
                    d['Name'] = accounts[account_idx]['Name']
                    d['account'] = accounts[account_idx]['account']
                    if len(reference) > 0 and hasattr(reference[0], 'transfer_payee_id'):
                        d['payee_id'] = reference[0].transfer_payee_id
                    else:
                        d['payee_id'] = None

                    return d

# Configure API key authorization: bearer
configuration = ynab.Configuration()
configuration.api_key['Authorization'] = api_settings.api_key
configuration.api_key_prefix['Authorization'] = 'Bearer'

# create an instance of the API class
api_instance = ynab.TransactionsApi(ynab.ApiClient(configuration))
api_accounts = ynab.AccountsApi(ynab.ApiClient(configuration))

#SBanken auth
http_session = create_authenticated_http_session(api_settings.CLIENTID, api_settings.SECRET)
today = datetime.date.today()
endDate = today
startDate = today - datetime.timedelta(8)   # Last 8 days

# Get the transactions for all accounts
accounts = []