Skip to content

[Customer Portal][BE] Update product search payload by adding the filters - #483

Merged
cloby99 merged 5 commits into
wso2-open-operations:dev-app-customer-portalfrom
Rashmika998:dev-app-customer-portal
Apr 10, 2026
Merged

cloby99 merged 5 commits into
wso2-open-operations:dev-app-customer-portalfrom
Rashmika998:dev-app-customer-portal

Conversation

@Rashmika998

@Rashmika998 Rashmika998 commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Update product search by adding the class filter.

Summary by CodeRabbit

  • New Features

    • Products now include a product class and can be filtered by class in searches.
    • Call requests include a request number and optional meeting link for easier tracking.
  • Documentation

    • API contract updated to reflect new product class and call request attributes.

@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Rashmika998 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 15 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 15 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 644e4c27-4c2c-4d7c-9c72-35ffcbe650ba

📥 Commits

Reviewing files that changed from the base of the PR and between ed726e6 and 6f3ea9f.

📒 Files selected for processing (2)
  • apps/customer-portal/backend/modules/entity/types.bal
  • apps/customer-portal/backend/openapi.yaml
📝 Walkthrough

Walkthrough

Adds a new ProductClass enum (single value), introduces class, number, and meetingLink fields to types, updates the OpenAPI Product and CallRequestUpdatePayload schemas, and includes the new call request fields in the mapping utility.

Changes

Cohort / File(s) Summary
Product Classification Enum
apps/customer-portal/backend/modules/entity/enums.bal
Added exported enum ProductClass with a single constant: PRODUCT_MODEL = "product_model".
Entity Type Extensions
apps/customer-portal/backend/modules/entity/types.bal
Added string number and string? meetingLink to CallRequest; added optional filters (with optional class: ProductClass) to ProductSearchPayload; added required class field to Product.
Backend Types Module
apps/customer-portal/backend/modules/types/types.bal
Extended public CallRequest record with number (required string) and meetingLink (optional string).
API Specification
apps/customer-portal/backend/openapi.yaml
Removed durationInMinutes from CallRequestUpdatePayload; clarified utcTimes is mandatory when stateKey is 2; added required class string property to Product schema.
Mapping Utilities
apps/customer-portal/backend/utils.bal
Updated mapSearchCallRequestResponse to include number and meetingLink in mapped types:CallRequest objects returned by the mapper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Type/Improvement

Suggested reviewers

  • shayanmalinda
  • cloby99
  • yuk7hi

Poem

🐰 A tiny enum hops into the day,
A product's class in one bright display,
Call numbers and meeting links now play,
Types and docs updated — hip hooray! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and does not follow the required template with essential sections like Purpose, Goals, Approach, Release notes, Documentation, and Testing details. Expand the description to include Purpose (with issue links), Goals, Approach, Release note, Documentation impact, and at minimum basic testing information following the repository template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding filters (specifically a class filter) to the product search payload.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/customer-portal/backend/openapi.yaml (2)

2826-2845: ⚠️ Potential issue | 🟠 Major

Restore durationInMinutes to CallRequestUpdatePayload.

The backend type and validation still consume this field, so removing it from the published schema makes the API contract drift from the server implementation. Re-add it here with the numeric constraints.

Proposed fix
     utcTimes:
       type: array
       description: New preferred UTC times for the call (mandatory when stateKey
         is 2)
       items:
         $ref: '#/components/schemas/DateTime'
+    durationInMinutes:
+      minimum: 1
+      type: integer
+      description: Duration in minutes (mandatory when stateKey is 2)
+      format: int64
       additionalProperties: false
       description: Request payload for updating a call request.

Based on learnings, CallRequestUpdatePayload.durationInMinutes is strictly required when stateKey is 2, and the OpenAPI schema should include minimum: 1 and format: int64.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/customer-portal/backend/openapi.yaml` around lines 2826 - 2845, Restore
the durationInMinutes field to the CallRequestUpdatePayload schema: add a
properties.durationInMinutes entry with type: integer, format: int64 and
minimum: 1, and add a conditional rule so that when stateKey is 2 the schema
requires durationInMinutes (use an if/then block with if: properties: {
stateKey: { const: 2 } } then: { required: [ "durationInMinutes" ] }). Keep
additionalProperties: false and leave other fields unchanged.

4329-4341: ⚠️ Potential issue | 🟡 Minor

Constrain Product.class to the supported values.

Declaring this as a plain string drops the enum contract the backend already has, so generated clients and docs will not advertise the only valid values. Model it as an enum here, or reference a shared ProductClass schema.

Proposed fix
         class:
           type: string
           description: "Product class (service_model, software_model, or product_model)"
+          enum:
+          - service_model
+          - software_model
+          - product_model
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/customer-portal/backend/openapi.yaml` around lines 4329 - 4341, The
Product.schema currently defines the property "class" as type: string which
loses the backend enum constraint; update the "class" property (Product.class)
to either reference a shared enum schema (e.g., $ref:
'#/components/schemas/ProductClass') or replace type: string with an explicit
enum list (e.g., enum: [service_model, software_model, product_model]) so
generated clients/docs advertise the valid values; ensure the chosen enum schema
is added under components/schemas if it doesn't already exist and update any
usages to reference it.
🧹 Nitpick comments (1)
apps/customer-portal/backend/modules/entity/types.bal (1)

1589-1590: Prefer ProductClass over raw string for Product.'class.

At Line 1590, using string weakens the response contract even though ProductClass already exists for this domain. Typing this field as ProductClass keeps request/response semantics consistent and prevents invalid class values.

♻️ Proposed refactor
 public type Product record {|
     # ID
     IdString id;
     # Name
     string name;
     # Product class (service_model, software_model, or product_model)
-    string 'class;
+    ProductClass 'class;
     json...;
 |};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/customer-portal/backend/modules/entity/types.bal` around lines 1589 -
1590, The Product record currently types the field Product.'class as raw string
which weakens the contract; change its type to the existing ProductClass type so
the field reads Product.'class: ProductClass (update any necessary
imports/qualified names where ProductClass is defined and run CI/types checks to
ensure all usages of Product.'class conform to the enum/union values); update
any serialization/deserialization or tests that assume a plain string to use
ProductClass values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/customer-portal/backend/openapi.yaml`:
- Around line 2826-2845: Restore the durationInMinutes field to the
CallRequestUpdatePayload schema: add a properties.durationInMinutes entry with
type: integer, format: int64 and minimum: 1, and add a conditional rule so that
when stateKey is 2 the schema requires durationInMinutes (use an if/then block
with if: properties: { stateKey: { const: 2 } } then: { required: [
"durationInMinutes" ] }). Keep additionalProperties: false and leave other
fields unchanged.
- Around line 4329-4341: The Product.schema currently defines the property
"class" as type: string which loses the backend enum constraint; update the
"class" property (Product.class) to either reference a shared enum schema (e.g.,
$ref: '#/components/schemas/ProductClass') or replace type: string with an
explicit enum list (e.g., enum: [service_model, software_model, product_model])
so generated clients/docs advertise the valid values; ensure the chosen enum
schema is added under components/schemas if it doesn't already exist and update
any usages to reference it.

---

Nitpick comments:
In `@apps/customer-portal/backend/modules/entity/types.bal`:
- Around line 1589-1590: The Product record currently types the field
Product.'class as raw string which weakens the contract; change its type to the
existing ProductClass type so the field reads Product.'class: ProductClass
(update any necessary imports/qualified names where ProductClass is defined and
run CI/types checks to ensure all usages of Product.'class conform to the
enum/union values); update any serialization/deserialization or tests that
assume a plain string to use ProductClass values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b45576d4-97cf-46c0-97e7-88f5a4d6ba1b

📥 Commits

Reviewing files that changed from the base of the PR and between bdec6ca and d2dac57.

📒 Files selected for processing (5)
  • apps/customer-portal/backend/modules/entity/enums.bal
  • apps/customer-portal/backend/modules/entity/types.bal
  • apps/customer-portal/backend/modules/types/types.bal
  • apps/customer-portal/backend/openapi.yaml
  • apps/customer-portal/backend/utils.bal

Comment thread apps/customer-portal/backend/openapi.yaml Outdated
Co-authored-by: Anuradha Basnayake <anuradhabsnk@gmail.com>
Comment thread apps/customer-portal/backend/modules/entity/types.bal Outdated
Comment thread apps/customer-portal/backend/openapi.yaml Outdated
Rashmika998 and others added 2 commits April 10, 2026 13:58
Co-authored-by: Anuradha Basnayake <anuradhabsnk@gmail.com>
Co-authored-by: Anuradha Basnayake <anuradhabsnk@gmail.com>
@cloby99
cloby99 merged commit 9619962 into wso2-open-operations:dev-app-customer-portal Apr 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants