Lists operations

Lists operations are responsible for communicating with Client API and internal SDK methods related to Fans United entities.

The namespace is of course called lists. All methods return promises. The general design of the namespace follows this pattern unless stated otherwise:

📘

General call:

sdk.lists.someMethod()
  .then((responseObject) => {
    // do something with responseObject
}).catch((error) => {
  	// error handling
});

The responses are comprised of different objects you can find here.

Lists related operations

Get list content

Method: getListContent(listId, filters?, disableCache?)

Models:

Method returns content of specific list. The content in the list can be the following Fans United entities: Top X, Match Quiz, Leaderboard Template, Classic Quiz, Either/Or or Poll.

No authentication required.

The response from API is cached for 1 minute. With disableCache argument you can avoid cached response.

Filters object:

  • limit: number . How many entities will be returned in list. Maximum value is 50
  • page: number. The number of the page.

If no value is provided for filters, then no filters will be aplied.

❗️

IMPORTANT:

  1. Filters will be NOT considered by Client API for CUSTOM type list.
  2. The instance for entityModel property is based on the entity type using discriminated union type. This means that the following entityType -> entityModel are applied:
    1. CLASSIC_QUIZ -> ClassicQuizBasicModel
    2. EITHER_OR -> EitherOrBasicModel
    3. POLL -> PollBasicModel
    4. TOP_X -> GamesListModel
    5. MATCH_QUIZ -> GamesListModel
    6. LEADERBOARD_TEMPLATES -> TemplateModel

📘

Example call:

const filters = {
  limit: 1,
  page: 1
};

sdk.lists
  .getListContent("listId", filters, true)
  .then((response) => {
    // Handle response
  })
  .catch((error) => {
    // Handle error
  });

Example result

{
   meta: {
      pagination: {
         currentPage: 1,
         itemsPerPage: 1,
         totalItems: 1,
         numberOfPages: 1
      }
   },
   data: [
      {
         entityId: "CkuDxfuv3YUJlcGWbZR0",
         entityType: "CLASSIC_QUIZ",
         entityModel: ClassicQuizBasicModel // can be null
      }
   ]
}