Content

    Content


    Article summary


    title: Content

    version: 1.2.0
    layout: default
    sdk: discovery

    # 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:

    ParamTypeRequiredSummary
    eventstringYesThe event to listen for, see Events.
    callbackfunctionYesA function that will be invoked when the event occurs.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Content.clear(id)

    Callback parameters:

    ParamTypeRequiredSummary
    dataanyYesThe 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:

    ParamTypeRequiredSummary
    callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

    Callback parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event that has occured listen for, see Events.
    dataanyYesThe event data, which depends on which event is firing, see Events.

    Promise resolution:

    TypeDescription
    numberListener 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:

    ParamTypeRequiredSummary
    eventstringYesThe event to listen for, see Events.
    callbackfunctionYesA function that will be invoked when the event occurs.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Content.clear(id)

    Callback parameters:

    ParamTypeRequiredSummary
    dataanyYesThe 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:

    ParamTypeRequiredSummary
    callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

    Callback parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event that has occured listen for, see Events.
    dataanyYesThe event data, which depends on which event is firing, see Events.

    Promise resolution:

    TypeDescription
    numberListener 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:

    ParamTypeRequiredDescription
    typeInterestTypetrue
    values: 'interest' \| 'disinterest'
    reasonInterestReasontrue
    values: 'playlist' \| 'reaction' \| 'recording'

    Promise resolution:

    InterestResult

    Capabilities:

    RoleCapability
    usesxrn: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:

    RoleCapability
    usesxrn: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



    Was this article helpful?

    What's Next