Implemented the customer rate card view, including SKU search
This commit is contained in:
@@ -79,5 +79,29 @@ function createSpaConsumption({
|
||||
}
|
||||
}
|
||||
|
||||
return { requestConsumptionTrend, requestConsumptionPlanDetail };
|
||||
async function requestRatecardByPlan(message) {
|
||||
const debugRequests = [];
|
||||
try {
|
||||
const planNumber = typeof message.planNumber === "string" ? message.planNumber.trim() : "";
|
||||
const authorization = normalizeMessageAuthorization(message.authorization, "g2m-authorization");
|
||||
if (!planNumber) throw new Error("Plan number is required for the rate card.");
|
||||
if (!authorization.value) throw new Error("OCICONS-TS authorization is unavailable for the rate card.");
|
||||
const items = await fetchJson("https://spa.oracle.com/oalcrm/web/api/provider-proxy/g2m-consumption/service/v1/ratecard/byPlan", {
|
||||
method: "POST", credentials: "include", cache: "no-store",
|
||||
headers: { Accept: "application/json", "Content-Type": "application/json", "G2m-Authorization": authorization.value },
|
||||
body: JSON.stringify({ planNumber, recordsSize: 10000 })
|
||||
}, "requestRatecardByPlan", debugRequests);
|
||||
if (!Array.isArray(items) || items.some(item => !item || typeof item !== "object" || Array.isArray(item))) {
|
||||
throw new Error("requestRatecardByPlan returned invalid rate card items.");
|
||||
}
|
||||
return { ok: true, planNumber, items, debugRequests };
|
||||
} catch (error) {
|
||||
const entry = debugRequests[debugRequests.length - 1];
|
||||
if (entry && entry.status === "success") { entry.status = "failed"; entry.error = error.message; }
|
||||
error.debugRequests = debugRequests;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return { requestConsumptionTrend, requestConsumptionPlanDetail, requestRatecardByPlan };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user