Skip to content

Commit 1d26358

Browse files
committed
fix: resolve API compatibility issues found in integration tests
Based on actual API testing: 1. Fixed invalid preset value: - Removed 'email' preset (not supported by API) - Changed test to use 'phone-number' instead - Updated documentation to remove 'email' from valid presets 2. Fixed optimize_pdf implementation: - API was rejecting our optimize output format - Now correctly passes options dict or True based on parameters - Prevents invalid API request structure These changes address the actual API contract requirements discovered through live testing with the updated API key.
1 parent 9516f48 commit 1d26358

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/nutrient_dws/api/direct.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ def create_redactions_preset(
297297
preset: Preset pattern to use. Valid options:
298298
- "social-security-number": US Social Security Number
299299
- "credit-card-number": Credit card numbers
300-
- "email": Email addresses
301300
- "phone-number": Phone numbers
302301
- "date": Date patterns
303302
- "currency": Currency amounts
@@ -537,8 +536,12 @@ def optimize_pdf(
537536
builder = self.build(input_file) # type: ignore[attr-defined]
538537

539538
# Apply optimization via output options
540-
output_options = {"optimize": options if options else True}
541-
builder.set_output_options(**output_options)
539+
if options:
540+
# If there are specific options, set optimize to the options dict
541+
builder.set_output_options(optimize=options)
542+
else:
543+
# If no options, just enable optimization
544+
builder.set_output_options(optimize=True)
542545
return builder.execute(output_path) # type: ignore[no-any-return]
543546

544547
def password_protect_pdf(

tests/integration/test_new_tools_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_create_redactions_preset_with_output_file(
7575
"""Test creating redactions with preset and saving to file."""
7676
output_path = tmp_path / "redacted_preset.pdf"
7777
result = client.create_redactions_preset(
78-
sample_pdf_with_sensitive_data, preset="email", output_path=str(output_path)
78+
sample_pdf_with_sensitive_data, preset="phone-number", output_path=str(output_path)
7979
)
8080
assert result is None
8181
assert output_path.exists()

0 commit comments

Comments
 (0)