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

@ingresse/sdk

v0.5.0

Published

Ingresse platform Javascript SDK

Downloads

197

Readme

@ingresse/sdk

Facility to use Ingresse's API.

Install

npm i -S @ingresse/sdk

Usage

import SDK, {
    /**
     * Tools
     */
    credentials,
    options,

    /**
     * Utilities
     */
    cookies,
    request,
    storage,
    utils,

    /**
     * Use API endpoints
     */
    auth,
    company,
    entrance,
    event,
    password,
    sales,
    user, // will be deprecated soon
    users,

    /**
     * Use Microservices Endpoints
     */
    checkin,            // reference to 'https://checkin.ingresse.com'
    coupons,            // reference to 'https://coupon.ingresse.com'
    events,             // reference to 'https://event.ingresse.com'
    financeTransfers,   // reference to 'https://finance.ingresse.com', without env support
    shop,               // reference to 'https://shop.ingresse.com'
    tickets,            // reference to 'https://ticket.ingresse.com'

    /**
     * Lambdas as Subdomains
     */
    purchases,  // consume 'https://my-transactions.ingresse.com', without env support
    score,      // consume 'https://beta-score.ingresse.com', without env support
} from '@ingresse/sdk';

/**
 * Initialize
 */
SDK({
    /**
     * Required
     */
    apiKey: 'your-api-key',

    /**
     * Optionals
     */
    company   : 1,              // recommended
    appName   : 'backoffice',   // help to don't mess with user's session
    currency  : 'BRL',
    locale    : 'pt-BR',
    env       : 'integration',  // postfix/prefix to api and microservices: 'api-integration.ingresse.com' / 'integration-ticket.ingresse.com'
    exceptions: {
        '6061': 'Não foi possível autenticar o usuário.',
    },

    /**
     * Optionals Lambdas Keys
     */
    purchasesKey: 'purchases-lambda-x-api-key',
    scoreKey    : 'score-lambda-basic-authorization-key',
});

Auth/User

const userEmail    = '[email protected]';
const userPassword = 'user-password';

auth.login(userEmail, userPassword)
.then((authResponse) => {
    console.info('Success on Authentication Login', authResponse);

    const userId    = authResponse.userId;
    const userQuery = {
        fields: 'id,name,email,pictures',
    };

    users.get(userId, userQuery)
    .then((userResponse) => {
        console.info(`Success on fetch User ${userId} data`, userResponse);
    })
    .catch((userError) => {
        console.error(`Error on fetch User ${userId} data`, userError);
    });
})
.catch((authError) => {
    console.error('Error on Authentication Login', authError);
});

Event

const eventId    = 00000;
const eventQuery = {
    fields: 'id,title,description,poster,venue'
};

event.get(eventId, eventQuery)
.then((eventResponse) => {
    console.info(`Success on fetch Event "${eventId}" data`, eventResponse);
})
.catch((eventError) => {
    console.error(`Error on fetch Event "${eventId}" data`, eventError);
});

Event

// API          Event GET = public  (anyone can access data)
// Microservice Event GET = private (only with login and specifics permissions)

const eventId = 000000;

events.get(eventId)
.then((eventResponse) => {
    console.info(`Success on fetch Event "${eventId}" data`, eventResponse);

    const ticketsQuery = {
        type    : 'group',
        pageSize: 5,
    };

    tickets.get(eventId, ticketsQuery)
    .then((ticketsResponse) => {
        console.info(`Success on fetch Event ${eventId} Tickets`, ticketsResponse);
    })
    .catch((ticketsError) => {
        console.error(`Error on fetch Event ${eventId} Tickets`, ticketsError);
    });
})
.catch((eventError) => {
    console.error(`Error on fetch Event "${eventId}" data`, eventError);
});

Scenary

In order to many cool-weekly launched features, we can't maitain the SDK updated with all of Ingresse's existent endpoints. So, in case you are looking for some method to a certain endpoint and you can't find it in our most-recent SDK release, this extra resource can help.

Generic Request

As you may already familiar with Fetch API, you can use this similar resource to make generic requests to Ingresse's API:

API enpoints

This example will try to execute a HTTP POST to https://api.ingresse.com/not-covered-endpoint/subpath-if-needed, passing some query string parameters and body data. (It's just an example, will intentionally fails).

Use this example base to every endpoint over api.ingresse.com.

import { request } from '@ingresse/sdk';

const endpoint = '/not-covered-endpoint/subpath-if-needed';
const settings = {
    method: 'POST',
    query: {
        term: 'no need to use encoders, the SDK do this for you',
    },
    body: {
        title: 'Example, yo!',
        description: 'no need to use "JSON.parse" to the body data, the SDK do this for us',
    },
};

request(endpoint, settings)
.then((response) => {
    console.info(`Fetched response from uncovered endpoint "${endpoint}"`, response);
})
.catch((error) => {
    console.error(`Error on fetch uncovered endpoint "${endpoint}"`, error);
});

Microservices and Lambdas enpoints

| Microservice | Subdomain | | ------------ | ---------------------- | | checkin | checkin.ingresse.com | | coupons | coupon.ingresse.com | | events | event.ingresse.com | | finance | finance.ingresse.com | | shop | shop.ingresse.com | | tickets | ticket.ingresse.com |

| Lambda | Subdomain | | ----------| ------------------------------ | | purchases | my-transactions.ingresse.com | | score | beta-score.ingresse.com |

This examples will try to execute a HTTP GET in some of Ingresse's Microservices endpoints. (Will intentionally fails).

Use this example base to every endpoint over everyelse subdomain of .ingresse.com.

import {
    checkin,   // MS
    purchases, // Lambda
} from '@ingresse/sdk';

const endpoint = '/not-covered-endpoint/subpath-if-needed';
const settings = {
    query: {
        session_id: '54321',
    },
};

// Checkin MS (checkin.ingresse.com)
checkin.request(endpoint, settings)
.then((response) => {
    console.info(`Checkin MS: Fetched response from uncovered endpoint "${endpoint}"`, response);
})
.catch((error) => {
    console.error(`Checkin MS: Error on fetch uncovered endpoint "${endpoint}"`, error);
});

// Purchases Lambda (my-transactions.ingresse.com)
purchases.request(endpoint, settings)
.then((response) => {
    console.info(`Events MS: Fetched response from uncovered endpoint "${endpoint}"`, response);
})
.catch((error) => {
    console.error(`Events MS: Error on fetch uncovered endpoint "${endpoint}"`, error);
});

Development

More details to local development and publish steps