PandaDoc / pandadoc-api-python-client

The Official PandaDoc Python client SDK
https://developers.pandadoc.com/reference/about
MIT License
19 stars 4 forks source link

Error raised when sending document if "expiration_date" is None, using SDK. #28

Closed Dhruv-Aubie closed 4 months ago

Dhruv-Aubie commented 5 months ago

When using the SDK to send documents, an error is raised if "expiration_date" is None. This does not occur when using the requests library.

Example with SDK:

import pandadoc_client
from pandadoc_client.api import documents_api
from pandadoc_client.model.document_send_request import DocumentSendRequest

API_KEY = ""
DOCUMENT_ID = ""

cfg = pandadoc_client.Configuration(
    api_key={"apiKey": f"API-Key {API_KEY}"}"},
)
client = pandadoc_client.ApiClient(cfg)
documents_instance = documents_api.DocumentsApi(client)

document_send_request = DocumentSendRequest(silent=False, subject="This doc was sent via python SDK")
documents_instance.send_document(DOCUMENT_ID, document_send_request=document_send_request)

Raises:

pandadoc_client.exceptions.ApiTypeError: Invalid type for variable 'expiration_date'. Required value type is str and passed type was NoneType at ['received_data']['expiration_date']

Example with GET:

import requests

API_KEY = ""
DOCUMENT_ID = ""    # same template as the previous example

headers = {
    "Content-Type": "application/json",
    "Authorization": f"API-Key {API_KEY}"
}

url = "https://api.pandadoc.com/" + f"public/v1/documents/{DOCUMENT_ID}/send"
res = requests.get(url, headers=headers)
document_sent_response_dict = res.json()

Impact:

Because of this library behavior, I can't implement the feature of sending the document to the set of recipients defined during its creation using the SDK. Even though they receive the document, the method throws the below error:

{
    "message": "An unexpected error occurred.",
    "errors": "Invalid type for variable 'expiration_date'. Required value type is str and passed type was NoneType at ['received_data']['expiration_date']"
}

Steps to Reproduce:

  1. Set up the PandaDoc Python SDK using the API key and document ID.
  2. Create a document using a reference template with a set of recipients and send it with "expiration_date" as None, as it can't be set using the SDK.
  3. Observe the error raised by the SDK.

Expected Behavior:

The SDK should handle None values for fields that might be unknown or optional, similar to the behavior when using the requests library.

Actual Behavior:

The SDK raises an error when encountering None values for "expiration_date".

Environment: