quash-max icon indicating copy to clipboard operation
quash-max copied to clipboard

Fix #17: Modularize Integration Service

Open JishnuGoyal opened this issue 10 months ago โ€ข 2 comments

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.

JishnuGoyal avatar Sep 01 '24 18:09 JishnuGoyal