npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dintero/discounts-web-sdk

v0.2.14

Published

Dintero Discounts SDK for web frontends

Downloads

149

Readme

Dintero Discounts JavaScript SDK for frontend applications

Build Status npm latest version

Use this SDK in your frontend application to embed one or more discounts from the Dintero Discount Service service in your webpage.

Learn more about the Dintero Discount Service at docs.dintero.com

Installation

NPM package

npm install @dintero/discounts-web-sdk

Inline HTML JavaScript example getting a list of discounts with API access

In this example the SDK will try to fetch data from the discount service.

Make sure to configure the plugin with an API client that only has grants giving access to the public:discounts scope.

<script type="text/javascript">
    const container = document.getElementById("checkout-container");
    discounts.embed({
        container: document.getElementById("deals-container"),
        api: {
            account: "P00000000",
            key: "public_api_key",
            secret: "abcdef01-2345-6789-abcd-ef0123456789",
        },
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
    });
</script>

Inline HTML JavaScript example getting a single discounts with API access

In this example the SDK will try to fetch data from the discount service for a given discountId.

Make sure to configure the plugin with an API client that only has grants giving access to the public:discounts-scope.

<script type="text/javascript">
    const container = document.getElementById("checkout-container");
    discounts.embed({
        container: document.getElementById("deals-container"),
        api: {
            account: "P00000000",
            key: "public_api_key",
            secret: "abcdef01-2345-6789-abcd-ef0123456789",
            discountId: "1234",
        },
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
    });
</script>

Inline HTML JavaScript example with discount objects

In this example the SDK is supplied with a list of discount objects directly.

<script type="text/javascript">
    const container = document.getElementById("checkout-container");
    discounts.embed({
        container: document.getElementById("deals-container"),
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        },
        discounts: [
            {
                id: "1",
                name: "Testvare",
                description: "Beskrivelse av testvare",
                requirement: {
                    item: { items: [{ id: "testvare-1" }] },
                    customer: {},
                    store_ids: ["*"],
                    purchase_to: "2030-06-13T21:59:00Z",
                    purchase_from: "2080-06-06T22:00:00Z",
                },
                limitation: {},
                reward: { type: "discount_item_new_price", value: 5000 },
                created_by: "DinteroTest",
                created_at: "2021-06-04T10:21:18.029Z",
                updated_at: "2021-06-04T10:21:18.029Z",
                receipt_text: "Ukens tilbud",
                type: "item",
                links: [
                    {
                        rel: "medium_discount_image",
                        href: "https://uploads-ssl.webflow.com/5f023ba9549ac22870f32943/5f1333ae5a496b0e0476975e_dintero-logo.svg",
                    },
                ],
                metadata: {
                    label: "Før: 100,-",
                    subtitle: "Ukens tilbud",
                    campaign_id: 1,
                },
                active: true,
            },
        ],
    });
</script>

Inline HTML JavaScript example with discount webshop links and their link behaviour

In this example the SDK will try to fetch data from the discount service with webshop links.

The behaviour of opening links can be adjusted using linkTarget in the configuration.

_self (default) will open the webshop link directly on the same tab.

_blank will open the webshop link in a new tab.

<script type="text/javascript">
    const container = document.getElementById("checkout-container");
    discounts.embed({
        container: document.getElementById("deals-container"),
        linkTarget: '_blank'
        api:{
            account: 'P00000000',
            key: 'public_api_key',
            secret: 'abcdef01-2345-6789-abcd-ef0123456789',
        },
        theme: {
            fontSize: "14px",
            color: "rgba(0,0,0,1)",
            primary: "hotpink",
            secondary: "aqua",
            background: "#fff",
        }
    });
</script>

Bugs

Bugs can be reported to https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues

Security

Contact us at [email protected]

Browser support

All major modern browsers above version N - 1, where N is the most recent version.

Building from source

yarn install
yarn run build

Creating a new release

  1. Enforce all commits to the master branch to be formatted according to the Angular Commit Message Format
  2. When merged to master, it will automatically be released with semantic-release