@agm-as/bridge

agm services bridge

Usage no npm install needed!

<script type="module">
  import agmAsBridge from 'https://cdn.skypack.dev/@agm-as/bridge';
</script>

README

@agm-as/bridge

provides easy access to agm-services and their data.

npm install @agm-as/bridge

Publishing

Update the version in package.json according to the best practices of semantic versioning, and commit (the version change) as :bookmark: Update bridge version, then run npm publish to realise the changes.

Notes

  • organization is a filtering object that takes either firebaseId, titleId, environmentId, hostname, or titleCode.
  • user is a filtering object that takes either emailAddress, customerId, or customerNumber.
  • lilypadsOptions is an object sent to the lilypads npm module.

Methods

orgs

import * as orgs from '@agm-as/bridge/orgs';

orgs.getOrganizations({hostname: 'varden.no'})
    .then(console.log);

getOrganizations (organization, lilypadsOptions)

import getOrganizations from '@agm-as/bridge/orgs';

getOrganizations().then((organizations) => console.log(organizations));

users

import * as users from '@agm-as/bridge/users';

users.getUserConstellation({emailAddress: 'demo-n@agderposten.no'})
    .then(console.log);

authenticateUser (username, password, organization)

import authenticateUser from '@agm-as/bridge/users/authenticate';
// or import {authenticateUser} from '@agm-as/bridge/users';

authenticateUser('demo-n@agderposten.no', 'DemoUser5678', {titleId: 1})
    .then((result) => console.log(result));

logoutUser (token)

import logoutUser from '@agm-as/bridge/users/logout';
// or import {logoutUser} from '@agm-as/bridge/users';

logoutUser(token)
    .then(() => console.log('logged out'));

validateUserAccess (token, organization, requestOptions)

  • requestOptions
    • requestOptions.url (string): resource url
    • requestOptions.cxenseUserId (string): cxense user id
    • requestOptions.ipAddress (string): client ip address
    • requestOptions.referrer (string): client referrer
import validateUserAccess from '@agm-as/bridge/users/validate-access';
// or import {validateUserAccess} from '@agm-as/bridge/users';

validateUserAccess(token, {titleId: 1}, {url: 'https://agderposten.no'})
    .then((result) => console.log(result));

getUserConstellation (user, organization, requestOptions, lilypadsOptions)

  • requestOptions
    • requestOptions.token (string): user authentication token
import getUserConstellation from '@agm-as/bridge/users/constellation';
// or import {getUserConstellation} from '@agm-as/bridge/users';

getUserConstellation({customerId: '920538'})
    .then((constellation) => console.log(constellation));

news

import * as news from '@agm-as/bridge/news';

news.getNews({url: 'https://www.agderposten.no/trafikk/oppdaget-feil-pa-23-km-midtdeler-pa-e18'})
    .then(console.log);

getNews (news, lilypadsOptions)

import getNews from '@agm-as/bridge/news';

getNews({url: 'https://www.agderposten.no/trafikk/oppdaget-feil-pa-23-km-midtdeler-pa-e18'})
    .then((news) => console.log(news));