Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Callback exception trace, optional fields IFTTT, project status #9

Open
cryptoluks opened this issue Aug 18, 2022 · 3 comments
Open

Comments

@cryptoluks
Copy link

cryptoluks commented Aug 18, 2022

Hi,

thanks for the great project. Also the documentation looks very, very good for a project this size.

I wonder if the project is still alive? I tried installing the project, but get some exceptions on callbacks:

2022-08-18 09:42:41 default[redacted]  [bunqcb_mutation] input: {"NotificationUrl": {"target_url": "https://redacted.appspot.com//bunq2ifttt_mutation", "category": "MUTATION", "event_type": "MUTATION_RECEIVED", "object": {"Payment": {"id": 123456, "created": "2022-08-18 09:42:41.119373", "updated": "2022-08-18 09:42:41.119373", "monetary_account_id": 12345, "amount": {"currency": "EUR", "value": "0.01"}, "description": "", "type": "BUNQ", "merchant_reference": null, "alias": {"iban": "DE123456789000", "is_light": false, "display_name": "Forename", "avatar": {"uuid": "redacted", "image": [{"attachment_public_uuid": "redacted", "height": 1024, "width": 1024, "content_type": "image/jpeg", "urls": [{"type": "ORIGINAL", "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/bunq_file/File/content/redacted.jpg"}]}], "anchor_uuid": null, "style": "NONE"}, "label_user": {"uuid": "redacted", "display_name": "Forename", "country": "DE", "avatar": {"uuid": "redacted", "image": [{"attachment_public_uuid": "redacted", "height": 389, "width": 389, "content_type": "image/jpeg", "urls": [{"type": "ORIGINAL", "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/redacted.jpg"}]}], "anchor_uuid": "redacted", "style": "NONE"}, "public_nick_name": "Forename", "type": "PERSON"}, "country": "DE"}, "counterparty_alias": {"iban": "DE123456790000", "is_light": false, "display_name": "Forename Lastname", "avatar": {"uuid": "redacted", "image": [{"attachment_public_uuid": "redacted", "height": 1024, "width": 1024, "content_type": "image/jpeg", "urls": [{"type": "ORIGINAL", "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/bunq_file/File/content/redacted.jpg"}]}], "anchor_uuid": null, "style": "NONE"}, "label_user": {"uuid": "redacted", "display_name": "Forename Lastname", "country": "DE", "avatar": {"uuid": "redacted", "image": [{"attachment_public_uuid": "redacted", "height": 389, "width": 389, "content_type": "image/jpeg", "urls": [{"type": "ORIGINAL", "url": "https://bunq-prod-model-storage-public.s3.eu-central-1.amazonaws.com/bunq_file%2FFile%2Fcontent%redacted.jpg"}]}], "anchor_uuid": "Redacted", "style": "NONE"}, "public_nick_name": "Forename", "type": "PERSON"}, "country": "DE"}, "attachment": [], "geolocation": null, "batch_id": null, "scheduled_id": null, "address_billing": null, "address_shipping": null, "sub_type": "PAYMENT", "request_reference_split_the_bill": [], "balance_after_mutation": {"currency": "EUR", "value": "1.01"}, "payment_auto_allocate_instance": null}}}}
2022-08-18 09:42:41 default[redacted]  Traceback (most recent call last):    File "/srv/event.py", line 136, in bunq_callback_mutation      print("[bunqcb_mutation] translated: {}".format(json.dumps(item)))    File "/opt/python3.7/lib/python3.7/json/__init__.py", line 231, in dumps      return _default_encoder.encode(obj)    File "/opt/python3.7/lib/python3.7/json/encoder.py", line 199, in encode      chunks = self.iterencode(o, _one_shot=True)    File "/opt/python3.7/lib/python3.7/json/encoder.py", line 257, in iterencode      return _iterencode(o, 0)    File "/opt/python3.7/lib/python3.7/json/encoder.py", line 179, in default      raise TypeError(f'Object of type {o.__class__.__name__} '  TypeError: Object of type method is not JSON serializable

Furthermore, with the mutation triggers, I get errors in IFTTT if i do not provide every parameter. I double checked the documentation looking for a way to define optional parameters. But according to documentation, a mutation trigger with ANY/ANY is possible without defining the remaining.

image

Is anybody currently using the project with success?

Thank you very much.

@cryptoluks
Copy link
Author

Ok at least I got the callback stuff working by calling the arrow.timestamp as method in event.py and not passing the method itself to json.dumps. Not sure why this worked in the first place for anyone.

diff --git a/app/event.py b/app/event.py
index 506708f..a6f264b 100644
--- a/app/event.py
+++ b/app/event.py
@@ -59,7 +59,7 @@ def bunq_callback_request():
             "request_id": metaid,
             "meta": {
                 "id": metaid,
-                "timestamp": arrow.get(obj["created"]).timestamp
+                "timestamp": arrow.get(obj["created"]).timestamp()
             }
         }

@@ -129,7 +129,7 @@ def bunq_callback_mutation():
             "payment_id": metaid,
             "meta": {
                 "id": metaid,
-                "timestamp": arrow.get(payment["created"]).timestamp
+                "timestamp": arrow.get(payment["created"]).timestamp()
             }
         }

@cryptoluks
Copy link
Author

cryptoluks commented Aug 18, 2022

arrow had some breaking changes with 1.0, so timestamp property is now called int_timestamp and the timestamp method matches behavior of datetime. So it should probably changed to int_timestamp.

See arrow-py/arrow#832

diff --git a/app/event.py b/app/event.py
index 506708f..a6f264b 100644
--- a/app/event.py
+++ b/app/event.py
@@ -59,7 +59,7 @@ def bunq_callback_request():
             "request_id": metaid,
             "meta": {
                 "id": metaid,
-                "timestamp": arrow.get(obj["created"]).timestamp
+                "timestamp": arrow.get(obj["created"]).int_timestamp
             }
         }

@@ -129,7 +129,7 @@ def bunq_callback_mutation():
             "payment_id": metaid,
             "meta": {
                 "id": metaid,
-                "timestamp": arrow.get(payment["created"]).timestamp
+                "timestamp": arrow.get(payment["created"]).int_timestamp
             }
         }

Maybe pinning the packages version is a good idea. I will do some PRs if I find some free time :).

@cryptoluks
Copy link
Author

cryptoluks commented Aug 19, 2022

Okay I found a workaround for the missing fields error. Creating the applet with the iOS app works without any problems.

It seems to be a bug of IFTTT web interface, the request payload to https://ifttt.com/api/v3/graph it is randomly missing field parameters. Tested it with different browsers and addons disabled.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant