Skip to end of banner
Go to start of banner

Learning Hub: Event Subscription API

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Although these APIs are publicly documented, the management of Event Subscriptions is currently handled by Heuristics staff due to the complex templating that is involved.

Overview

Publisher data is not publicly accessible to prevent it from being scraped, and to give Publishers controls over their data.

Therefore, Subscribers must “subscribe” to a Program in order to pull its data from the Hub.

Heuristics staff establish these relationships partially to manage the complex templates that are required, but also to ensure that the Subscriber has a legitimate need to access that Publisher’s data.

API Hostnames

See https://heuristicsolutions.atlassian.net/wiki/spaces/DOCS/pages/3697770890/Learning+Hub#API-Hostnames

Authentication

See https://heuristicsolutions.atlassian.net/wiki/spaces/DOCS/pages/3697770890/Learning+Hub#Authentication

Unless otherwise specified, all endpoints on this page require an API Key with SYSTEM permissions.

Data model

SUBSCRIPTION

A Subscription is a relationship from a Subscriber to a Publisher that allows the Subscriber to receive the Publisher’s data.

Field

Type

Notes

ProgramId

string (25 char)

The identifier of the Subscriber

PublisherProgramId

string (25 char)

The identifier of the Publisher

LastSyncUtc

UTC date/time

UTC timestamp of the last time the Subscriber pulled data from this Publisher

SyncEnabled

boolean

Whether or not the subscription supports the nightly sync process. (Applies to LearningBuilder subscribers only)

Setting this to TRUE does not automatically enable the nightly sync, it just allows the nightly sync to process this subscription.

LbApiPayloadTemplate

JSON

JSON structure mapping different PublisherEventCategory values to the Handlebars template that converts those Events into a batch row payload for LearningBuilder’s WorkflowImportQueue/CreateBatch API.

{
  "{EventCategory}": {
    "label": "human readable note",
    "importProcessId": {WIQ Process Id},
    "batchRowTemplate": "{handlebars template}"
  }
}

See below for detailed explanation

Converting Provider data into Subscriber data

This section applies specifically to subscribers using LearningBuilder. Other systems will need to implement their own mechanism for processing data from the Hub.

Publishers and Subscribers think about and model their data differently, so the publisher’s data typically needs modified or converted before it can be imported into LearningBuilder.

Therefore, each Event Subscription contains one or more templates that convert from the Publisher’s data model into the Subscriber’s data model.

It works like this:

  • When Publishers push data into the Hub, they specify a PublisherEventCategory value. (For example, this might differentiate between data representing a completed course and data representing work history)

  • A Subscriber’s EventSubscription contain contain one or more templates, each one mapped to a specific PublisherEventCategory value. (This allows the subscriber to convert those courses and work history entries in different ways)

  • Each template converts a single PublisherEventData JSON object into a different JSON schema that can be passed to the Subscriber’s API/WorkflowImportQueue/CreateBatch API endpoint.

  • When LearningBuilder synchronizes data, it loops through each PublisherEventData item, converts it using the relevant template, and then makes a single call to API/WorkflowImportQueue/CreateBatch to import the data.

image-20240911-171330.png

Event Subscriptions

“Event Subscriptions” track which Programs will receive the Events published by other Programs.

GET /api/programs/{programId}/eventSubs

Returns a list of Event Subscriptions for the specified Program.

Responses

Response Code

Headers and Body

200 (Ok)

[
  { 
    "ProgramId": "subscriber_program_id", 
    "PublisherProgramId": "publisher_program_id", 
    "CreatedUtc": "UTC date/time",
    "LastSyncUtc": "UTC date/time",
    "SynEnabled": true,
    "LbApiPayloadTemplate": "..."
  },
  ...
]

GET /api/programs/{programId}/eventSubs/{publisherId}

Returns the details about {programId}'s subscription to {publisherId}'s Events.

Responses

Response Code

Headers and Body

200 (Ok)

{ 
  "ProgramId": "foo", 
  "PublisherProgramId": "bar", 
  "CreatedUtc": "UTC date/time",
  "LastSyncUtc": "UTC date/time",
  "SynEnabled": true,
  "LbApiPayloadTemplate": "..."  
}

POST /api/programs/{programId}/eventSubs

Creates a new Event Subscription. Returns an error if it already exists.

Audit fields such as CreatedUtc are assigned during creation.

JSON Payload

{
    "PublisherProgramId": "PublisherId",
    "SyncEnabled": true,
    "LbApiPayloadTemplate": "..."    
}

Responses

Response Code

Headers and Body

201 (Created)

A new Event Subscription was created. No body is returned.

HTTP headers:

Location: /API/programs/{programId}/eventSubs/{pubProgId}


PATCH /api/programs/{programId}/eventSubs/{publisherId}

Updates an existing Event Subscription.

JSON Payload

{
    "LastSyncUtc": "date",
    "SyncEnabled": true,
    "LbApiPayloadTemplate": "..."
}

Responses

Response Code

Headers and Body

204 (No Content)

Update was performed successfully. No body is returned.


DELETE /api/programs/{programId}/eventSubs/{publisherId}

Deletes an existing Event Subscription.

Responses

Response Code

Headers and Body

204 (No Content)

Delete was performed successfully. No body is returned.


  • No labels