update_product_rate_plan
Update an existing product rate plan by modifying its name, type, description, effective dates, or image using the rate plan ID.
Instructions
Update a rate plan. PUT /product-rateplans/{ratePlanId}. Optional: name, type (contract|ongoing|prepaid), description, effectiveStartDate, effectiveEndDate, image.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ratePlanId | Yes | Rate plan ID (URI: /product-rateplans/{ratePlanId}) | |
| name | No | Rate plan name | |
| type | No | Type: contract, ongoing, or prepaid | |
| description | No | Description | |
| effectiveStartDate | No | Effective start date | |
| effectiveEndDate | No | Effective end date | |
| minimumCommitment | No | Minimum commitment | |
| minimumCommitmentLength | No | Minimum commitment length | |
| minimumCommitmentUnit | No | Minimum commitment unit | |
| changeStatusBasedOnCharge | No | Change status based on charge | |
| image | No | Image |
Implementation Reference
- Handler function for update_product_rate_plan tool. Parses input with Zod schema, extracts ratePlanId, and delegates to ratePlanService.updateRatePlan.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } const { ratePlanId, ...body } = parsed.data; return handleToolCall(() => ratePlanService.updateRatePlan(client, ratePlanId, body)); } - Zod validation schema and tool definition (name: update_product_rate_plan, inputSchema with properties for ratePlanId, name, type, description, effectiveStartDate, effectiveEndDate, minimumCommitment, minimumCommitmentLength, minimumCommitmentUnit, changeStatusBasedOnCharge, image).
import { z } from "zod"; import type { Tool } from "../types.js"; import type { Client } from "./helpers.js"; import { errorResult, handleToolCall } from "./helpers.js"; import * as ratePlanService from "../../services/productRatePlanServices.js"; const schema = z.object({ ratePlanId: z.string().min(1, "ratePlanId is required"), name: z.string().optional(), type: z.enum(["contract", "ongoing", "prepaid"]).optional(), description: z.string().optional(), effectiveStartDate: z.string().optional(), effectiveEndDate: z.string().optional(), minimumCommitment: z.boolean().optional(), minimumCommitmentLength: z.number().optional(), minimumCommitmentUnit: z.string().optional(), changeStatusBasedOnCharge: z.boolean().optional(), image: z.string().optional(), }); const definition = { name: "update_product_rate_plan", description: "Update a rate plan. PUT /product-rateplans/{ratePlanId}. Optional: name, type (contract|ongoing|prepaid), description, effectiveStartDate, effectiveEndDate, image.", inputSchema: { type: "object" as const, properties: { ratePlanId: { type: "string", description: "Rate plan ID (URI: /product-rateplans/{ratePlanId})" }, name: { type: "string", description: "Rate plan name" }, type: { type: "string", description: "Type: contract, ongoing, or prepaid" }, description: { type: "string", description: "Description" }, effectiveStartDate: { type: "string", description: "Effective start date" }, effectiveEndDate: { type: "string", description: "Effective end date" }, minimumCommitment: { type: "boolean", description: "Minimum commitment" }, minimumCommitmentLength: { type: "number", description: "Minimum commitment length" }, minimumCommitmentUnit: { type: "string", description: "Minimum commitment unit" }, changeStatusBasedOnCharge: { type: "boolean", description: "Change status based on charge" }, image: { type: "string", description: "Image" }, }, required: ["ratePlanId"], }, }; - src/tools/product_rate_plans/updateRatePlan.ts:53-56 (registration)Tool object export combining the definition and handler, registered as updateRatePlanTool.
export const updateRatePlanTool: Tool = { definition, handler, }; - src/tools/product_rate_plans/index.ts:12-12 (registration)Import of updateRatePlanTool into the rate plan tools barrel module for registration.
import { updateRatePlanTool } from "./updateRatePlan.js"; - Service function updateRatePlan that makes PUT /product-rateplans/{ratePlanId} API call, filtering out undefined fields from the request body.
export async function updateRatePlan( client: Client, ratePlanId: string, body: UpdateRatePlanBody ): Promise<unknown> { const payload = Object.fromEntries( Object.entries(body).filter(([, v]) => v !== undefined) ) as UpdateRatePlanBody; return client.put<unknown>( `/product-rateplans/${ratePlanId}`, Object.keys(payload).length ? payload : undefined ); }