Skip to content
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

V2: Major Enhancements and Refactoring #10

Merged
merged 20 commits into from
Dec 16, 2024
Merged

V2: Major Enhancements and Refactoring #10

merged 20 commits into from
Dec 16, 2024

Conversation

Douglasokolaa
Copy link
Owner

@Douglasokolaa Douglasokolaa commented Dec 16, 2024

This pull request merges the v2 branch into develop, incorporating a series of significant updates, performance improvements, and codebase enhancements. These changes align with the longer-term goal of creating a robust, modular, and maintainable SDK, ensuring seamless integration with Termii's API.

Highlights of Changes in v2

1. New Features

  • Insight API Support
    Added new endpoints for the Insight API, including:

    • Balance retrieval.
    • Phone number status check.
    • DND (Do Not Disturb) checks.
    • Message history retrieval.
      Accompanied by corresponding tests and resources for smoother usage.
  • Token API for OTP Workflows
    Implemented endpoints for generating, sending, and verifying OTPs across multiple channels including:

    • SMS, voice, email, and in-app.
      Enhanced with test cases and documentation updates.
  • Custom RequestException Class
    Introduced a new TermiiRequestException to replace Saloon's base exceptions. This improves exception handling by centralizing and streamlining error management.

  • Troubleshooting Support
    Added initial debugging and troubleshooting capabilities to help developers resolve integration issues quickly.

2. Codebase Refactoring and Optimization

  • Consolidated requests into Endpoint Classes for improved clarity and maintainability, aligning with a more modular architecture.
  • Refactored the Termii class to follow the Singleton Pattern for managing TermiiConnector initialization, reducing redundancy and improving resource handling.
  • Introduced a new ConvertsDtoToRequestArray interface, implemented across relevant DTOs for consistency in request array conversion.

3. Coding Standards and Quality

  • Applied PHP-CS-Fixer for consistent code formatting and adherence to modern standards.
  • Introduced PHPStan configuration for static analysis, enhancing code quality and reliability.

4. Testing Improvements

  • Added tests for new APIs and refactored existing test cases, especially around updated resources like CampaignApiTest.
  • Integrated a GitHub Actions workflow for automated testing (ci(tests)), ensuring better CI/CD coverage.

5. Documentation Updates

  • Revised the README to include updated examples of using various APIs (Messaging, Campaigns, Phonebook, Contact Management, etc.).
  • Added instructions for new features and clarified the usage of updated SDK functionalities.

Breaking Changes

  • Code restructuring (e.g., endpoint consolidations, new exceptions) will impact downstream projects by requiring updates to match the latest architecture.

Benefits of the Merge

  • Improved Modularity: More streamlined and reusable code components.
  • Enhanced Testing and Quality: Improved reliability via stricter testing and static analysis.
  • Robust Features: Full implementation of Termii APIs (Insight and Token), broadening the SDK’s utility.
  • Developer Experience: Consistent exception handling and better documentation for easier onboarding.

Checklist

  • Code reviewed and approved.
  • Coverage verified via unit and integration tests.
  • CI workflows validated.
  • Final tests on critical paths.

Additional Notes

  • Ensure all updated workflows function correctly in the develop branch after merging.

…tecture

This commit significantly refactors the Termii PHP library by removing outdated files and dependencies. It introduces new resource structures, including MessagingResource, SenderIdResource, and CampaignResource, for improved organization and functionality. The Termii class has been updated to integrate these resources, offering a more modular and maintainable architecture for interacting with Termii's API.

Signed-off-by: Douglas Okolaa <[email protected]>
The requests from various parts of the application have been consolidated and refactored into endpoint classes for greater clarity and organization. This change improves maintainability by centralizing request logic, aligning with a more streamlined architecture. Existing requests have been removed or replaced with their endpoint equivalents to ensure consistency across the codebase.

Signed-off-by: Douglas Okolaa <[email protected]>
The Termii class now uses a singleton pattern for TermiiConnector initialization, simplifying resource management and avoiding redundant connections. In CampaignResource, the phoneBook method is optimized by implementing lazy initialization for PhonebookResource, ensuring efficient resource use.

Signed-off-by: Douglas Okolaa <[email protected]>
Corrected return types in factory methods to match class names, replaced a dangling static instance with direct instantiation, and removed a debug statement. Additionally, a phpstan configuration file was added to enhance code quality checks, and the phpstan dependency was included in composer.json. These changes aim to improve code reliability and maintainability.
…coverage

Modified endpoints in Campaign and adjusted class properties for flexibility. The changes improve data handling, such as making certain fields optional, adding new multipart data structure, and refining API key handling in requests. Updated endpoint paths as part of a broader API alignment effort.
Introduced the `ConvertsDtoToRequestArray` interface and implemented it across relevant DTO classes for enhanced request array conversion. This improves data handling consistency and streamlines request building processes.
Enhanced the README with updated code examples for message sending, campaigns, phonebook, and contact management. Improved clarity by restructuring snippets for better usability and understanding. These changes align with the current TermiiPHP SDK functionality.
Added support for generating, sending, and verifying OTPs via voice call, email, in-app, and SMS channels. Introduced relevant resources, endpoints, and tests to ensure functionality and improve API integration. This update enhances the library's utility for handling OTP workflows.
Enhanced the README with updated code examples for message sending, campaigns, phonebook, and contact management. Improved clarity by restructuring snippets for better usability and understanding. These changes align with the current TermiiPHP SDK functionality.
Added `.php-cs-fixer.php` configuration to enforce a consistent code style across the project.
Aligned indentation, spacing, and method declaration formatting using PHP-CS-Fixer rules.

BREAKING CHANGE: Codebase formatting changes can result in merge conflicts or affect existing pull requests.
Introduced Insight API endpoints including balance retrieval, phone number status, DND check, and message history. Added corresponding test cases, fixtures, and updated resources for seamless integration.
Introduce a new custom `RequestException` to replace Saloon's base exceptions. This ensures consistent exception handling across the codebase and improves modularity by centralizing exception management.
@Douglasokolaa Douglasokolaa marked this pull request as ready for review December 16, 2024 01:22
@Douglasokolaa Douglasokolaa merged commit 9222c6c into develop Dec 16, 2024
11 checks passed
@Douglasokolaa Douglasokolaa deleted the v2 branch December 16, 2024 01:28
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