Skip to content

Commit

Permalink
🏷️ [#4908] Add typing hints for json registration options
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvanwijk committed Dec 20, 2024
1 parent 9525728 commit 4ed04a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/openforms/registrations/contrib/json/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
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")
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'?

Expand Down Expand Up @@ -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={},
# ),
Expand Down
9 changes: 9 additions & 0 deletions src/openforms/registrations/contrib/json/typing.py
Original file line number Diff line number Diff line change
@@ -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]]

0 comments on commit 4ed04a4

Please sign in to comment.