Skip to content

Expose filter operator on Responses\Filter#27

Merged
ondrajodas merged 1 commit into
mainfrom
ondra/filter-response-operator
May 15, 2026
Merged

Expose filter operator on Responses\Filter#27
ondrajodas merged 1 commit into
mainfrom
ondra/filter-response-operator

Conversation

@ondrajodas
Copy link
Copy Markdown
Contributor

Summary

Adds the required operator field to Responses\Filter so clients can read the comparison operator that the server stored alongside the filter field and value.

The Notification API guarantees operator is always present in subscription filter responses — the server defaults to == when the field is omitted in the request — so the property is a non-nullable string.

Changes

  • src/Responses/Filter.php — new string $operator property assigned from $data['operator'], new getOperator(): string accessor.
  • tests/Responses/FilterTest.php — existing test datasets updated to include operator, new testOperators data provider covering all five values (==, <, >, <=, >=), and a new testMissingOperator asserting that a payload without operator raises ClientException.
  • tests/Responses/SubscriptionTest.php — mock data extended with operator plus an assertion on getOperator().
  • tests/SubscriptionClientFunctionalTest.phpoperator added to the two response payloads and getOperator() asserted in both the single-subscription and list endpoints.

Adds the required `operator` field to `Responses\Filter` so clients can
read the comparison operator that the server stored alongside the filter
field and value. The Notification API guarantees `operator` is always
present in responses (server defaults to '==' when omitted in the
request), so the property is a non-nullable string.

Tests now cover all operator values ('==', '<', '>', '<=', '>=') and a
missing-operator payload throws ClientException. Mock responses in the
functional test suite were updated to include the new field.
@ondrajodas
Copy link
Copy Markdown
Contributor Author

# Release Notes
`Responses\Filter` now exposes the comparison operator via a new `getOperator(): string` accessor. The accessor returns the operator stored on the subscription filter (`==`, `<`, `>`, `<=`, `>=`).

# Plans for Customer Communication
None required — additive accessor on a response VO. Consumers of `notification-api-php-client` who want to read the operator must bump to the version containing this change; existing callers are unaffected.

# Impact Analysis
- Affected component: `Keboola\NotificationClient\Responses\Filter`.
- Behavioral change: `operator` is now a required key in the deserialized response payload. Any caller passing a hand-crafted array without `operator` to `new Filter(...)` will get a `ClientException` (`Unrecognized response: ...`).
- API contract: `notification-service` already always returns `operator` in subscription filter responses (server defaults to `==` when omitted in the POST request), so real API traffic is not affected.

# Change Type
Feature (additive accessor) with a minor BC consideration for direct constructor callers.

# Justification
Downstream consumers need access to the filter operator to render and reason about subscription filters. Without the accessor the operator was silently dropped on deserialization.

# Deployment Plan
Tag a new minor release of the package after merge. No infra or config changes required.

# Rollback Plan
Revert the PR and tag a patch release. Consumers can pin the previous tag.

# Post-Release Support Plan
Monitor downstream apps for `ClientException: Unrecognized response: ... operator` after upgrade — would indicate an API path that does not return `operator` (none expected based on current `notification-service` code).

Copy link
Copy Markdown

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 an operator property to the Responses\Filter class so API consumers can read the comparison operator (e.g. ==, <, >=) returned by the Notification API alongside subscription filter fields and values.

Changes:

  • Adds non-nullable string $operator property and getOperator() accessor on Responses\Filter.
  • Updates existing Filter/Subscription tests to include operator in payloads and assert the new accessor.
  • Adds new tests covering all five operator values and a missing-operator failure case.

Reviewed changes

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

File Description
src/Responses/Filter.php Adds $operator property, assigns it from $data['operator'], and exposes getOperator().
tests/Responses/FilterTest.php Updates existing cases with operator, adds testOperators data provider and testMissingOperator.
tests/Responses/SubscriptionTest.php Adds operator to mock data and asserts getOperator() on the filter.
tests/SubscriptionClientFunctionalTest.php Adds operator to functional test payloads and asserts getOperator() for single and list endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ondrajodas ondrajodas marked this pull request as ready for review May 14, 2026 19:54
@ondrajodas ondrajodas requested a review from odinuv May 14, 2026 19:54
@ondrajodas ondrajodas merged commit abc4451 into main May 15, 2026
5 checks passed
@ondrajodas ondrajodas deleted the ondra/filter-response-operator branch May 15, 2026 06:50
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.

3 participants