Skip to content

Commit

Permalink
Adding form metadata endpoint support to uils (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumesh-aot authored Mar 12, 2024
1 parent 3bfd396 commit 302a703
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""This exposes the Formio APIs."""
import json
from http import HTTPStatus
from typing import List

import jwt
import requests
from flask import current_app

from formsflow_api_utils.exceptions import BusinessException
from formsflow_api_utils.utils import Cache
from formsflow_api_utils.exceptions import ExternalError
from formsflow_api_utils.utils import Cache


class FormioService:
Expand Down Expand Up @@ -115,6 +115,14 @@ def get_form_by_id(self, form_id: str, formio_token):
url = f"{self.base_url}/form/{form_id}"
return self._invoke_service(url, headers, method='GET')

def get_form_metadata(self, form_id: str, formio_token, is_bundle: bool = False, bundled_ids: List[str] = []):
"""Get form metadata using the custom endpoint in form.io."""
headers = {"Content-Type": "application/json", "x-jwt-token": formio_token}
url = f"{self.base_url}/form/{form_id}/metadata"
if is_bundle:
url = f"{url}?isBundle=true&formIds={','.join(bundled_ids)}"
return self._invoke_service(url, headers, method='GET')

def get_submission(self, data, formio_token):
"""Get request to formio API to get submission details."""
headers = {"Content-Type": "application/json", "x-jwt-token": formio_token}
Expand Down

0 comments on commit 302a703

Please sign in to comment.