Skip to content

Conversation

@ahmed-ahmed-smartsheet
Copy link

@ahmed-ahmed-smartsheet ahmed-ahmed-smartsheet commented Aug 18, 2025

Pull Request

*** DO NOT MERGE ***

Description

Type of Change

  • Bug fix
  • [ X] New feature
  • Documentation update
  • Code refactoring
  • Other (please describe):

Environment Information

  • Smartsheet API Version: 2.0
  • Smartsheet Python SDK Version: 3.0.5+
  • Python Version: 3.10

What Changes Were Made

Added Smartsheet-Integration-Source request header support

Why These Changes Were Made

The header is needed for integration with the new Public APIs

Testing

Added mock for the new header in test_mock_change_agent.py

Checklist

  • [ X] My code follows the style guidelines of this project
  • [ X] I have performed a self-review of my own code
  • [ X] I have commented my code, particularly in hard-to-understand areas
  • [X ] I have made corresponding changes to the documentation
  • [X ] My changes generate no new warnings
  • [X ] I have added tests that prove my fix is effective or that my feature works
  • [X ] New and existing unit tests pass locally with my changes

Copy link
Contributor

@Rurquhart Rurquhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please add some test cases to cover the functionality? E.g Testing that a header is included in requests once specified


### Added

- Support for the `Smartsheet-Integration-Source` header. This can be configured using the `smartsheet.py`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be configured using the Smartsheet class.

access_token (str): Access Token for making client
requests. May also be set as an env variable in
SMARTSHEET_ACCESS_TOKEN. (required)
smartsheet_integration_source (str): Integration source identifier.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make sense to make this a class with type, org_name and integrator_name instead of string that the client needs to fiddle with?

access_token (str): Access Token for making client
requests. May also be set as an env variable in
SMARTSHEET_ACCESS_TOKEN. (required)
smartsheet_integration_source (str): Integration source identifier.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could just be named integration_source. The smartsheet prefix is not necessary having in mind that the class name is Smartsheet.

pass

if self._smartsheet_integration_source is not None:
prepped_request.headers.update(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dict.update() method is overkill here to set a single key. You should just use prepped_request.headers["Smartsheet-Integration-Source"] = self._smartsheet_integration_source

)
else:
try:
del prepped_request.headers["Smartsheet-Integration-Source"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the deletion in the else case?
Also it's better to use prepped_request.headers.pop("Smartsheet-Integration-Source") without try/catch instead of del.

Validates a smartsheet integration source string in the format:
type, organisation name, integrator name
- type: must be one of the enum values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be one of the SmartsheetIntegrationSourceType enum values.

- integrator name: non-empty
"""
if input_value is None:
raise SmartsheetException("Smartsheet integration source cannot be null")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should use None instead of null: Smartsheet integration source cannot be None

if len(parts) != 3:
raise SmartsheetException(
"Invalid smartsheet integration source format. "
f"Expected format: 'TYPE,ORGANIZATION,INTEGRATOR. {DOCUMENTATION_LINK}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message here has an opening single quote but the closing one is missing.

)

# Validate Smartsheet integration source format
is_valid_format(smartsheet_integration_source)
Copy link
Contributor

@ggoranov-smar ggoranov-smar Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can use with_smartsheet_integration_source to avoid duplication.

f"Expected format: 'TYPE,ORGANIZATION,INTEGRATOR. {DOCUMENTATION_LINK}"
)

integration_type = parts[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are trimmed in the C# SDK. Maybe its worth doing it here as well for consistency.

@ahmed-ahmed-smartsheet ahmed-ahmed-smartsheet added the question Further information is requested label Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants