7.10.0 • Published 2 years ago

d2l-content-service-api-client v7.10.0

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

d2l-content-service-api-client

Content Service API clients with support for a configurable HTTP client for usage in Node and the browser.

Supported HTTP Clients

Usage (ContentServiceApiClient)

Node

const ContentServiceNodeHttpClient = require('d2l-content-service-node-http-client');
const { ContentServiceApiClient } = require('d2l-content-service-api-client');

const httpClient = new ContentServiceNodeHttpClient({ ... });
const client = new ContentServiceApiClient({ 
    httpClient,
    tenantId: '00000000-0000-0000-0000-000000000000',
    contextType: 'topic',
    contextId: '12345'
});
const result = await client.content.getItem({ id: 'foo' });

Browser

import ContentServiceBrowserHttpClient from 'd2l-content-service-browser-http-client';
import { ContentServiceApiClient } from 'd2l-content-service-api-client';

const httpClient = new ContentServiceBrowserHttpClient({ ... });
const client = new ContentServiceApiClient({ 
    httpClient,
    tenantId: '00000000-0000-0000-0000-000000000000',
    contextType: 'topic',
    contextId: '12345'
});
const result = await client.content.getItem({ id: 'foo' });

Parameters

  • httpClient: HTTP client
  • tenantId: LMS tenant ID. Used in tenant-scoped API calls.
  • contextType (optional): topic or placement. This option describes the LE context in which the API calls are being made. This is only valid when using LE user tokens, and provides access to Content Service objects based on LE resources, such as topics or ISF/QuickLinks/Attachments placements. It provides users with access to certain Content Service objects based on their LE permissions/enrolments.
  • contextId: The ID of the contextType. For instance, if contextType is topic, this would be the topic ID

Usage (BrightspaceApiClient)

Node

const ContentServiceNodeHttpClient = require('d2l-content-service-node-http-client');
const { BrightspaceApiClient } = require('d2l-content-service-api-client');

const httpClient = new ContentServiceNodeHttpClient({ ... });
const client = new BrightspaceApiClient({ httpClient });
const result = await client.getContentServiceEndpoint();

Browser

import ContentServiceBrowserHttpClient from 'd2l-content-service-browser-http-client';
import { BrightspaceApiClient } from 'd2l-content-service-api-client';

const httpClient = new ContentServiceBrowserHttpClient({ ... });
const client = new ContentServiceApiClient({ httpClient });
const result = await client.getContentServiceEndpoint();

Parameters

  • httpClient: HTTP client

Usage (CaptureApiClient)

Node

const ContentServiceNodeHttpClient = require('d2l-content-service-node-http-client');
const { CaptureApiClient } = require('d2l-content-service-api-client');

const httpClient = new ContentServiceNodeHttpClient({ ... });
const client = new CaptureApiClient({ httpClient });
const result = await client.getEvent({ id, orgUnitId });

Browser

import ContentServiceBrowserHttpClient from 'd2l-content-service-browser-http-client';
import { CaptureApiClient } from 'd2l-content-service-api-client';

const httpClient = new ContentServiceBrowserHttpClient({ ... });
const client = new CaptureApiClient({ httpClient });
const result = await client.getEvent({ id, orgUnitId });

Parameters

  • httpClient: HTTP client

Supported APIs

View the source code to see supported API methods. If something is missing, add it!

Creating a custom HTTP Client

You can make your own HTTP client by extending AbstractHttpClient (a named export of d2l-content-service-api-client) and implementing the required functions. See the existing HTTP client implementations for examples.

7.8.0

2 years ago

7.9.1

2 years ago

7.9.0

2 years ago

7.10.0

2 years ago

7.4.0

2 years ago

7.3.1

2 years ago

7.0.4

2 years ago

7.3.0

2 years ago

7.2.1

2 years ago

7.0.3

2 years ago

7.2.0

2 years ago

7.0.2

2 years ago

7.1.0

2 years ago

7.0.1

2 years ago

7.7.0

2 years ago

7.6.1

2 years ago

7.6.0

2 years ago

7.0.6

2 years ago

7.5.0

2 years ago

7.0.5

2 years ago

6.1.25

2 years ago

6.1.24

2 years ago

6.1.23

2 years ago

6.1.22

2 years ago

6.1.21

2 years ago

6.1.20

2 years ago

6.1.19

2 years ago