Skip to content

RI Recommendations - APIClient#8121

Merged
wordpressfan merged 9 commits intofeature/ri-recommendationsfrom
feature/8098-apiclient
Mar 5, 2026
Merged

RI Recommendations - APIClient#8121
wordpressfan merged 9 commits intofeature/ri-recommendationsfrom
feature/8098-apiclient

Conversation

@wordpressfan
Copy link
Contributor

Description

Fixes #8098

Everything is mentioned in the issue itself.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).
  • Sub-task of #(issue number)
  • Chore
  • Release

Detailed scenario

What was tested

Manually check the response of the APIClient::get_recommendations method

How to test

It's not testable by QA, only dev can validate it and we can enhance it later when it's being used.

Affected Features & Quality Assurance Scope

Nothing, new file

Technical description

Documentation

Only APIClient to send the request and handle the response of recommendations.

New dependencies

New endpoint, it's deployed in this saas director: https://group-onecom.slack.com/archives/C0AF91DUS9Z/p1771944856664779

Risks

N/A

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Unticked items justification

If some mandatory items are not relevant, explain why in this section.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

@wordpressfan wordpressfan changed the base branch from develop to feature/ri-recommendations March 4, 2026 06:52
@wordpressfan wordpressfan self-assigned this Mar 4, 2026
@codacy-production
Copy link

codacy-production bot commented Mar 4, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.10% (target: -0.10%) 95.45% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c1c0052) 42529 19367 45.54%
Head commit (3310a31) 42584 (+55) 19434 (+67) 45.64% (+0.10%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#8121) 88 84 95.45%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@wordpressfan wordpressfan marked this pull request as ready for review March 4, 2026 08:22
@wordpressfan wordpressfan requested a review from Copilot March 4, 2026 12:15
# Conflicts:
#	inc/Engine/Admin/RocketInsights/ServiceProvider.php
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Rocket Insights “Recommendations” SaaS API client intended to fetch recommendation data from the /recommendations/ endpoint and wires it into the RocketInsights DI module, with accompanying unit tests/fixtures.

Changes:

  • Added Recommendations\APIClient::get_recommendations() for fetching and validating recommendations responses.
  • Registered the recommendations API client in inc/Engine/Admin/RocketInsights/ServiceProvider.php.
  • Added unit tests and fixtures covering success and common failure paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
inc/Engine/Admin/RocketInsights/Recommendations/APIClient.php New Recommendations API client implementation (request + response validation + logging).
inc/Engine/Admin/RocketInsights/ServiceProvider.php Registers the recommendations API client in the RocketInsights container.
tests/Unit/inc/Engine/Admin/RocketInsights/Recommendations/APIClient/getRecommendations.php Unit tests for get_recommendations().
tests/Fixtures/inc/Engine/Admin/RocketInsights/Recommendations/APIClient/getRecommendations.php Test fixtures for the recommendations API client scenarios.
Comments suppressed due to low confidence (1)

inc/Engine/Admin/RocketInsights/ServiceProvider.php:185

  • Service registration wires ri_recommendations_api_client with the options service, but the recommendations endpoint is intended to be public/no-auth. If the API client is refactored to avoid credentials (and thus no longer needs Options_Data), update the container registration to drop this dependency to prevent unnecessary coupling and avoid leaking consumer credentials in requests.
				[
					'ri_query',
					'ri_manager',

@wordpressfan wordpressfan merged commit 51f9f14 into feature/ri-recommendations Mar 5, 2026
15 checks passed
@wordpressfan wordpressfan deleted the feature/8098-apiclient branch March 5, 2026 06:31
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.

[RI Recommendations] Task 1.2: Create Recommendations API Client

2 participants