Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mergeapi/merge-sdk-typescript

Package Overview
Dependencies
Maintainers
6
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mergeapi/merge-sdk-typescript

NodeJS client for Merge API, Inc's unified API's.

  • 3.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-43.47%
Maintainers
6
Weekly downloads
 
Created
Source

@mergeapi/merge-sdk-typescript@3.0.10

This is the Merge API, Inc. SDK client for Typescript. It utilizes Fetch API to make requests to Merge on behalf of customers. We recommend only using this module in NodeJS server environments.

Language level

  • ES5 - you must have a Promises/A+ library installed
  • ES6

Module system

  • CommonJS
  • ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference)

Documentation

The documentation for various Merge category API's can be found here:

Basic Usage

Common to all categories is the Merge SDK Configuration object, which defines the authentication properties of your requests. The apiKey property is the API Key of your Merge account, which can be administered in the Merge dashboard. The accessToken property will be the X-Account-Token header which identifies which of your customers' data you are requesting. See the following examples for calling various category API's:

node-fetch override on Node version < 17.5

This SDK relies on the Fetch API, which is baked into Node starting at version 17.5. For those customers on older versions of Node, we allow you to explicitly set the fetchApi property like so:

import fetch from 'node-fetch'

...

let test_conf_crm = new Configuration({
    apiKey: "REDACTED",
    accessToken: "REDACTED",
    fetchApi: fetch
});

You can find the node-fetch package here: https://www.npmjs.com/package/node-fetch . We have tested that node-fetch @ 2.x.x can be passed in directly on Node version 16.0.0, however later versions of node-fetch or later versions of Node may require additional type adjustments to make it work.

Accounting
const confAccounting = new Configuration({
    apiKey: "REDACTED-YourAPIKeyWithMerge",
    accessToken: "REDACTED-YourCustomer1Key"
});

const accountsApi = new merge_sdk.Accounting.AccountsApi(confAccounting);

// lists the accounting accounts for customer 1
let response = await accountsApi.accountsList({}).catch((reason) => {
    console.log(reason);
});
console.log(response);
ATS
const confAts = new Configuration({
    apiKey: "REDACTED-YourAPIKeyWithMerge",
    accessToken: "REDACTED-YourCustomer1Key"
});

const candidatesApi = new merge_sdk.ATS.CandidatesApi(confAts);

// lists ats candidates for customer 1
let response = await candidatesApi.candidatesList({}).catch((reason) => {
    console.log(reason);
});
console.log(response);
CRM
const confCrm = new Configuration({
    apiKey: "REDACTED-YourAPIKeyWithMerge",
    accessToken: "REDACTED-YourCustomer1Key"
});

const contactsApi = new merge_sdk.CRM.ContactsApi(confCrm);

// lists crm contacts for customer 1
let response = await contactsApi.contactsList({});
console.log(response);
HRIS
const confHris = new Configuration({
    apiKey: "REDACTED-YourAPIKeyWithMerge",
    accessToken: "REDACTED-YourCustomer1Key"
});

const employeesApi = new merge_sdk.HRIS.EmployeesApi(confHris);

// list all employess reporting to managerId: x for customer 1
let response = await employeesApi.employeesList({
    managerId: "REDACTED"
});
console.log(response);
Ticketing
const confTicketing = new Configuration({
    apiKey: "REDACTED-YourAPIKeyWithMerge",
    accessToken: "REDACTED-YourCustomer1Key"
});

const ticketsApi = new merge_sdk.Ticketing.TicketsApi(confTicketing);

// list all ticketing tickets for customer 1
let response = await ticketsApi.ticketsList({});
console.log(response);

Enums

Merge's API tries to unify enum values across integrations for a given category. However, there will be sporadic cases where integration enum values are too unique to be mapped. In these cases, the value will come back as-is. In order to support this behavior, starting in v3.0.0 of merge-sdk-typescript, all enum values will be wrapped in an interface like:

{
    value: EnumValue,
    rawValue: string
}

Where the rawValue property will be the string from the Merge API, which may be the enum value as-is from the integration source.

Building

To build and compile the typescript sources to javascript use:

npm install
npm run build

Tests

There is a single rough test for the SDK which calls one API from each category. To run it, you must set configuration variables with the relevant API key and access token for each category. Additionally, the HRIS section of the test checks an optional filtering query parameter.

Consuming

navigate to the folder of your consuming project and run one of the following commands.

published:

npm install @mergeapi/merge-sdk-typescript@3.0.9 --save

unPublished (not recommended):

npm install PATH_TO_GENERATED_PACKAGE --save

FAQs

Package last updated on 18 Jul 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc