Installation
Requesting your credentials
The AdsumClientApi is hosted in a private npm registry, so you will need to contact us.
Once you have your npm authentication token, you'll need to create a .npmrc
file into your root project directory with the following content:
//registry.npmjs.org/:_authToken=YOUR_ADACTIVE_TOKEN
Where YOUR_ADACTIVE_TOKEN
is the provided token.
Add AdsumClientApi to your App
We recommend using Yarn or npm for managing front-end dependencies. If you’re new to package managers, the Yarn documentation is a good place to get started.
To install AdsumClientApi using Yarn, run:
yarn add @adactive/adsum-client-api@^2.0.0
To install AdsumClientApi using npm, run:
npm install --save @adactive/adsum-client-api@^2.0.0
React Native Only - Install peer dependencies
React Native environment requires an extra step by installing react-native-fs
Add it to your project
yarn add react-native-fs
Or
npm install react-native-fs --save
Then link it using:
react-native link react-native-fs
Get API credentials
Please note that you need to be admin on your site to get the credentials.
Download the JSON configuration file as specified in studio documentation
You should have something like this:
{
...
"api": {
"endpoint": "https://api.adsum.io",
"site": 322,
"username": "323-device",
"key": "343169bf805f8abd5fa71a4f529594a654de6afbac70a2d867a8b458c526fb7d"
},
...
}
Integration
- ES6 Modules
- NodeJs
- Browser
import { EntityManager } from '@adactive/adsum-client-api';
// Create an entityManager using the API credentials
const entityManager = new EntityManager({
"endpoint": "https://api.adsum.io",
"site": 322,
"username": "323-device",
"key": "343169bf805f8abd5fa71a4f529594a654de6afbac70a2d867a8b458c526fb7d"
});
// Load the data
entityManager.load().then(() => {
// Retrieve the data you need there
const pois = entityManager.getRepository('Poi').getAll();
});
There is some environment specific implementation, so you need to make sure the proper target is configured to either
node
orweb
depending of the environment your targetting.
const AdsumClientApi = require('@adactive/adsum-client-api');
// Create an entityManager using the API credentials
const entityManager = new AdsumClientApi.EntityManager({
"endpoint": "https://api.adsum.io",
"site": 322,
"username": "323-device",
"key": "343169bf805f8abd5fa71a4f529594a654de6afbac70a2d867a8b458c526fb7d"
});
// Load the data
entityManager.load().then(() => {
// Retrieve the data you need there
const pois = entityManager.getRepository('Poi').getAll();
});
<!DOCTYPE html>
<html>
<body>
<script src="./node_modules/@adactive/adsum-client-api/build/adsum-client-api.browser.js"></script>
<script type="application/javascript">
// AdsumClientApi is available globally
// Create an entityManager using the API credentials
const entityManager = new AdsumClientApi.EntityManager({
"endpoint": "https://api.adsum.io",
"site": 322,
"username": "323-device",
"key": "343169bf805f8abd5fa71a4f529594a654de6afbac70a2d867a8b458c526fb7d"
});
// Load the data
entityManager.load().then(() => {
// Retrieve the data you need there
const pois = entityManager.getRepository('Poi').getAll();
});
</script>
</body>
</html>