Skip to content

refactor: implement quick wins for code modernization#25

Merged
programmable-banking-community merged 1 commit intomasterfrom
refactor/quick-wins
Mar 24, 2026
Merged

refactor: implement quick wins for code modernization#25
programmable-banking-community merged 1 commit intomasterfrom
refactor/quick-wins

Conversation

@programmable-banking-community
Copy link
Copy Markdown
Collaborator

Overview

This PR implements a set of quick-win refactoring changes to modernize the codebase and improve code quality.

Changes

Ruby Version & Compatibility

  • Updated Ruby requirement from >= 2.3.0 to >= 2.7.0
  • Added base64 dependency for Ruby 3.4+ compatibility

Code Quality

  • Frozen String Literals added to all source files for better performance and immutability
  • Custom Exception Classes created for better error handling:
    • InvestecOpenApi::AuthenticationError for OAuth failures
    • InvestecOpenApi::NotFoundError for missing resources
    • InvestecOpenApi::ValidationError for invalid inputs
    • InvestecOpenApi::APIError for general API errors
    • InvestecOpenApi::RateLimitError for rate limiting scenarios

Error Handling & Validation

  • Improved error messages with contextual information replacing generic exceptions
  • Parameter validation added to all public methods:
    • transactions(account_id, options) validates account_id
    • pending_transactions(account_id, options) validates account_id
    • balance(account_id) validates account_id
    • transfer_multiple(account_id, transfers, profile_id) validates all inputs
    • Transfer#initialize validates all constructor parameters

Documentation

  • Enhanced YARD documentation with @param, @return, and @raise tags
  • Thread-safety warning added to connection caching documentation
  • Improved comments replacing vague comments with proper documentation

Testing

✅ All 20 tests passing

Breaking Changes

None - all changes are backward compatible.

Motivation

The codebase was 2-6 years old and had accumulated technical debt. These improvements modernize the code, improve error handling, and make it more maintainable without major architectural changes.

- Update Ruby version requirement from 2.3.0 to 2.7.0
- Add frozen string literals to all source files
- Create custom exception classes (AuthenticationError, NotFoundError, ValidationError, APIError, RateLimitError)
- Improve error handling with contextual error messages
- Add parameter validation to all public methods
- Enhance documentation with proper YARD comments
- Document thread-safety limitations in connection caching
- Add base64 as runtime dependency for Ruby 3.4+ compatibility
- All tests passing (20/20)
@programmable-banking-community programmable-banking-community merged commit 2867b7d into master Mar 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant