Skip to content

Commit 747705b

Browse files
resolved review comments
1 parent db05f22 commit 747705b

8 files changed

Lines changed: 21 additions & 57 deletions

File tree

src/sap_cloud_sdk/outputmanagement/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .models.form_configuration import FormConfiguration
2121
from .clients.email_client import EmailClient
2222
from .config.destination_credential_config import DestinationCredentialConfig
23-
from .constants import FileFormat, Channel, Status
23+
from .constants import FileFormat, Channel
2424
from .exceptions import (
2525
OutputManagementException,
2626
AuthenticationException,
@@ -54,7 +54,6 @@
5454
# Constants/Enums
5555
"FileFormat",
5656
"Channel",
57-
"Status",
5857
# Exceptions
5958
"OutputManagementException",
6059
"AuthenticationException",

src/sap_cloud_sdk/outputmanagement/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import logging
44
import requests
55
from abc import ABC, abstractmethod
6+
from typing import Optional
67

8+
from sap_cloud_sdk.destination import Destination
79
from .clients.output_requests_client import OutputRequestsClient
810
from .clients.output_requests_client_impl import OutputRequestsClientImpl
911

@@ -35,8 +37,8 @@ class OutputManagementServiceDefaultClient(OutputManagementServiceClient):
3537
def __init__(
3638
self,
3739
base_url: str,
38-
destination: any = None,
39-
destination_instance: str = None,
40+
destination: Optional[Destination] = None,
41+
destination_instance: Optional[str] = None,
4042
):
4143
"""Initialize client.
4244

src/sap_cloud_sdk/outputmanagement/client_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def build(self) -> OutputManagementServiceClientProvider:
7474
# Get the destination object - it handles authentication automatically
7575
http_destination = self._destination_credential_config.get_destination()
7676

77-
# Get the base URL from destinatiozxn
77+
# Get the base URL from destination
7878
base_url = self._destination_credential_config.get_base_url()
7979
logger.info(f"Retrieved destination base URL: {base_url}")
8080

src/sap_cloud_sdk/outputmanagement/clients/email_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_output_request(
2525
to: List[str],
2626
business_document: Dict[str, Any],
2727
cc: Optional[List[str]] = None,
28-
template_language: str = "en",
28+
template_language: Optional[str] = "en",
2929
attachment_urls: Optional[List[str]] = None
3030
) -> OutputRequest:
3131
"""
@@ -121,8 +121,8 @@ def send_email(
121121
business_document: Dict[str, Any],
122122
destination_name: str,
123123
cc: Optional[List[str]] = None,
124-
template_language: str = "en",
125-
access_strategy: str = "PROVIDER_ONLY",
124+
template_language: Optional[str] = "en",
125+
access_strategy: Optional[str] = None,
126126
instance: Optional[str] = None,
127127
attachment_urls: Optional[List[str]] = None
128128
) -> OutputResponse:
@@ -139,7 +139,7 @@ def send_email(
139139
destination_name: Name of the destination for authentication and endpoint
140140
cc: Optional list of CC email addresses
141141
template_language: ISO language code for email template (default: "en")
142-
access_strategy: Destination access strategy - "PROVIDER_ONLY" or "SUBSCRIBER_ONLY" (default: "PROVIDER_ONLY")
142+
access_strategy: Destination access strategy - "PROVIDER_ONLY" or "SUBSCRIBER_ONLY" (defaults to "PROVIDER_ONLY" if not specified)
143143
instance: Destination service instance name (defaults to "default" if not provided)
144144
attachment_urls: Optional list of DMS URLs for pre-generated attachments (default: None)
145145

src/sap_cloud_sdk/outputmanagement/clients/output_requests_client_impl.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
"""Implementation of output requests client."""
22

33
import logging
4-
from typing import Dict, Optional
54
import os
6-
import json
75
import uuid
6+
from typing import Dict, Optional
7+
88
import requests
9+
from sap_cloud_sdk.destination import Destination
910

1011
from .output_requests_client import OutputRequestsClient
12+
from ..constants import Constants
1113
from ..models.output_request import OutputRequest
1214
from ..models.output_response import (
1315
OutputResponse,
1416
)
15-
from ..constants import Constants
1617
from ..utils.request_validator import RequestValidator
1718

1819
logger = logging.getLogger(__name__)
@@ -30,8 +31,8 @@ def __init__(
3031
self,
3132
http_session: requests.Session,
3233
base_url: str,
33-
destination: any = None,
34-
destination_instance: str = None,
34+
destination: Optional[Destination] = None,
35+
destination_instance: Optional[str] = None,
3536
):
3637
"""
3738
Constructs a new OutputRequestsClientImpl.
@@ -88,9 +89,8 @@ def send_output_request(self, output_request: OutputRequest) -> OutputResponse:
8889

8990
try:
9091
request_body = output_request.model_dump(by_alias=True, exclude_none=True)
91-
logger.info(f"Request body: {request_body}")
9292

93-
response = self._execute_request('POST', endpoint, json=request_body, headers=headers)
93+
response = self._http_session.request('POST', endpoint, json=request_body, headers=headers)
9494
status_code = response.status_code
9595

9696
logger.debug(f"Response status: {status_code}")
@@ -327,20 +327,6 @@ def _fetch_oauth_token_from_destination(self) -> Optional[str]:
327327

328328
return None
329329

330-
def _execute_request(self, method: str, endpoint: str, **kwargs):
331-
"""Execute HTTP request using destination if available, otherwise use session.
332-
333-
Args:
334-
method: HTTP method (GET, POST, etc.)
335-
endpoint: Full endpoint URL
336-
**kwargs: Additional arguments to pass to the request
337-
338-
Returns:
339-
Response object
340-
"""
341-
# Always use regular session - authentication is handled in _get_headers
342-
return self._http_session.request(method, endpoint, **kwargs)
343-
344330
def _get_headers(self) -> Dict[str, str]:
345331
"""Get request headers with authentication."""
346332
headers = {}

src/sap_cloud_sdk/outputmanagement/constants.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class Constants:
1010
API_OUTPUT_CONTROL = "/api/output-control-api/v1/"
1111

1212
# Headers
13-
CONTENT_TYPE = "Content-Type"
14-
APPLICATION_JSON = "application/json"
1513
AUTHORIZATION = "Authorization"
1614
BEARER = "Bearer"
1715
HEADER_CONTENT_TYPE = "Content-Type"
@@ -22,16 +20,6 @@ class Constants:
2220
CONTENT_TYPE_PDF = "application/pdf"
2321

2422

25-
class Status(Enum):
26-
"""Output request status."""
27-
28-
PENDING = "PENDING"
29-
IN_PROGRESS = "IN_PROGRESS"
30-
COMPLETED = "COMPLETED"
31-
FAILED = "FAILED"
32-
CANCELLED = "CANCELLED"
33-
34-
3523
class FileFormat(Enum):
3624
"""Supported file formats."""
3725

tests/outputmanagement/unit/test_basic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ def test_constants_import(self):
3030
Constants,
3131
FileFormat,
3232
Channel,
33-
Status,
3433
)
3534
assert Constants.API_OUTPUT_CONTROL is not None
3635
assert FileFormat.PDF is not None
3736
assert Channel.EMAIL is not None
38-
assert Status.PENDING is not None
3937

4038
def test_exceptions_import(self):
4139
"""Test that exceptions can be imported."""

tests/outputmanagement/unit/test_constants.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
Constants,
1010
FileFormat,
1111
Channel,
12-
Status,
1312
)
1413

1514

@@ -28,15 +27,15 @@ def test_api_output_control_starts_with_slash(self):
2827

2928
def test_header_constants_exist(self):
3029
"""Test that header constants exist."""
31-
assert Constants.CONTENT_TYPE is not None
32-
assert Constants.APPLICATION_JSON is not None
30+
assert Constants.HEADER_CONTENT_TYPE is not None
31+
assert Constants.CONTENT_TYPE_JSON is not None
3332
assert Constants.AUTHORIZATION is not None
3433
assert Constants.BEARER is not None
3534

3635
def test_header_constants_are_strings(self):
3736
"""Test that header constants are strings."""
38-
assert isinstance(Constants.CONTENT_TYPE, str)
39-
assert isinstance(Constants.APPLICATION_JSON, str)
37+
assert isinstance(Constants.HEADER_CONTENT_TYPE, str)
38+
assert isinstance(Constants.CONTENT_TYPE_JSON, str)
4039
assert isinstance(Constants.AUTHORIZATION, str)
4140
assert isinstance(Constants.BEARER, str)
4241

@@ -58,11 +57,3 @@ def test_channel_enum(self):
5857
assert Channel.INTERNAL_EMAIL.value == "INTERNAL_EMAIL"
5958
assert Channel.DIRECT_SHARE.value == "DIRECT_SHARE"
6059
assert Channel.FORM.value == "FORM"
61-
62-
def test_status_enum(self):
63-
"""Test Status enum."""
64-
assert Status.PENDING.value == "PENDING"
65-
assert Status.IN_PROGRESS.value == "IN_PROGRESS"
66-
assert Status.COMPLETED.value == "COMPLETED"
67-
assert Status.FAILED.value == "FAILED"
68-
assert Status.CANCELLED.value == "CANCELLED"

0 commit comments

Comments
 (0)