-
Notifications
You must be signed in to change notification settings - Fork 37
Added support for Smartsheet-Integration-Source #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mainline
Are you sure you want to change the base?
Added support for Smartsheet-Integration-Source #75
Conversation
Rurquhart
left a comment
There was a problem hiding this 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`. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
Pull Request
*** DO NOT MERGE ***
Description
Type of Change
Environment Information
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