From e5fd59537a853d0861c1e2342478e6a53da1aaf8 Mon Sep 17 00:00:00 2001 From: blueink-bot Date: Fri, 13 Mar 2026 20:03:52 +0000 Subject: [PATCH] chore: sync internal main (5021ad5) --- src/blueink/bundle_helper.py | 12 ++++++ src/blueink/model/bundles.py | 3 ++ src/blueink/tests/test_bundle_helper.py | 54 +++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/src/blueink/bundle_helper.py b/src/blueink/bundle_helper.py index 75cf235..0e720c2 100644 --- a/src/blueink/bundle_helper.py +++ b/src/blueink/bundle_helper.py @@ -28,6 +28,7 @@ def __init__( is_test: bool = False, custom_key: str = None, team: str = None, + signing_brand: str = None, ): """Helper class to aid building a Bundle. @@ -41,6 +42,7 @@ def __init__( is_test: custom_key: team: + signing_brand: """ self._label = label self._in_order = in_order @@ -52,6 +54,7 @@ def __init__( self._packets = {} self._custom_key = custom_key self._team = team + self._signing_brand = signing_brand self._envelope_template = None # for file uploads, index should match those in the document "file_index" field @@ -209,6 +212,7 @@ def add_field( v_pattern: str = None, v_min: int = None, v_max: int = None, + v_attachment_types: List[str] = None, key=None, **additional_data, ): @@ -226,6 +230,7 @@ def add_field( v_pattern: Optional v_min: Optional v_max: Optional + v_attachment_types: Optional list of allowed attachment file extensions (only for kind='att') editors: Optional key: Optional additional_data: Optional and will append any additional kwargs to the json of the field @@ -247,6 +252,7 @@ def add_field( v_pattern=v_pattern, v_min=v_min, v_max=v_max, + v_attachment_types=v_attachment_types, key=key, **additional_data, ) @@ -267,6 +273,7 @@ def add_auto_placement( offset_y: int = 0, editors: List[str] = None, page: int = None, + v_attachment_types: List[str] = None, **additional_data, ): """Add an auto-placement field to a document. @@ -284,6 +291,7 @@ def add_auto_placement( offset_y: Vertical offset from the search text (default: 0) editors: List of signer keys who can edit this field page: Optional page number to limit search to + v_attachment_types: Optional list of allowed attachment file extensions (only for kind='att') additional_data: Optional additional kwargs to append to the auto-placement Returns: @@ -313,6 +321,7 @@ def add_auto_placement( offset_x=offset_x, offset_y=offset_y, page=page, + v_attachment_types=v_attachment_types, **additional_data, ) @@ -496,6 +505,7 @@ def _compile_bundle(self, **additional_data) -> Bundle: cc_emails=self._cc_emails, custom_key=self._custom_key, team=self._team, + signing_brand=self._signing_brand, **additional_data, ) return bundle_out @@ -561,6 +571,8 @@ def as_data_for_envelope_template(self, **additional_data): result["custom_key"] = self._custom_key if self._team: result["team"] = self._team + if self._signing_brand: + result["signing_brand"] = self._signing_brand # Add any additional data result.update(additional_data) diff --git a/src/blueink/model/bundles.py b/src/blueink/model/bundles.py index 177f21e..9a11659 100644 --- a/src/blueink/model/bundles.py +++ b/src/blueink/model/bundles.py @@ -28,6 +28,7 @@ class AutoPlacement(BaseModel): offset_y: Optional[int] = 0 editors: Optional[List[str]] page: Optional[int] + v_attachment_types: Optional[List[str]] class Config: extra = "allow" @@ -94,6 +95,7 @@ class Field(BaseModel): v_min: Optional[int] v_max: Optional[int] editors: Optional[List[str]] + v_attachment_types: Optional[List[str]] class Config: extra = "allow" @@ -292,6 +294,7 @@ class Bundle(BaseModel): is_test: Optional[bool] custom_key: Optional[str] team: Optional[str] + signing_brand: Optional[str] class Config: extra = "allow" diff --git a/src/blueink/tests/test_bundle_helper.py b/src/blueink/tests/test_bundle_helper.py index 0eaa9c7..c5d6700 100644 --- a/src/blueink/tests/test_bundle_helper.py +++ b/src/blueink/tests/test_bundle_helper.py @@ -316,3 +316,57 @@ def test_auto_placement_with_page_restriction(self): auto_placement = compiled_bundle["documents"][0]["auto_placements"][0] self.assert_equal(auto_placement["page"], 2) + + def test_auto_placement_with_attachment_types(self): + """Test auto-placement with v_attachment_types restriction""" + input_data = copy.deepcopy(self.BUNDLE_INIT_DATA) + url01 = self.DOCUMENT_01_URL + signer01_data = copy.deepcopy(self.SIGNER_01_DATA) + + bh = BundleHelper(**input_data) + doc01_key = bh.add_document_by_url(url01) + signer01_key = bh.add_signer(**signer01_data) + + bh.add_auto_placement( + document_key=doc01_key, + kind="att", + search="Upload your document", + w=20, + h=5, + v_attachment_types=["pdf", "png"], + editors=[signer01_key], + ) + + compiled_bundle = bh.as_data() + auto_placement = compiled_bundle["documents"][0]["auto_placements"][0] + + self.assert_equal(auto_placement["kind"], "att") + self.assert_equal(auto_placement["v_attachment_types"], ["pdf", "png"]) + + def test_field_with_attachment_types(self): + """Test adding a field with v_attachment_types""" + input_data = copy.deepcopy(self.BUNDLE_INIT_DATA) + url01 = self.DOCUMENT_01_URL + signer01_data = copy.deepcopy(self.SIGNER_01_DATA) + + bh = BundleHelper(**input_data) + doc01_key = bh.add_document_by_url(url01) + signer01_key = bh.add_signer(**signer01_data) + + bh.add_field( + document_key=doc01_key, + x=10, + y=20, + w=30, + h=10, + p=1, + kind="att", + editors=[signer01_key], + v_attachment_types=["pdf", "docx"], + ) + + compiled_bundle = bh.as_data() + field = compiled_bundle["documents"][0]["fields"][0] + + self.assert_equal(field["kind"], "att") + self.assert_equal(field["v_attachment_types"], ["pdf", "docx"])