Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a utility method for URL-encoding path segments to ensure safe inclusion in URLs and updates various API endpoint calls to use this method. It also adds comprehensive unit tests for the new method. The most important changes are grouped below by theme.
Core Functionality
encode_path_segmentas a static method inAbstractManagerto URL-encode path segments, ensuring safe inclusion in API endpoint URLs. This method usesurllib.parse.quotewithsafe=""to encode all unsafe characters. (src/multisafepay/api/base/abstract_manager.py)API Endpoint Updates
capture_manager.py,gateway_manager.py,issuer_manager.py,order_manager.py,payment_method_manager.py,recurring_manager.py) to use the newencode_path_segmentmethod for encoding path parameters such asorder_id,gateway_code, andreference. This ensures consistent and safe URL construction. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Unit Testing
encode_path_segmentin a new test file,test_abstract_manager.py. The tests cover various input scenarios, including strings with special characters, spaces, Unicode, empty strings, numbers, and reserved characters, ensuring robust validation of the method's behavior. (tests/multisafepay/unit/api/base/test_abstract_manager.py)These changes enhance the safety and reliability of URL construction in the API, preventing potential issues with improperly encoded path parameters.