From 18cfbd264be55dccd51d7cfcc13e451d47379f67 Mon Sep 17 00:00:00 2001 From: "Peter.Morton" Date: Fri, 12 Jan 2024 18:18:06 -0600 Subject: [PATCH] added km: for using KM content --- README.md | 2 ++ src/@types/HydraCollection.ts | 5 +++++ src/helpers/index.ts | 28 +++++++++++++++++++++++- src/views/HomePage.vue | 2 +- src/views/TelephonyContext.vue | 40 ++++++++++++---------------------- 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f914d83..1947509 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Displays Telephony Context Information. This route has been designed to be used Parameters prefixed with 'tps:' will fetch values from the Tenant Properties Service. +Paremeters prefixed with 'km:' will use Knowledge Management using the {contentID}(migratableReference)/{lang}. For example, integrationCardDoc=km:DvudRWR4yd2iRSDtlboDp8/en-US. + | name | description | | -------------------- | ---------------------------------------------------------- | | ani | Automatic Number Identification | diff --git a/src/@types/HydraCollection.ts b/src/@types/HydraCollection.ts index 82b8ac7..5fdfd55 100644 --- a/src/@types/HydraCollection.ts +++ b/src/@types/HydraCollection.ts @@ -7,3 +7,8 @@ export interface VCFGProperty { "vcfg:name": string; "vcfg:value": string; } + +export interface ArticleContent { + "vkm:name": string; + "vkm:articleBody": string; +} diff --git a/src/helpers/index.ts b/src/helpers/index.ts index 1770a8e..43c931f 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -1,6 +1,6 @@ import type { ChannelAutomationAPI } from "../@types/ChannelAutomationAPI"; import type { TenantProperty } from "../@types/TenantProperty"; -import type { HydraCollection } from "../@types/HydraCollection"; +import type { HydraCollection, ArticleContent } from "../@types/HydraCollection"; import { jwtDecode } from "jwt-decode"; import type { VueCookies } from "vue-cookies"; import { inject } from "vue"; @@ -119,3 +119,29 @@ export async function getTenantProperty( throw error; }); } + +export async function getKMContent( + contentID?: string, +): Promise { + const channelAutomationAPI = await getChannnelAutomationAPI(); + if (!channelAutomationAPI) { + throw new Error("no channel automation api details"); + } + const headers = { + Authorization: `OIDC_id_token ${channelAutomationAPI.authentication}`, + "Accept": "application/ld+json", + }; + // TO-DO do something about lang parameter + const url = `${channelAutomationAPI.host}/km-content-service/${channelAutomationAPI.tenant}/content/vkm:AuthoredContent/${contentID}`; + + return await axios + .get(url, { headers }) + .then((response: { data: ArticleContent }) => { + return response.data["vkm:articleBody"]; + }) + .catch((error) => { + console.error("getTenantProperty: channelAutomationAPI.fetch"); + console.error(error); + throw error; + }); +} diff --git a/src/views/HomePage.vue b/src/views/HomePage.vue index 69bf2d7..a63d736 100644 --- a/src/views/HomePage.vue +++ b/src/views/HomePage.vue @@ -7,7 +7,7 @@
  • Telephony Context diff --git a/src/views/TelephonyContext.vue b/src/views/TelephonyContext.vue index dac0e65..0a1c929 100644 --- a/src/views/TelephonyContext.vue +++ b/src/views/TelephonyContext.vue @@ -1,6 +1,6 @@