Content Module


Version Content 1.2.0

Table of Contents

Usage

To use the Content module, you can import it into your project from the Firebolt SDK:

import { Content } from '@firebolt-js/discovery-sdk'

Overview

undefined

Methods

listen

To listen to a specific event pass the event name as the first parameter:

listen(event: string, callback: (data: any) => void): Promise<number>

Parameters:

Param Type Required Summary
event string Yes The event to listen for, see Events.
callback function Yes A function that will be invoked when the event occurs.

Promise resolution:

Type Description
number Listener ID to clear the callback method and stop receiving the event, e.g. Content.clear(id)

Callback parameters:

Param Type Required Summary
data any Yes The event data, which depends on which event is firing, see Events.

To listen to all events from this module pass only a callback, without specifying an event name:

listen(callback: (event: string, data: any) => void): Promise<number>

Parameters:

Param Type Required Summary
callback function Yes A function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

Callback parameters:

Param Type Required Summary
event string Yes The event that has occured listen for, see Events.
data any Yes The event data, which depends on which event is firing, see Events.

Promise resolution:

Type Description
number Listener ID to clear the callback method and stop receiving the event, e.g. Content.clear(id)

See Listening for events for more information and examples.

once

To listen to a single instance of a specific event pass the event name as the first parameter:

once(event: string, callback: (data: any) => void): Promise<number>

The once method will only pass the next instance of this event, and then dicard the listener you provided.

Parameters:

Param Type Required Summary
event string Yes The event to listen for, see Events.
callback function Yes A function that will be invoked when the event occurs.

Promise resolution:

Type Description
number Listener ID to clear the callback method and stop receiving the event, e.g. Content.clear(id)

Callback parameters:

Param Type Required Summary
data any Yes The event data, which depends on which event is firing, see Events.

To listen to the next instance only of any events from this module pass only a callback, without specifying an event name:

once(callback: (event: string, data: any) => void): Promise<number>

Parameters:

Param Type Required Summary
callback function Yes A function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

Callback parameters:

Param Type Required Summary
event string Yes The event that has occured listen for, see Events.
data any Yes The event data, which depends on which event is firing, see Events.

Promise resolution:

Type Description
number Listener ID to clear the callback method and stop receiving the event, e.g. Content.clear(id)

See Listening for events for more information and examples.

requestUserInterest

Provide information about the entity currently displayed or selected on the screen.

function requestUserInterest(
  type: InterestType,
  reason: InterestReason,
): Promise<InterestResult>

Parameters:

Param Type Required Description
type InterestType true
values: 'interest' \| 'disinterest'
reason InterestReason true
values: 'playlist' \| 'reaction' \| 'recording'

Promise resolution:

InterestResult

Capabilities:

Role Capability
uses xrn:firebolt:capability:discovery:interest

Examples

Default Example

JavaScript:

import { Content } from '@firebolt-js/discovery-sdk'

let interest = await Content.requestUserInterest('interest', 'playlist')
console.log(interest)

Value of interest:

{
	"appId": "cool-app",
	"entity": {
		"identifiers": {
			"entityId": "345",
			"entityType": "program",
			"programType": "movie"
		},
		"info": {
			"title": "Cool Runnings",
			"synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.",
			"releaseDate": "1993-01-01T00:00:00.000Z",
			"contentRatings": [
				{
					"scheme": "US-Movie",
					"rating": "PG"
				},
				{
					"scheme": "CA-Movie",
					"rating": "G"
				}
			]
		}
	}
}
JSON-RPC:

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "Content.requestUserInterest",
  "params": {
    "type": "interest",
    "reason": "playlist"
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "appId": "cool-app",
    "entity": {
      "identifiers": {
        "entityId": "345",
        "entityType": "program",
        "programType": "movie"
      },
      "info": {
        "title": "Cool Runnings",
        "synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.",
        "releaseDate": "1993-01-01T00:00:00.000Z",
        "contentRatings": [
          {
            "scheme": "US-Movie",
            "rating": "PG"
          },
          {
            "scheme": "CA-Movie",
            "rating": "G"
          }
        ]
      }
    }
  }
}

Events

userInterest

function listen('userInterest', () => void): Promise<number>

See also: listen(), once(), clear().

Event value:

InterestEvent

Capabilities:

Role Capability
uses xrn:firebolt:capability:discovery:interest

Examples

Default Example

JavaScript:

import { Content } from '@firebolt-js/discovery-sdk'

Content.listen('userInterest', (interest) => {
  console.log(interest)
})

Value of interest:

{
	"appId": "cool-app",
	"type": "interest",
	"reason": "playlist",
	"entity": {
		"identifiers": {
			"entityId": "345",
			"entityType": "program",
			"programType": "movie"
		},
		"info": {
			"title": "Cool Runnings",
			"synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.",
			"releaseDate": "1993-01-01T00:00:00.000Z",
			"contentRatings": [
				{
					"scheme": "US-Movie",
					"rating": "PG"
				},
				{
					"scheme": "CA-Movie",
					"rating": "G"
				}
			]
		}
	}
}
JSON-RPC:

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "Content.onUserInterest",
  "params": {
    "listen": true
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "appId": "cool-app",
    "type": "interest",
    "reason": "playlist",
    "entity": {
      "identifiers": {
        "entityId": "345",
        "entityType": "program",
        "programType": "movie"
      },
      "info": {
        "title": "Cool Runnings",
        "synopsis": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc.",
        "releaseDate": "1993-01-01T00:00:00.000Z",
        "contentRatings": [
          {
            "scheme": "US-Movie",
            "rating": "PG"
          },
          {
            "scheme": "CA-Movie",
            "rating": "G"
          }
        ]
      }
    }
  }
}

Types

InterestResult

type InterestResult = {
  appId: string
  entity: EntityDetails
}

See also:

EntityDetails


InterestEvent

type InterestEvent = {
  appId: string
  type: InterestType
  reason: InterestReason
  entity: EntityDetails
}

See also:

InterestType InterestReason EntityDetails