ChemPal Documentation - v1.6.0
    Preparing search index...

    Function isAmbeedProductPriceResponse

    • Type guard to validate if data matches the Ambeed product price API response structure. Checks the AmbeedResponseBase fields plus a value.proInfo object, which carries the shared product info every priced variant in the response is keyed against.

      Parameters

      • data: unknown

        The response data to validate

      Returns data is AmbeedProductPriceResponse

      Type predicate indicating if the data is a valid AmbeedProductPriceResponse

      const response = await this.httpPostJson({ path: "/webapi/v1/product_price" });
      if (isAmbeedProductPriceResponse(response)) {
      console.log("Product:", response.value.proInfo.p_name_en);
      console.log("Lead time:", response.value.proInfo.p_leadtime);
      }
      export function isAmbeedProductPriceResponse(data: unknown): data is AmbeedProductPriceResponse {
      return v.safeParse(ambeedProductPriceResponseSchema, data).success;
      }