Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@gusto/embedded-api

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gusto/embedded-api

Gusto API JavaScript client library.

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
32K
-5.04%
Maintainers
1
Weekly downloads
 
Created
Source

@gusto-embedded/embedded-api

Client SDK responsible for making requests to the Gusto public API.

Getting Started

Install NPM package

npm i @gusto/embedded-api

Usage

import { GustoApi } from '@gusto/embedded-api';

// default value for OpenAPI.BASE is 'https://api.gusto-demo.com'
const config = {
  BASE: 'https://api.gusto-demo.com',
  TOKEN: 'some_session_token',
};

const GustoClient = new GustoApi(OpenAPI);
const payroll = GustoClient.payrolls.getCompanyPayroll({
  companyId,
  payrollId,
});
const employees = GustoClient.employees.getCompanyEmployees({ companyId });

Refreshable Session Token

From Callback

import {
  GustoApi,
  refreshableTokenFromCallback,
  SessionTokenCallbackResponse,
} from '@gusto/gusto-api';

const yourSessionCallback = async (): Promise<SessionTokenCallbackResponse> => {
  return {
    session: 'SESSION',
    expiresIn: 3600,
  };
};
const config = {
  TOKEN: refreshableTokenFromCallback(yourSessionCallback),
};
const GustoClient = new GustoApi(OpenAPI);

From Url

If you pass a url to the refreshableTokenFromCallback function, it will automatically fetch the data from it.

This url should return a json object containing the session and expiresIn properties.

import { GustoApi, refreshableTokenFromCallback } from '@gusto/embedded-api';

const config = {
  TOKEN: refreshableTokenFromCallback('http://url.site.com/gusto/session-token'),
};
const GustoClient = new GustoApi(OpenAPI);

Note: It is your responsibility to properly secure this session-token url !

FAQs

Package last updated on 09 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts