diff --git a/src/openrpc/content.json b/src/openrpc/content.json index 321d9c784..63d2925be 100644 --- a/src/openrpc/content.json +++ b/src/openrpc/content.json @@ -41,7 +41,7 @@ "result": { "name": "interest", "schema": { - "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/Interest" + "$ref": "#/components/schemas/InterestResult" }, "summary": "The EntityDetails data." }, @@ -109,7 +109,7 @@ "result": { "name": "interest", "schema": { - "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/Interest" + "$ref": "#/components/schemas/InterestEvent" }, "summary": "The EntityDetails data." }, @@ -149,6 +149,50 @@ } } ] - } - ] -} + } + ], + "components": { + "schemas": { + "InterestResult": { + "title": "InterestResult", + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + }, + "required": [ + "appId", + "entity" + ] + }, + "InterestEvent": { + "title": "InterestEvent", + "type": "object", + "properties": { + "appId": { + "type": "string" + }, + "type": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestType" + }, + "reason": { + "$ref": "https://meta.comcast.com/firebolt/discovery#/definitions/InterestReason" + }, + "entity": { + "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" + } + }, + "required": [ + "appId", + "entity", + "type", + "reason" + ] + } + } + } +} \ No newline at end of file diff --git a/src/schemas/discovery.json b/src/schemas/discovery.json index 58ccb2c1f..1c13435a7 100644 --- a/src/schemas/discovery.json +++ b/src/schemas/discovery.json @@ -74,28 +74,6 @@ "reaction", "recording" ] - }, - "Interest": { - "title": "Interest", - "type": "object", - "properties": { - "appId": { - "type": "string" - }, - "type": { - "$ref": "#/definitions/InterestType" - }, - "reason": { - "$ref": "#/definitions/InterestReason" - }, - "entity": { - "$ref": "https://meta.comcast.com/firebolt/entity#/definitions/EntityDetails" - } - }, - "required": [ - "appId", - "entity" - ] } - } + } } diff --git a/src/sdks/discovery/test/suite/content.test.ts b/src/sdks/discovery/test/suite/content.test.ts index 810437f8b..1ab4e98c8 100644 --- a/src/sdks/discovery/test/suite/content.test.ts +++ b/src/sdks/discovery/test/suite/content.test.ts @@ -20,7 +20,7 @@ import { test, expect } from "@jest/globals"; import { Content } from "../../build/javascript/src/firebolt-discovery"; test("Content.requestUserInterest()", () => { - return Content.requestUserInterest(Content.InterestType.INTEREST, Content.InterestReason.PLAYLIST).then((interest: Content.Interest) => { + return Content.requestUserInterest(Content.InterestType.INTEREST, Content.InterestReason.PLAYLIST).then((interest: Content.InterestResult) => { const entity = interest.entity const appId = interest.appId expect(appId).toBeDefined() @@ -28,3 +28,16 @@ test("Content.requestUserInterest()", () => { expect(entity.info.title).toBe("Cool Runnings") }) }); + +test("Content.onUserInterest()", () => { + return Content.listen('userInterest', (interest: Content.InterestEvent) => { + const entity = interest.entity + const appId = interest.appId + const reason = interest.reason + expect(interest['type']).toBeDefined() + expect(reason).toBeDefined() + expect(appId).toBeDefined() + expect(entity).toBeDefined() + expect(entity.info.title).toBe("Cool Runnings") + }) +});