Widgets is a factory for creating widgets. It's possible to build your own widgets using the WidgetApi but most people will prefer to use these easy methods.

Hierarchy

  • Widgets

Constructors

Properties

Methods

Constructors

  • Initialize a new Widgets instance.

    Parameters

    Returns Widgets

    Example

    Browser example

    var widgets = new squatch.Widgets({tenantAlias:'test_12b5bo1b25125'});
    

    Example

    Browserify/Webpack example

    var Widgets = require('@saasquatch/squatch-js').Widgets;
    var widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});

    Example

    Babel+Browserify/Webpack example

    import {Widgets} from '@saasquatch/squatch-js';
    let widgets = new Widgets({tenantAlias:'test_12b5bo1b25125'});

Properties

Instance of WidgetApi

domain: string

SaaSquatch domain for API requests

Default

"https://app.referralsaasquatch.com"
npmCdn: string

Hosted CDN for npm packages

Default

"https://fast.ssqt.io/npm"
tenantAlias: string

Tenant alias of SaaSquatch tenant

Methods

  • Autofills a referral code into an element when someone has been referred. Uses squatchReferralCookie behind the scenes.

    Parameters

    • selector: string | Function

      Element class/id selector, or a callback function

    Returns Promise<void>

  • This function calls the render method, and it renders the widget if it is successful. Otherwise it shows the "error" widget.

    Parameters

    Returns Promise<undefined | WidgetResult>

    json object if true, with a Widget and user details

  • This function calls the upsertUser method, and it renders the widget if it is successful. Otherwise it shows the "error" widget.

    Parameters

    Returns Promise<{
        user: any;
        widget: any;
    }>

    json object if true, with a Widget and user details

Generated using TypeDoc