2.4.1 • Published 3 months ago

@happy-horizon/f19-sdk-js v2.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

F19 SDK JS

Language Language

Javascript SDK for the F19 digital reporting platform.

Getting Started

How to install

Installing

A step by step series of examples that tell you how to get a development env running

npm install @happy-horizon/f19-sdk-js

⚠️ This SDK uses the Fetch API under the hood. If your environment doesn't support it, you need to install a polyfill like isomorphic-fetch or node-fetch

Usage

Import the package using ES6 imports or CommonJS require

import F19 from "@happy-horizon/f19-sdk-js";
const F19 = require("@happy-horizon/f19-sdk-js");

Create a new instance of the F19 class with your API key, Client Id, and base URL

const client = new F19({
    apiKey: "[F19_API_KEY]",
    clientId: "[F19_CLIENT_ID]",
    baseUrl: "[F19_BASE_URL]"
});

Now you can access all anonymous methods using the client object.

If you want to access the personal methods, you need to log in first. You can do this by redirecting the user to the F19 login page and then redirecting them back after logging in using a callback URL.

// Define the callback URL (you would replace this with your actual callback URL)
const loginUrl = client.getAuthUrl("https://your.callback.url");

After the user has logged in, they will be redirected back to your callback URL with impersonation options in the request body. You can use these impersonation options to create a new instance of the client that can access the personal methods.

const client = new F19(
    {
        apiKey: "[F19_API_KEY]",
        clientId: "[F19_CLIENT_ID]",
        baseUrl: "[F19_BASE_URL]"
    },
    {
        userId: body.UserId,
        keyThumbprint: body.KeyThumbprint,
        cacheDifferentiator: body.CacheDifferentiator,
        authorizationToken: body.AuthorizationToken
    }
);

Available methods

GroupingMethod NameParameters
articlesgetAllByProjectIdprojectId: string
getByIdarticleId: string
assetsgetImageByNameprojectId: string, name: string
getDownloadByNameprojectId: string, name: string
getBlobByTokentoken: string
channelgetAll
chartsgetAllprojectId: string
getByIdchartId: string
downloadsgetByIdid: string
getAllByProjectIdprojectId: string
facetNavigationsgetAllprojectId: string
getByIdfacetId: string
imagesgetAllprojectId: string
getByIdimageId: string
noncegetNonce
projectsgetAll
getByIdid: string
reportsgetByIdid: string
getAllByProjectIdid: string
tablesgetAllprojectId: string
getByIdtableId: string
tokenstokenRequesturl: string, authorizationToken: string
getPersonalauthorizationToken: string
getAnonymousauthorizationToken: string
websitesgetAll
getByAliasalias: string
getCurrent

Example usage

// Define the projectId (you would replace this with your actual project ID)
const projectId = "your_project_id_here";

// Call the getAllByProjectId method
client.article
    .getAllByProjectId(projectId)
    .then(result => {
        // Handle the result here
        console.log("Result:", result);
    })
    .catch(error => {
        // Handle any errors that occur
        console.error("Error:", error);
    });
2.4.1

3 months ago

2.4.0

3 months ago

2.3.0

3 months ago

2.2.9

3 months ago

2.2.8

3 months ago

2.2.7-0

3 months ago

2.2.6

3 months ago

2.2.5

3 months ago

2.2.4

3 months ago

2.2.3

3 months ago

2.2.2

3 months ago

2.2.1

3 months ago

2.2.0

3 months ago

2.1.1

4 months ago

2.1.0

4 months ago

2.0.4

4 months ago

2.0.3

4 months ago

2.0.2

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

1.0.0

6 months ago

0.1.10

6 months ago

0.1.9

7 months ago

0.1.8

7 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

9 months ago

0.1.1

9 months ago

0.1.0

9 months ago