25
loading...
This website collects cookies to deliver better user experience
def lambda_handler(event, context):
print(event)
def create_webhook(invoke_url):
api_url = api_url_base + 'webhooks'
data_object = {"data": {"attributes": {"url" : invoke_url}}}
response = requests.post(api_url, headers=headers, json=data_object)
print(response.text)
def retrieve_transaction(transaction_id):
api_url = api_url_base + 'transactions/' + transaction_id
response = requests.get(api_url, headers=headers)
data = response.json()
dictionary = {
'ID' : transaction_id,
'Description' : data.get('data').get('attributes').get('description'),
'Value' : data.get('data').get('attributes').get('amount').get('value')[1:],
'Created At' : data.get('data').get('attributes').get('createdAt')
}
if data.get('data').get('attributes').get('amount').get('value') < 0:
pass
if data.get('data').get('relationships').get('category').get('data'):
dictionary['Category'] = data.get('data').get('relationships').get('category').get('data').get('id')
else:
dictionary['Category'] = 'Uncategorized'
if data.get('data').get('relationships').get('parentCategory').get('data'):
dictionary['Parent Category'] = data.get('data').get('relationships').get('parentCategory').get('data').get('id')
else:
dictionary['Parent Category'] = 'Uncategorized'
return dictionary
transaction_id = event.get('body').get('data').get('relationships').get('transaction').get('data').get('id')
transaction = retrieve_transaction(transaction_id)