Giter Club home page Giter Club logo

gigya-api-wrapper's Introduction

Gigya API wrapper

This is a simple Gigya JS api wrapper which works with promises and should make life easier for developers working with Gigya markup extensions.

Scope

Currently this library does not include the custom JS registration, login and password reset API functions as it is intended to be used next to the Gigya markup extensions. The Gigya Markup extensions deal with the registration, account linking, password reset and other flows on their own as long as you add the proper data and class attributes on their HTML.

A later release might possibly contain the other API functions so you can code a completely custom Gigya RaaS implementation.

How to use...

  npm i gigya-api-wrapper

Initialisation

import GigyaWrapper from 'gigyaWrapper';

this.gigyaWrapperInstance = new GigyaWrapper({
  apiKey: '<api_key>',
  containerID: 'wrapper',
  screenSet: 'screen-set', // could be on gigya's servers or local
  lang: 'en',
  autoLogin: true,
  debug: false,
  https: true
});

// Listen to the async load event of the Gigya library.
this.gigyaWrapperInstance.onLibraryReady().then( ( gigyaObject )=>{
  // do stuffs
});

A common use case

Initialise like the above code sample.

// Listen to user events
this.gigyaWrapperInstance.registerEventListeners({
  onLogin: ()=>{ /* show profile */ },
  onLogout: ()=>{
    //shortcut for the showScreenSet function.
    this.gigyaWrapperInstance.showLoginScreen();
  }
});

this.gigyaWrapperInstance.checkLoggedInStatus().then( ( response )=>{
    if( response.loggedIn ){
      // show profile
    }
    else {
      this.gigyaWrapperInstance.showLoginScreen();
    }
  }
});

Other common functions

Remember to always initialise (onLibraryReady()) first so the Gigya object is available.

// Return promises
this.gigyaWrapperInstance.getAccountInfo();
this.gigyaWrapperInstance.logout();
this.gigyaWrapperInstance.getSchema();
this.gigyaWrapperInstance.getPolicies();
this.gigyaWrapperInstance.getScreenSets();

// ScreenSet handling
// See esdoc directory for all property explanations
this.gigyaWrapperInstance.showLoginScreen();

this.gigyaWrapperInstance.showScreenSet({
  screenSet: 'screen-set',
  containerID: 'wrapper',
  startScreen: 'gigya-login-screen'
});

this.gigyaWrapperInstance.hideScreenSet({
  screenSet: 'screen-set',
  containerID: 'wrapper'
});

// Sharing
// See esdoc directory for all property explanations
this.gigyaWrapperInstance.share({
  provider: 'facebook',
  url: 'http://timbenniks.nl',
  title: 'Tims website',
  subtitle: 'Times website subtitle',
  description: 'Tims website is pretty cool man',
  imageurl: 'http://timbenniks.nl/assets/favicon.png'
});

Development

You need to have node and npm installed to be able to work on this code. If you intend to add or change code you will need to re-render the esdoc.

Install esdoc

npm install -g esdoc

Run esdoc

esdoc -c esdoc.json

Installation

npm install

Tests

npm run test

Dev

npm run dev

Build

npm run build

gigya-api-wrapper's People

Contributors

timbenniks avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.