From 4ed04a4d7cbe6a4b623b241229a848bcbc7a8bac Mon Sep 17 00:00:00 2001 From: Viktor van Wijk Date: Fri, 20 Dec 2024 11:13:46 +0100 Subject: [PATCH] :label: [#4908] Add typing hints for json registration options --- src/openforms/registrations/contrib/json/plugin.py | 7 ++++--- src/openforms/registrations/contrib/json/typing.py | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/openforms/registrations/contrib/json/typing.py diff --git a/src/openforms/registrations/contrib/json/plugin.py b/src/openforms/registrations/contrib/json/plugin.py index 4334317638..26384af938 100644 --- a/src/openforms/registrations/contrib/json/plugin.py +++ b/src/openforms/registrations/contrib/json/plugin.py @@ -7,10 +7,11 @@ from openforms.submissions.models import Submission from openforms.variables.service import get_static_variables -from ...base import BasePlugin, OptionsT # openforms.registrations.base +from ...base import BasePlugin # openforms.registrations.base from ...registry import register # openforms.registrations.registry from ...utils import execute_unless_result_exists from .config import JSONOptionsSerializer +from .typing import JSONRegistrationOptions @register("json") @@ -18,9 +19,8 @@ class JSONRegistration(BasePlugin): verbose_name = _("JSON registration") configuration_options = JSONOptionsSerializer - def register_submission(self, submission: Submission, options: OptionsT) -> None: + def register_submission(self, submission: Submission, options: JSONRegistrationOptions) -> None: # TODO-4908: the email plugin works with a EmailConfig singleton model. Is that useful here? - # TODO-4908: add typing for options dict # TODO-4908: any other form field types that need 'special attention'? @@ -72,6 +72,7 @@ def register_submission(self, submission: Submission, options: OptionsT) -> None # result = execute_unless_result_exists( # partial( # client.post, + # options["relative_api_endpoint"], # json=json, # headers={}, # ), diff --git a/src/openforms/registrations/contrib/json/typing.py b/src/openforms/registrations/contrib/json/typing.py new file mode 100644 index 0000000000..fc85e3b41d --- /dev/null +++ b/src/openforms/registrations/contrib/json/typing.py @@ -0,0 +1,9 @@ +from typing import Required, TypedDict + +from zgw_consumers.models import Service + + +class JSONRegistrationOptions(TypedDict): + service : Required[Service] + relative_api_endpoint : str + form_variables: Required[list[str]]