3.7.10 • Published 5 days ago

@devrev-growth/snap-in-utils v3.7.10

Weekly downloads
-
License
MIT
Repository
github
Last release
5 days ago

Overview

This package is a collection of helper functions we share between DevRev snap-ins

Installation

npm i -S @devrev-growth/snap-in-utils

Upgrading

npm update @devrev-growth/snap-in-utils

Usage

Each of the remote destinations supported have their own client that requires configuration before use.

BigQuery

import { createBQClient } from '@devrev-growth/snap-in-utils';

const client = createBqClient(GOOGLE_API_KEY, PROJECT_ID);

const query =
  'SELECT * FROM `bigquery-public-data.covid19_nyt.us_counties` LIMIT 10';

const results = await client.executeQuery(query);

The executeQuery method will also format the data, returning a list of objects where the keys are the values of the columns in the query. You can also use executeQueryRaw and formatData if you wish to handle this on your own

DevRev

import { createDevRevClient } fromn '@devrev-growth/snap-in-utils';

const client = createDevRevClient(DEVREV_API_TOKEN);

const contact = client.getContactById(CONTACT_ID);

const {contact, account} = client.getContactAndAccount(EMAIL_ADDRESS);

By default, the client will have a 40000ms timeout on requests and be limited to 10 requests per second. It also uses the prod api https://api.devrev.ai by default. You can override these with the timeout maxRequests and baseURL options

const client = createDevRevClient(DEVREV_API_TOKEN, {
  timeout: 60000,
  maxRequests: 4,
  baseURL: 'https://api.dev.devrev-eng.ai',
});

If you need to get all of something, you can use the special getAll method. This will handle pagination for you and return a list of all the results, using the API name

const allAccounts = client.getAll('accounts');

// Some API endpoints have an extra bit in the path, like rev-users.all.
// This will be handled properly by the code
const allRevUsers = client.getAll('rev-users.all');

The most important functions are the getContactAndAccount and the getOrCreateContactAndAccount. This will handle Contact and Account resolution for you, just provide whatever info you can will do the rest. The major difference is that getOrCreateContactAndAccount will create a new Contact and Account if one does not exist. It accepts an optional object at the end to provide additional information to create the Contact and Account

const { contact, account } = client.getContactAndAccount(EMAIL_ADDRESS);
const { contact, account } = client.getContactAndAccount(EMAIL_ADDRESS, DOMAIN);
const { contact, account } = client.getOrCreateContactAndAccount(EMAIL_ADDRESS);
const { contact, account } = client.getOrCreateContactAndAccount(
  EMAIL_ADDRESS,
  DOMAIN
);
const { contact, account } = client.getOrCreateContactAndAccount(
  EMAIL_ADDRESS,
  DOMAIN,
  { full_name: NAME, company: COMPANY }
);

Beyond these special functions, there should be get and create for all the major workflows we need (and if not we should add them)

getAccountsByDomain,
getAccountById,
getContactById,
getRevOrgById,
getRevOrgsByAccount,
getContactsByEmail,
getDevUserById,
getDevUsersByEmail,
getEngagementById,
getEngagementsByExternalRef,
getContactsByRevOrg,
getContactsByAccount,
getContactAndAccount,
getOrCreateContactAndAccount,
deleteContact,
deleteAccount,
deleteEngagement,
getAll,
updateRevOrg,
updateContact,
updateAccount,
updateEngagement,
createEngagement,
3.7.9

5 days ago

3.7.10

5 days ago

3.7.8

8 days ago

3.7.5

11 days ago

3.7.4

11 days ago

3.7.7

11 days ago

3.7.6

11 days ago

3.7.3

13 days ago

3.7.1

24 days ago

3.6.3

25 days ago

3.7.0

25 days ago

3.6.2

2 months ago

3.6.1

2 months ago

3.6.0

2 months ago

3.5.1

2 months ago

3.4.3

2 months ago

3.5.0

3 months ago

3.4.2

4 months ago

3.4.1

4 months ago

3.4.0

4 months ago

3.3.5

4 months ago

3.3.4

4 months ago

3.3.3

4 months ago

3.3.2

5 months ago

3.2.8

5 months ago

3.2.7

5 months ago

3.3.1

5 months ago

3.3.0

5 months ago

3.2.6

5 months ago

3.2.5

5 months ago

3.2.2

5 months ago

3.2.1

5 months ago

3.2.0

6 months ago

3.2.4

5 months ago

3.2.3

5 months ago

3.1.9

6 months ago

3.1.8

6 months ago

3.1.7

6 months ago

3.1.6

6 months ago

3.1.5

6 months ago

3.1.4

6 months ago

3.1.3

6 months ago

3.1.2

6 months ago

3.1.1

6 months ago

3.1.0

6 months ago

3.0.23

6 months ago

3.0.22

6 months ago

3.0.21

6 months ago

3.0.20

6 months ago

3.0.19

6 months ago

3.0.18

6 months ago

3.0.17

6 months ago

3.0.16

6 months ago

3.0.15

6 months ago

3.0.14

6 months ago

3.0.13

6 months ago

3.0.12

6 months ago

3.0.11

6 months ago

3.0.10

6 months ago

3.0.9

6 months ago

3.0.8

6 months ago

3.0.7

7 months ago

3.0.6

7 months ago

3.0.5

7 months ago

3.0.4

7 months ago

3.0.3

7 months ago

3.0.2

7 months ago

3.0.1

7 months ago

3.0.0

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.3

7 months ago

2.0.2

7 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.9.11

7 months ago

1.9.10

7 months ago

1.9.9

7 months ago

1.9.8

7 months ago

1.9.7

7 months ago

1.9.6

7 months ago

1.9.5

7 months ago

1.9.3

7 months ago

1.9.2

7 months ago

1.9.1

7 months ago

1.9.0

7 months ago

1.8.5

8 months ago

1.8.3

8 months ago

1.8.2

8 months ago

1.8.1

8 months ago

1.8.0

8 months ago

1.7.4

8 months ago

1.7.3

8 months ago

1.7.2

8 months ago

1.7.1

8 months ago

1.7.0

8 months ago

1.6.5

8 months ago

1.6.2

8 months ago

1.6.1

8 months ago

1.6.0

8 months ago

1.5.5

8 months ago

1.5.2

8 months ago

1.5.1

8 months ago

1.5.0

9 months ago

1.4.7

9 months ago

1.4.6

9 months ago

1.4.5

9 months ago

1.4.2

9 months ago

1.4.1

9 months ago

1.4.0

9 months ago

1.3.7

9 months ago

1.3.6

9 months ago

1.3.5

9 months ago

1.3.3

9 months ago

1.3.2

9 months ago

1.3.1

9 months ago

1.3.0

9 months ago

1.2.3

9 months ago

1.2.2

9 months ago

1.2.1

9 months ago

1.2.0

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.0

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago