ESD-901: Add product pricing to ProductService - #149
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new pricing lookup capability to ProductService by introducing GetProductPricing, request/response pricing types, and unit tests to validate basic behavior against POST /v4/pricebook/product.
Changes:
- Added
GetProductPricing(ctx, req)toProductService/ProductServiceOpbacked byPOST /v4/pricebook/product. - Introduced
pricing_types.gocontaining pricebook request/response DTOs and enums. - Added unit tests for the happy-path pricing response and nil-request handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| product.go | Adds GetProductPricing implementation and wires it into the ProductService interface. |
| pricing_types.go | Defines request/response types, enums, and error values for pricebook pricing. |
| product_test.go | Adds tests for GetProductPricing success and nil request behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…dOns field; auto-inject productType; per-type validation; companyId/companyUid support; full test coverage
- Fix gofmt alignment in pricing_types.go (struct tag spacing) - Guard typed-nil PriceBookRequest via reflect.ValueOf(req).IsNil(); req == nil only catches a nil interface, not (*T)(nil) - Capture *http.Response from Client.Do and defer resp.Body.Close() in both GetProductPricing and GetProductPricingForCompany to avoid leaking the connection - Return error when envelope.Data == nil so callers get a clear error instead of a silent (nil, nil) return on a 2xx with empty body - Add TestGetProductPricingTypedNilRequest to lock in typed-nil guard
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… company identifiers - Push the nil / typed-nil interface guard down into validatePriceBookRequest so both GetProductPricing and GetProductPricingForCompany are covered with a single check, preventing nil-pointer panics when any *XPriceBookRequest case dereferences r.Field. - Reject GetProductPricingForCompany requests that set both CompanyID and CompanyUID, since the docs and API treat them as mutually exclusive. - Add ErrPricingCompanyIDAndUIDSet and tests covering nil wrapper, nil inner request, typed-nil inner request, and the mutually exclusive identifier case.
|
Addressed Copilot review feedback in 7df8e2a:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Adding |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…riceBookDTO Extract isNilPriceBookRequest helper that checks Kind before calling IsNil to prevent panics on non-nilable types. Rename PriceBookDto to PriceBookDTO to follow Go initialism conventions.
|
Both Copilot issues addressed in 45a9362: 1. Safe reflect nil check — Extracted 2. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed: added |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace inline fmt.Errorf for missing pricing data with package-level ErrProductPricingResponseEmpty sentinel in pricing_types.go. Add TestGetProductPricingForCompanyUID to assert companyUid query param is sent when CompanyUID is set (and companyId is absent).
|
Addressed both review points in c40b3d2:
All product tests pass. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ld, extract body builder helper - Lowercase all ErrPricing* error message strings per Go convention - Remove omitempty from MVEPriceBookRequest.LocationID (field is required) - Extract buildPriceBookRequestBody helper to eliminate duplication between GetProductPricing and GetProductPricingForCompany
|
Addressed Copilot feedback: lowercased all |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ingAddOnType constants Replace the incorrect "IPSEC" string in the ProductAddOnPriceBookRequest comment with the correct "IP_SEC" value (matching AddOnTypeIPsec in mcr_types.go), and introduce exported PricingAddOnTypeCrossConnect and PricingAddOnTypeIPSec constants.
|
The addition of |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds
GetProductPricingtoProductService, backed byPOST /v4/pricebook/product. Supports pricing requests for VXC, MCR, Port (Megaport), MVE, IX, NAT Gateway, and IP Address product types via thePriceBookRequestinterface, and returns per-product monthly rates, price elements, and applied discounts.Also adds
GetProductPricingForCompanyfor partner/reseller pricing scoped to another company via mutually exclusivecompanyId/companyUidquery parameters.Part of ESD-889.