Skip to content

Conversation

@chrisgacsal
Copy link
Collaborator

@chrisgacsal chrisgacsal commented Apr 14, 2025

Overview

Add api spec for add-on assignments to manage relationship between plans adn add-ons.

Summary by CodeRabbit

  • New Features

    • Introduced new API endpoints to manage plan add-ons, allowing users to list, create, retrieve, update, and delete add-on assignments.
  • Enhancements

    • Improved routing and error handling for clearer, more reliable API interactions.
    • Expanded data models to support detailed add-on information for enhanced plan customization.

@chrisgacsal chrisgacsal added area/api release-note/feature Release note: Exciting New Features labels Apr 14, 2025
@chrisgacsal chrisgacsal self-assigned this Apr 14, 2025
@chrisgacsal chrisgacsal requested a review from a team as a code owner April 14, 2025 07:48
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 14, 2025

📝 Walkthrough

Walkthrough

The changes introduce new API endpoints and data models for managing plan add-ons. The OpenAPI specification now includes endpoints for listing, creating, retrieving, updating, and deleting plan add-ons, along with new schemas. In the product catalog modules, a new TypeScript file defines the PlanAddon model, and an import statement is added to include it. Additionally, the routes file is updated to adjust existing interface methods and introduces a new interface for plan add-on operations with designated HTTP method annotations.

Changes

File(s) Summary of Changes
api/openapi.yaml Added endpoints for plan add-ons:
- GET and POST on /api/v1/plans/{planId}/addons
- GET, PUT, and DELETE on /api/v1/plans/{planId}/addons/{planAddonId}
Also, introduced new schemas: PlanAddon, PlanAddonCreate, and PlanAddonReplaceUpdate.
api/spec/.../main.tsp
api/spec/.../planaddon.tsp
In main.tsp, added an import for "./planaddon.tsp".
In planaddon.tsp, defined the PlanAddon model with properties such as id, key, version, instanceType, fromPlanPhase, and maxQuantity.
api/spec/.../routes.tsp Updated the Plans interface by adding @route("/{planId}") annotations and renaming a parameter from request to body.
Introduced a new PlanAddons interface with methods: list, create, update, get, and delete for managing plan add-ons.
openmeter/server/router/.../planaddon.go Introduced a new router file with methods for managing plan add-ons: ListPlanAddons, CreatePlanAddon, DeletePlanAddon, GetPlanAddon, and UpdatePlanAddon, each handling respective HTTP requests.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2
Failed executing command with error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b935cf and d2ad4d6.

📒 Files selected for processing (5)
  • api/openapi.yaml (2 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/planaddon.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (3 hunks)
  • openmeter/server/router/planaddon.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • api/spec/src/productcatalog/main.tsp
  • api/spec/src/productcatalog/planaddon.tsp
  • openmeter/server/router/planaddon.go
  • api/spec/src/productcatalog/routes.tsp
  • api/openapi.yaml
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: E2E
  • GitHub Check: CI
  • GitHub Check: Quickstart
  • GitHub Check: Lint
  • GitHub Check: Developer environment
  • GitHub Check: Commit hooks
  • GitHub Check: Test
  • GitHub Check: Build
  • GitHub Check: Analyze (go)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
api/spec/src/productcatalog/routes.tsp (1)

166-179: Introduction of PlanAddons interface and the list method

  1. Declaring a separate PlanAddons interface helps isolate plan add-on–specific functionality.
  2. The list method returning PlanAddon[] is straightforward for enumerating assigned add-ons.
  3. Consider adding pagination or searching if the number of add-ons can grow.
api/openapi.yaml (1)

6805-6879: Review GET /api/v1/plans/{planId}/addons Endpoint Parameter Consistency
In this GET operation, the planId parameter uses a pattern that allows two formats (^[a-z0-9]+(?:_[a-z0-9]+)*$|^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$). Please verify that supporting both formats here is intentional and that this dual-pattern approach is consistently reflected across the API.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c708b5f and 7cb5218.

📒 Files selected for processing (4)
  • api/openapi.yaml (2 hunks)
  • api/spec/src/productcatalog/main.tsp (1 hunks)
  • api/spec/src/productcatalog/planaddon.tsp (1 hunks)
  • api/spec/src/productcatalog/routes.tsp (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: E2E
  • GitHub Check: CI
  • GitHub Check: Developer environment
  • GitHub Check: Commit hooks
  • GitHub Check: Build
  • GitHub Check: Test
  • GitHub Check: Migration Checks
  • GitHub Check: Lint
  • GitHub Check: Analyze (go)
🔇 Additional comments (15)
api/spec/src/productcatalog/main.tsp (1)

17-17: Seamless import to incorporate plan add-ons

Adding import "./planaddon.tsp"; correctly integrates the plan add-on definitions into the main product catalog specification. No issues found.

api/spec/src/productcatalog/planaddon.tsp (4)

1-4: Relevant import statements

The imports for @typespec/http, local types.tsp, and ratecards.tsp appear valid, ensuring accessible definitions for HTTP operations and typed references.


5-9: Consistent namespace usage

Using namespace OpenMeter.ProductCatalog; aligns well with the existing product catalog modules. The using statements for TypeSpec utilities are properly declared.


10-50: Structured PlanAddon model with nested addon object

  1. The @friendlyName("PlanAddon") and docstrings (lines 10–12) offer clarity for external references.
  2. Nesting the addon object with fields like id, key, version, and instanceType cleanly encapsulates add-on attributes.
  3. Visibility annotations (e.g., @visibility(Lifecycle.Read, Lifecycle.Create)) are well-chosen for partial or read-only fields.

52-66: Additional properties for PlanAddon

  1. The fromPlanPhase property meaningfully indicates the specific plan phase from which the add-on should become purchasable. Consider defining a stricter type if valid phases are known in advance.
  2. The optional maxQuantity property is a good addition for multi-instance add-ons. Ensure proper validation logic in higher-level components.
api/spec/src/productcatalog/routes.tsp (5)

82-88: Renamed parameter to body

Switching from request to body clarifies that this parameter represents the request body for updating a plan. This naming convention is more intuitive and consistent.


94-95: Explicit route for getPlan method

The @route("/{planId}") annotation is a clear and consistent way to specify the path parameter.


118-119: Explicit route for deletePlan

Defining @route("/{planId}") aligns with standard RESTful deletion endpoints for identifying the resource by its ID.


180-198: createPlanAddon method

  1. Returning a 201 status with the newly created PlanAddon is REST-consistent.
  2. Handling ConflictError, NotFoundError, and CommonErrors comprehensively covers typical error states.

226-242: deletePlanAddon method

Returning 204 upon successful deletion is in line with RESTful practices. This endpoint should cleanly remove the assignment without returning a resource body.

api/openapi.yaml (5)

6880-6961: Review POST /api/v1/plans/{planId}/addons Endpoint Parameter Restrictions
The POST operation for creating a plan add-on assignment enforces a stricter pattern (^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$) for the planId parameter compared to the GET endpoint. Please confirm if this tighter validation is intentional or if the patterns should be aligned across endpoints for consistency.


7045-7122: Review GET /api/v1/plans/{planId}/addons/{planAddonId} Response Schema
The GET operation for a specific plan add-on assignment returns a schema reference to #/components/schemas/SubscriptionAddon, while the creation endpoint returns a PlanAddon. This introduces a naming inconsistency between endpoints handling what appears to be the same resource. Please verify whether using SubscriptionAddon is intentional or if it should be unified with PlanAddon for consistency.


7123-7198: Review DELETE /api/v1/plans/{planId}/addons/{planAddonId} Endpoint
The DELETE operation correctly defines required parameters and returns a 204 status code; no issues noted.


17812-18002: Verify New Schema Definitions for PlanAddon, PlanAddonCreate, and PlanAddonReplaceUpdate
The newly introduced schemas for managing plan add-ons are well defined with appropriate property types, required fields, and descriptive metadata. Ensure that these schemas align with the intended resource representation across the API. In particular, consider verifying that the resource naming (e.g., PlanAddon vs. SubscriptionAddon) is consistent throughout endpoint responses and documentation.


6962-7044:

Details

❓ Verification inconclusive

Inconsistency in Update Response Schema for PUT Operation
The PUT /api/v1/plans/{planId}/addons/{planAddonId} endpoint returns a 200 response with a schema reference to #/components/schemas/Plan, which is unexpected for an add-on update operation. It might be more consistent to return the updated add-on resource (e.g., PlanAddon or another appropriate schema). Please verify whether this is intentional or requires correction.


Attention: Verify Response Schema for UpdatePlanAddon Operation

It appears that the PUT endpoint /api/v1/plans/{planId}/addons/{planAddonId} returns a 200 response referencing the #/components/schemas/Plan schema, even though the request body uses the PlanAddonReplaceUpdate schema. This mismatch suggests that the update operation might be expected to return the updated add-on resource (e.g., using a PlanAddon schema or similar). Please review whether the response schema is intentional—if the design is to return the full updated plan, confirm that this behavior is consistently documented; otherwise, consider updating the response schema to better reflect the add-on update.

Items to Review:

  • File: api/openapi.yaml (Lines 6962-7044)
  • Request body schema: PlanAddonReplaceUpdate
  • Response 200 schema reference: Currently set to Plan

@chrisgacsal chrisgacsal force-pushed the feat/productcatalog branch 2 times, most recently from e8adc7f to 30a9e04 Compare April 14, 2025 08:02
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 5

🔭 Outside diff range comments (3)
openmeter/server/router/planaddon.go (2)

1-39: 🛠️ Refactor suggestion

Missing import for JSON handling and response utilities

The implementation suggestions require JSON handling and response utilities that are not currently imported.

package router

-import "net/http"
+import (
+	"encoding/json"
+	"net/http"
+)

// You'll also need to define a respondJSON function or import it from a utility package
// func respondJSON(w http.ResponseWriter, statusCode int, data interface{}) {
//     w.Header().Set("Content-Type", "application/json")
//     w.WriteHeader(statusCode)
//     if data != nil {
//         json.NewEncoder(w).Encode(data)
//     }
// }

1-39: 💡 Verification agent

🧩 Analysis chain

Add addonHandler field initialization in Router constructor

Ensure that the addonHandler field in the Router struct is properly initialized when the router is created.


🏁 Script executed:

#!/bin/bash
# Check if there's a constructor for the Router that initializes handlers

# Look for NewRouter or similar constructor functions
grep -r "func New.*Router" --include="*.go" .

Length of output: 380


Router constructor missing addonHandler initialization

Please update the Router's constructor (in openmeter/server/router/router.go, inside the NewRouter function) to initialize the addonHandler field. Currently, when creating a new Router instance, there’s no setup for addonHandler, which can lead to runtime issues when invoking the plan add-on endpoints. For example, consider initializing it similarly to your other handlers (e.g., using a helper like NewAddonHandler) and include appropriate configuration or dependency injections as needed.

api/spec/src/productcatalog/routes.tsp (1)

2-3: ⚠️ Potential issue

Missing import for PlanAddon type

The new PlanAddons interface uses the PlanAddon type, but there's no import for a file containing this type definition.

import "../rest.tsp";
import "./subscriptionaddon.tsp";
+import "./planaddon.tsp";
♻️ Duplicate comments (2)
api/spec/src/productcatalog/routes.tsp (2)

199-212: Incorrect return type for updatePlanAddon method

The method returns Plan instead of PlanAddon. This appears to be an oversight since the method is for updating plan add-ons.

-  ): Plan | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
+  ): PlanAddon | OpenMeter.NotFoundError | OpenMeter.CommonErrors;

213-225: Incorrect return type for getPlanAddon method

The method returns SubscriptionAddon but it's named getPlanAddon. This suggests a naming discrepancy.

-  ): SubscriptionAddon | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
+  ): PlanAddon | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
🧹 Nitpick comments (1)
api/spec/src/productcatalog/routes.tsp (1)

229-229: Incorrect documentation reference

The documentation refers to deleting a "plan" instead of a "plan addon".

-   * Once a plan is deleted it cannot be undeleted.
+   * Once a plan addon is deleted it cannot be undeleted.
🛑 Comments failed to post (5)
openmeter/server/router/planaddon.go (5)

21-24: 🛠️ Refactor suggestion

Implement router method to delete plan addon

This method needs implementation to handle the deletion of plan addons through the addonHandler.

func (a *Router) DeletePlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
-	//TODO implement me
-	panic("implement me")
+	// Delete the addon using the addonHandler
+	if err := a.addonHandler.DeletePlanAddon(r.Context(), planId, planAddonId); err != nil {
+		// Handle specific error types appropriately
+		// e.g., NotFound errors should return 404
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+	
+	// Respond with no content for successful deletion
+	w.WriteHeader(http.StatusNoContent)
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

func (a *Router) DeletePlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
	// Delete the addon using the addonHandler
	if err := a.addonHandler.DeletePlanAddon(r.Context(), planId, planAddonId); err != nil {
		// Handle specific error types appropriately
		// e.g., NotFound errors should return 404
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	
	// Respond with no content for successful deletion
	w.WriteHeader(http.StatusNoContent)
}

28-31: 🛠️ Refactor suggestion

Implement router method to get plan addon

This method needs implementation to retrieve a specific plan addon using the addonHandler.

func (a *Router) GetPlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
-	//TODO implement me
-	panic("implement me")
+	// Get the addon using the addonHandler
+	addon, err := a.addonHandler.GetPlanAddon(r.Context(), planId, planAddonId)
+	if err != nil {
+		// Handle specific error types appropriately
+		// e.g., NotFound errors should return 404
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+	
+	// Respond with the retrieved addon
+	respondJSON(w, http.StatusOK, addon)
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

func (a *Router) GetPlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
	// Get the addon using the addonHandler
	addon, err := a.addonHandler.GetPlanAddon(r.Context(), planId, planAddonId)
	if err != nil {
		// Handle specific error types appropriately
		// e.g., NotFound errors should return 404
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	
	// Respond with the retrieved addon
	respondJSON(w, http.StatusOK, addon)
}

14-17: 🛠️ Refactor suggestion

Implement router method to create plan addon

This method needs to be implemented to handle the creation of plan addons by using the addonHandler.

func (a *Router) CreatePlanAddon(w http.ResponseWriter, r *http.Request, planId string) {
-	//TODO implement me
-	panic("implement me")
+	// Parse the request body
+	var addonData planAddonRequest
+	if err := json.NewDecoder(r.Body).Decode(&addonData); err != nil {
+		http.Error(w, "Invalid request body", http.StatusBadRequest)
+		return
+	}
+	
+	// Create the addon using the addonHandler
+	addon, err := a.addonHandler.CreatePlanAddon(r.Context(), planId, addonData)
+	if err != nil {
+		// Handle specific error types appropriately
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+	
+	// Respond with the created addon
+	respondJSON(w, http.StatusCreated, addon)
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

func (a *Router) CreatePlanAddon(w http.ResponseWriter, r *http.Request, planId string) {
	// Parse the request body
	var addonData planAddonRequest
	if err := json.NewDecoder(r.Body).Decode(&addonData); err != nil {
		http.Error(w, "Invalid request body", http.StatusBadRequest)
		return
	}
	
	// Create the addon using the addonHandler
	addon, err := a.addonHandler.CreatePlanAddon(r.Context(), planId, addonData)
	if err != nil {
		// Handle specific error types appropriately
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	
	// Respond with the created addon
	respondJSON(w, http.StatusCreated, addon)
}

7-10: 🛠️ Refactor suggestion

Implement router method with addonHandler

This method has a placeholder implementation. When implementing, you should use the addonHandler from the Router struct to perform the actual operation.

func (a *Router) ListPlanAddons(w http.ResponseWriter, r *http.Request, planId string) {
-	//TODO implement me
-	panic("implement me")
+	// Example implementation - adjust based on your actual addonHandler methods
+	addons, err := a.addonHandler.ListPlanAddons(r.Context(), planId)
+	if err != nil {
+		// Handle the error appropriately
+		// You might want to check for specific error types and return different status codes
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+	// Respond with the list of addons
+	// Use appropriate helper methods to encode the response
+	respondJSON(w, http.StatusOK, addons)
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

func (a *Router) ListPlanAddons(w http.ResponseWriter, r *http.Request, planId string) {
	// Example implementation - adjust based on your actual addonHandler methods
	addons, err := a.addonHandler.ListPlanAddons(r.Context(), planId)
	if err != nil {
		// Handle the error appropriately
		// You might want to check for specific error types and return different status codes
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	// Respond with the list of addons
	// Use appropriate helper methods to encode the response
	respondJSON(w, http.StatusOK, addons)
}

35-38: 🛠️ Refactor suggestion

Implement router method to update plan addon

This method needs implementation to update an existing plan addon through the addonHandler.

func (a *Router) UpdatePlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
-	//TODO implement me
-	panic("implement me")
+	// Parse the request body
+	var addonData planAddonRequest
+	if err := json.NewDecoder(r.Body).Decode(&addonData); err != nil {
+		http.Error(w, "Invalid request body", http.StatusBadRequest)
+		return
+	}
+	
+	// Update the addon using the addonHandler
+	updatedAddon, err := a.addonHandler.UpdatePlanAddon(r.Context(), planId, planAddonId, addonData)
+	if err != nil {
+		// Handle specific error types appropriately
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+	
+	// Respond with the updated addon
+	respondJSON(w, http.StatusOK, updatedAddon)
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

func (a *Router) UpdatePlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
	// Parse the request body
	var addonData planAddonRequest
	if err := json.NewDecoder(r.Body).Decode(&addonData); err != nil {
		http.Error(w, "Invalid request body", http.StatusBadRequest)
		return
	}
	
	// Update the addon using the addonHandler
	updatedAddon, err := a.addonHandler.UpdatePlanAddon(r.Context(), planId, planAddonId, addonData)
	if err != nil {
		// Handle specific error types appropriately
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	
	// Respond with the updated addon
	respondJSON(w, http.StatusOK, updatedAddon)
}

@chrisgacsal chrisgacsal force-pushed the feat/productcatalog branch from 30a9e04 to 0b935cf Compare April 14, 2025 08:05
@chrisgacsal chrisgacsal force-pushed the feat/productcatalog branch from 0b935cf to d2ad4d6 Compare April 14, 2025 08:34
@chrisgacsal chrisgacsal merged commit f228f5f into main Apr 14, 2025
27 checks passed
@chrisgacsal chrisgacsal deleted the feat/productcatalog branch April 14, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants