quash-max
quash-max copied to clipboard
Fix #17: Modularize Integration Service
Quash Pull Request
Description
This pull request refactors the createOrUpdateIntegration() method in the IntegrationService to enhance modularity and improve code structure. The refactor breaks down the monolithic method into smaller, more manageable methods, improving readability and maintainability.
Fixes #17
Type of Change
Please check the relevant option(s)
- [x] ๐ Bug fix (non-breaking change addressing an issue)
- [ ] โจ New feature (non-breaking change adding functionality)
- [ ] ๐ฅ Breaking change (fix or feature causing existing functionality to not work as expected)
- [ ] ๐ Documentation update
- [x] ๐งน Code refactor
- [ ] ๐ง Build configuration change
- [ ] โก Performance improvement
- [ ] ๐งช Test update
Component
Please check the relevant option(s)
- [ ] ๐ฑ Android SDK
- [ ] ๐ฅ๏ธ Backend
- [ ] ๐ Frontend
- [ ] ๐ Cross-component change
Changes Made
Extracted Helper Methods:
-
getOrganisationByUser(User user)
: Handles retrieval of the organisation associated with the user, including error handling for cases where the organisation is not found. -
findExistingIntegration(String type, Organisation organisation)
: Searches for any existing integration of the specified type within the given organisation. -
updateExistingIntegration(Integration integration, String type, String accessToken, String refreshToken)
: Updates the settings of an existing integration. -
createNewIntegration(String type, Organisation organisation, String accessToken, String refreshToken)
: Creates a new integration when no matching integration is found.
Simplified Main Method:
-
The
createOrUpdateIntegration()
method is now streamlined and focused on orchestrating the flow, delegating specific tasks to the helper methods. -
Exception handling is centralized and improved for better error messaging.
How Has This Been Tested?
Describe the tests you ran to verify your changes. Provide instructions to reproduce and list any relevant details for your test configuration.
- [ ] Unit tests
- [ ] Integration tests
- [ ] Manual tests
Test Configuration:
- Quash SDK Version:
- Device/Environment:
- OS Version:
- Backend Version (if applicable):
- Frontend Version (if applicable):
Checklist
Please check all applicable items
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in complex areas
- [ ] I have updated the documentation accordingly
- [x] My changes generate no new warnings or errors
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [x] I have checked my code and corrected any misspellings
Additional Notes
Add any other context about the PR here.
Screenshots (if appropriate)
If your changes include visual updates, please add before/after screenshots here.