From 2c1f218b37335f0957889c70df2010c33928c51c Mon Sep 17 00:00:00 2001 From: tijsziere <39266480+tijsziere@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:41:09 +0100 Subject: [PATCH 1/5] merge main into dev (#58) * merge dev into main - fix empty label in create 121 program (#53) * fix empty label bug * Add support for barcode question type (#54) * fix empty label bug * improve clarity * fix error * add support for kobo barcode questiontype --------- Co-authored-by: Jacopo Margutti From 4226bc553e846c05ebb7b1c404da218c11b37fcd Mon Sep 17 00:00:00 2001 From: tijsziere <39266480+tijsziere@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:42:39 +0100 Subject: [PATCH 2/5] exception: map fspName to programFinancialServiceProviderConfigurationName --- routes/routes121.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/routes121.py b/routes/routes121.py index f6fbd27..663066f 100644 --- a/routes/routes121.py +++ b/routes/routes121.py @@ -72,6 +72,8 @@ async def kobo_to_121(request: Request, dependencies=Depends(required_headers_12 payload[target_field] = int(kobo_data[kobo_field]) elif target_field == "scope": payload[target_field] = clean_text(kobo_data[kobo_field]) + elif target_field == "fspName": + payload["programFinancialServiceProviderConfigurationName"] = kobo_data[kobo_field] elif kobo_value_url not in attachments.keys(): payload[target_field] = kobo_data[kobo_field] else: From dde547a634d6075ccca67805547e189cd6fc0d0d Mon Sep 17 00:00:00 2001 From: tijsziere <39266480+tijsziere@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:53:12 +0100 Subject: [PATCH 3/5] exception for nlrc --- routes/routes121.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/routes121.py b/routes/routes121.py index 663066f..4c08fc5 100644 --- a/routes/routes121.py +++ b/routes/routes121.py @@ -72,7 +72,7 @@ async def kobo_to_121(request: Request, dependencies=Depends(required_headers_12 payload[target_field] = int(kobo_data[kobo_field]) elif target_field == "scope": payload[target_field] = clean_text(kobo_data[kobo_field]) - elif target_field == "fspName": + elif target_field == "fspName" and "nlrc" not in request.headers["url121"]: payload["programFinancialServiceProviderConfigurationName"] = kobo_data[kobo_field] elif kobo_value_url not in attachments.keys(): payload[target_field] = kobo_data[kobo_field] From ff1a3c8fd9230c6986df6560372e929fd0678ca6 Mon Sep 17 00:00:00 2001 From: Sanne Berendschot Date: Mon, 2 Dec 2024 11:53:08 +0100 Subject: [PATCH 4/5] Update test_koboto121.py Change fspName to programFinancialServiceProviderConfigurationName in test --- tests/test_koboto121.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_koboto121.py b/tests/test_koboto121.py index 870a90e..119ceba 100644 --- a/tests/test_koboto121.py +++ b/tests/test_koboto121.py @@ -33,7 +33,7 @@ def test_kobo_to_121_payload(): assert payload["birthYear"] == "1600" assert payload["date"] == "2024-04-16" assert payload["deputyMain"] == "Beneficiary" - assert payload["fspName"] == "Excel" + assert payload["programFinancialServiceProviderConfigurationName"] == "Excel" assert payload["fullName"] == "asdf" assert payload["maxPayments"] == 5 assert payload["NRC"] == "12345" From 87316744f4bd8e32b7ed4d1ed049a71b2281312c Mon Sep 17 00:00:00 2001 From: Ruben Date: Mon, 2 Dec 2024 14:45:52 +0100 Subject: [PATCH 5/5] Changed endpoint url path post registrations Signed-off-by: Ruben --- routes/routes121.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/routes/routes121.py b/routes/routes121.py index 4c08fc5..a7c2f00 100644 --- a/routes/routes121.py +++ b/routes/routes121.py @@ -72,7 +72,7 @@ async def kobo_to_121(request: Request, dependencies=Depends(required_headers_12 payload[target_field] = int(kobo_data[kobo_field]) elif target_field == "scope": payload[target_field] = clean_text(kobo_data[kobo_field]) - elif target_field == "fspName" and "nlrc" not in request.headers["url121"]: + elif target_field == "fspName" and "nlrc.121.global" not in request.headers["url121"]: payload["programFinancialServiceProviderConfigurationName"] = kobo_data[kobo_field] elif kobo_value_url not in attachments.keys(): payload[target_field] = kobo_data[kobo_field] @@ -90,9 +90,14 @@ async def kobo_to_121(request: Request, dependencies=Depends(required_headers_12 # Continue with the POST if not in test mode access_token = login121(request.headers["url121"], request.headers["username121"], request.headers["password121"]) + + if 'nlrc.121.global' in request.headers['url121']: + url = f"{request.headers['url121']}/api/programs/{programid}/registrations/import" + else: + url = f"{request.headers['url121']}/api/programs/{programid}/registrations" # POST to 121 import endpoint import_response = requests.post( - f"{request.headers['url121']}/api/programs/{programid}/registrations/import", + url, headers={"Cookie": f"access_token_general={access_token}"}, json=[payload], )