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

[BSS-31] New Request Mechanism #9

Merged
merged 9 commits into from
Sep 18, 2024
Merged

[BSS-31] New Request Mechanism #9

merged 9 commits into from
Sep 18, 2024

Conversation

shahmal1yev
Copy link
Owner

@shahmal1yev shahmal1yev commented Sep 9, 2024

Implement and test the new request mechanism framework and integrate it into the system.

Objectives:

  • Design and develop a robust request mechanism framework
  • Implement comprehensive testing procedures
  • Seamlessly integrate the new framework into the existing system

Key Tasks:

  1. Analyze current request handling system and identify areas for improvement
  2. Develop the core components of the new "framework"
  3. Implement unit tests for each component

Success Criteria:

  • All unit and integration tests pass successfully
  • No regression in existing functionality

Copy link

New Request Mechanism

@shahmal1yev shahmal1yev added the enhancement New feature or request label Sep 9, 2024
@shahmal1yev shahmal1yev self-assigned this Sep 9, 2024
- Implemented `Request` class under the `Atproto\HTTP` namespace with methods to manage URL, path, method, headers, parameters, and query parameters.
- Added flexibility in setting and retrieving values for headers, parameters, and query parameters.
- Provided encoding for headers and parameters as arrays or JSON.
- Created `RequestTest` class under `Tests\Unit\HTTP` to ensure proper functionality:
  - Added tests for setting and retrieving values via the methods.
  - Verified instance return consistency when setting values.
  - Tested encoding output for headers, parameters, and query parameters.
- Introduced a new `RequestContract` interface to define the contract for HTTP request handling.
- Updated the `Request` class to implement `RequestContract` and conform to the interface requirements.
- Adjusted the `RequestTest` unit test to assert that `Request` implements `RequestContract` for better type consistency and interface-driven design.
- Created a new `APIRequestContract` interface that extends `RequestContract` for building API-specific requests.
- Added a `build()` method to `APIRequestContract` to ensure that implementations can return a fully constructed `RequestContract`.
- Deprecated the `GetProfile` class in `src/API/App/Bsky/Actor/GetProfile.php`.
- Updated the `RequestContract` to provide stricter method signatures for `url` and introduced the `origin` method.
- Introduced `MissingProvidedFieldException` to handle cases where required fields are missing.
- Created `APIRequest` base class in `src/HTTP/API/APIRequest.php`, which defines default headers and origin for API requests.
- Re-implemented the `GetProfile` request using the new `APIRequest` abstraction, adding validation for the `actor` field and building query parameters dynamically.
- Refined the `Request` class to handle URL construction based on origin, path, and query parameters, while adding the `origin` method.
- Added reflection support for tests, making it easier to manipulate private properties in `tests/Supports/Reflection.php`.
- Added unit tests for `GetProfile` to validate proper behavior, including checking that the `actor` method sets the correct data.
…Exception::__construct() has invalid type Atproto\Exceptions\Http\Throwable.
- Deprecate CreateRecord and UploadBlob classes in Com/Atrproto/Repo
- Add new CreateRecord and UploadBlob classes in HTTP/API/Requests/Com/Atproto/Repo
- Update RequestContract interface to allow non-string parameter values
- Refactor Request class to accommodate non-string parameter values
- Improve error handling and parameter validation in new classes
- Add deprecation notices and trigger warnings in legacy classes
@shahmal1yev shahmal1yev merged commit e4f0d12 into development Sep 18, 2024
2 checks passed
@shahmal1yev shahmal1yev deleted the bss-31 branch September 24, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant