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

refactor app contracts and add documentation for use cases #398

Conversation

mesilov
Copy link
Owner

@mesilov mesilov commented Jul 2, 2024

Deleted the Bitrix24Account contracts: Bitrix24AccountInterface, Bitrix24AccountRepositoryInterface, and Bitrix24AccountStatus. This is part of a broader refactor of the Bitrix24\SDK\Application\Contracts as noted in the changelog.

Deleted the Bitrix24Account contracts: Bitrix24AccountInterface, Bitrix24AccountRepositoryInterface, and Bitrix24AccountStatus. This is part of a broader refactor of the Bitrix24\SDK\Application\Contracts as noted in the changelog.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
@mesilov mesilov linked an issue Jul 2, 2024 that may be closed by this pull request
4 tasks
Added two new PHP classes under the directory src/Application/Contracts/Bitrix24Accounts/Entity. `Bitrix24AccountInterface` provides an interface for handling Bitrix24 account related operations. `Bitrix24AccountStatus` is an enumeration that defines possible statuses for a Bitrix24 account.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The commit involves the deletion of several redundant files related to the documentation of the project. The files were scattered across different sections like Core, Results, Events, and Application. They consisted of guidelines for adding new functionality, usage of different features, and instructions for tasks like Authorization on the portal. These files were not serving any purpose and cluttering the repository, hence removed.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…x24AccountInterface

A new file, Bitrix24AccountRepositoryInterface, has been created which defines the methods to interact with Bitrix24 account data in a data store. Additionally, the Bitrix24AccountInterface has been updated to throw an InvalidArgumentException where needed to make error handling more explicit and robust.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The AccessToken class has been renamed to AuthToken. This was accompanied by the renaming and modification of related methods, variables, and usages across multiple files. A new file was created, RenewedAuthToken.php, while the old RenewedAccessToken.php was deleted. WebhookUrl usage has also been adjusted.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This commit adjusts various import paths in the ServiceBuilderFactory class and updates the corresponding references in the code. The AccessToken import and references have been changed to AuthToken. The Bitrix24AccountInterface has been moved to another directory and the changes have been reflected. Certain use statements for exceptions have also been added.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The AccessToken class has been replaced with the AuthToken class across several modules. This includes changes in method arguments, object initializations, and class properties. The goal is to maintain consistency throughout the application by using the newly introduced AuthToken class.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The code changes replace the usage of AccessToken with AuthToken in the Core and Credentials test files. The AccessToken class is replaced globally with the AuthToken class to reflect changes or improvements in the authorization process.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The authToken parameters in the Core classes 'RenewedAuthToken' and 'Credentials' have been refactored. In 'RenewedAuthToken', unnecessary authToken and applicationStatus parameters were removed. In 'Credentials', variable name 'accessToken' was changed to 'authToken' for consistency and clarity.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
A new file containing a test implementation of the Bitrix24AccountInterface has been added, which includes methods for checking user status, managing authentication tokens, updating domain URL, and handling application installation and upgrade cases. The created tests help ensure the functionality and reliability of the system with Bitrix24Accounts.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
@mesilov mesilov changed the title Remove Bitrix24Account contracts refactor app contracts and add documentation for use cases Jul 4, 2024
mesilov added 18 commits July 6, 2024 09:07
Renamed the testing and reference implementation classes of Bitrix24AccountInterface and adjusted the methods due to changes in their behavior. Also added new methods for ApplicationStatus testing. This refactoring is important to ensure accurate testing and representation of our Bitrix24Accounts and their statuses.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The test method in ApplicationStatusTest.php has been updated from checking if the application status is local to checking if it is a subscription. This change will ensure that the unit tests are accurately reflecting the application's subscription status.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The commit includes the addition of a sorting step in the Scope constructor that ensures that the order of scope values is consistent. Also, a new method 'equal' has been added to compare if two scope instances are equal based on their values.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Added test case 'testEqual' to enhance the coverage of code in ScopeTest. Simplified the occurrences of UnknownScopeCodeException in all test cases, and corrected the order of scope codes inside the 'testInitFromString' test case.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This update adds more unit tests to validate application behavior. Particularly, tests for methods like 'isApplicationTokenValid', 'getCreatedAt', and 'getUpdatedAt' have been included. Also, the account status change from 'active' to 'blocked' has been corrected.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This commit updates all test cases to use native PHP8 attribute syntax instead of comments for PHPUnit annotations. The method visibility has also been adjusted to be compliant with the PHPUnit v9. Additionally, multiple unnecessary comment blocks have been removed from the source codes for better readability. All changes have been made across various classes and test cases.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The AccessToken and related classes and interfaces have been replaced with AuthToken and relevant entities across the SDK tests. The main aim was to unify the nomenclature and make it more expressive and intuitive. For instance, the AccessTokenFileStorage has been renamed to AuthTokenFileStorage, and methods and variables have been renamed accordingly.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
An interface AuthTokenRepositoryInterface has been added under the ApplicationBridge in tests. At the same time, an unnecessary use statement, AccessTokenFileStorage, has been removed from Fabric.php in Integration tests.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Created a new documentation file for the Bitrix24Accounts in the Application Contracts. This documentation includes an account state diagram and a detailed breakdown of repository methods. Each method is explained with its associated use cases to aid in understanding and implementation.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Created a new documentation file for the Bitrix24Accounts in the Application Contracts. This documentation includes an account state diagram and a detailed breakdown of repository methods. Each method is explained with its associated use cases to aid in understanding and implementation.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This commit expands the Bitrix24AccountRepositoryInterface with new methods for handling Bitrix24 accounts. It includes methods for saving and deleting Bitrix24 accounts, and for fetching accounts by id or specific characteristics. This update provides enhanced functionality to interact with Bitrix24 account data, from basic CRUD operations to more granular lookups based on account status and attributes.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The documentation for Bitrix24Accounts has been revised. A summary line has been added to better provide context and understandability to its content. It now contains a clear brief about storing auth tokens and methods for working with a Bitrix24 account.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Added new entities for "FullName" and "ContactPersonStatus", alongside an interface for "ContactPerson" under the Contracts namespace. Also, sample entity implementation has been added for testing purposes only. Dependencies in composer.json have also been updated to include necessary libraries and tools for these new implementations.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Expanded the DemoDataGenerator class to improve test data variety. Added additional methods to generate random but realistic data. Created a new ContactPerson entity method for marking a user as deleted, enhancing the functionality for manipulations with user status. Updated corresponding tests to cover new features.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This commit introduces the InMemoryContactPersonRepositoryImplementation class, which provides an in-memory implementation of the ContactPersonRepositoryInterface. It also includes associated unit test cases to ensure that the implementation behaves as expected. This mainly assists developers in the process of testing without needing a real database.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Updated method calls in InfoCall tests to use `getNationalNumber()` from `DemoDataGenerator::getMobilePhone()`. This change ensures we're passing the correct format of mobile phone number to `startWithText` and `startWithSound` methods.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
A variety of changes have been made across several files to enhance readability and optimize semantics. This includes implementing the Stringable interface in the FullName class and cleaning up variable names to be more descriptive. Additionally, unnecessary comments have been removed and elements in the Scope class are now transformed to lowercase in a more concise way.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This commit refactors several variable names across multiple methods in the codebase to increase readability. Changes include renaming "item" to "contactPerson", "userRepository" to "userRepo", "mobilePhone" to "phoneNumber" among others. The objective is to ensure that the names are meaningful and accurately reflect their purpose within the code.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The method findByExternalId within the ContactPersonRepository has been expanded to account for various scenarios. It now checks for empty ExternalId input and returns an array, instead of a single output, because a contact person can have multiple installations across different portals. Associated tests have been added or updated accordingly.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Updated variable names in various telephony test files for a better understanding of the return value being reflected. The new names specifically indicate the action taken and the result received, making the purpose of each test step clearer. This change upholds the quality of the codebase by promoting readability and maintainability.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
A line to ignore PHPStan analysis was added to the `findByExternalId('')` method call in the `ContactPersonRepositoryInterfaceTest.php` test. This annotative change helps to suppress the PHPStan error that's triggered by this particular line of testing code.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
The settings for failOnRisky and failOnWarning within PHPUnit configurations have been updated from true to false. This change allows tests to continue running even if there are risks or warnings, giving the opportunity to see a comprehensive list of all issues rather than stopping at the first one encountered.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Test file renaming and reorganizing has been done to streamline namespaces. Additionally, the phpunit configuration has been updated to fail on risky tests. Unused imports have also been removed from various test files, improving code readability.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Created new event classes for the ContactPerson entity in the Application Contracts layer, aimed to deal with various situations such as contact creation, block, unblock, or deletion. Also included is the full documentation file describing ContactPerson's methods, states, repository methods, and events.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
This update adds an application installation interface for setting up interactions between the application and the Bitrix24 API. A Bitrix24 user ID field is also added to the contact person interface. This modification extends the functionality of the contact person, enabling more advanced data tracking. The new ID field maps a Bitrix24 user with a contact person, if there is any association.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Implemented detailed application installation status management in the `ApplicationInstallationInterface` with corresponding methods. Introduced `ApplicationInstallationStatus` enum to define possible states. Included updates to contact person handling and external ID management.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Introduced the ability to set and get the Bitrix24 partner ID for contact persons. Updated tests and documentation to support this new functionality, ensuring comprehensive test coverage and proper documentation.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Extended the ContactPerson entities and their respective tests to include the bitrix24PartnerId/UUid field. This change ensures that we can store and retrieve Bitrix24 partner UUIDs for contact persons, enhancing our data handling capabilities.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Implemented ApplicationInstallationReferenceEntityImplementation for testing ApplicationInstallationInterface. Updated ApplicationInstallationInterface with new methods for managing portal license family and users count. Added tests to validate the new implementation and methods.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Introduce validation logic to check the status before changing
application installation status to active or deleted. Also,
added extensive unit tests to cover these new behaviors for
better reliability and clarity.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Added precondition checks for application status changes. Enhanced documentation for clarity in interface methods with new constraints. Comprehensive tests for `markAsActive`, `markAsBlocked`, and other status-related methods were introduced to ensure correct behavior.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Initialize 'comment' to null, validate 'externalId' input, and introduce ApplicationInstallationRepositoryInterface for persistence operations. Added new exception handling for application installation not found scenarios. Includes in-memory repository implementation and associated tests.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Added a new method `getById` to `ApplicationInstallationRepositoryInterface`. Renamed the test path prefix to `Unit`. Included various new tests for application installations, updating and reorganizing the existing structure.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Introduced the `Bitrix24PartnerStatus` enum to define partner statuses, and a `Bitrix24PartnerInterface` to standardize partner management operations, including partner creation, status changes, and retrieving partner information. This standardization aims to streamline interactions with Bitrix24 partner entities.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Introduce Bitrix24 Partner entity classes and a repository interface with in-memory implementations for testing. Added tests cover save, delete, getById, and associated functions to ensure data persistence operations work correctly.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Locking the phpstan version to 1.11.7 ensures stable and consistent builds. This change avoids potential issues from future updates to the phpstan package.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Replaced Fabric::getLogger with Psr\Log\NullLogger in multiple InMemory repository implementations for consistent logging behavior in unit tests. Adjusted test suite configuration to display warnings.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Updated README for better clarity and readability by adjusting formatting and adding new sections. Improved instructions for running tests and included additional examples for application setup in Bitrix24.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
@mesilov mesilov merged commit f67bc8a into 385-publish-b24-php-sdk-beta-3 Aug 6, 2024
16 checks 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.

refactor app contracts and add documentation for use cases
1 participant