# Node Client Library

## Installation

To install via [NPM](https://www.npmjs.com/package/tomba):

```bash
npm install tomba --save
```

To install via [YARN](https://yarnpkg.com/package/tomba):

```bash
yarn add tomba
```

## Usage

### Domain Search

Get email addresses found on the internet.

```js
import { TombaClient, Domain } from "tomba";

// Init Tomba
const client = new TombaClient();
const domain = new Domain(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = domain.domainSearch("stripe.com");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Email Finder

Find the verified email address of any professional.

```js
import { TombaClient, Finder } from "tomba";

// Init Tomba
const client = new TombaClient();
const finder = new Finder(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = finder.emailFinder("stripe.com", "fname", "lname");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Email Verifier

Verify the validity of any professional email address with the most complete email checker.

```js
import { TombaClient, Verifier } from "tomba";

// Init Tomba
const client = new TombaClient();
const verifier = new Verifier(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = verifier.emailVerifier("m@wordpress.org");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

## Examples

### Get Account Information

```js
import { TombaClient, Account } from "tomba";

// Init Tomba
const client = new TombaClient();
const account = new Account(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = account.getAccount();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Email Count

```js
import { TombaClient, Count } from "tomba";

// Init Tomba
const client = new TombaClient();
const count = new Count(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = count.emailCount("tomba.io");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Finder Services

#### Author Finder

```js
import { TombaClient, Finder } from "tomba";

// Init Tomba
const client = new TombaClient();
const finder = new Finder(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = finder.authorFinder("www.shopify.com/blog/self-publish-a-book");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Email Enrichment

```js
import { TombaClient, Finder } from "tomba";

// Init Tomba
const client = new TombaClient();
const finder = new Finder(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = finder.emailEnrichment("dayna.winter@shopify.com");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### LinkedIn Finder

```js
import { TombaClient, Finder } from "tomba";

// Init Tomba
const client = new TombaClient();
const finder = new Finder(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = finder.linkedinFinder("https://www.linkedin.com/in/mattm");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### API Key Management

#### Create API Key

```js
import { TombaClient, Keys } from "tomba";

// Init Tomba
const client = new TombaClient();
const keys = new Keys(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = keys.createKey();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Delete API Key

```js
import { TombaClient, Keys } from "tomba";

// Init Tomba
const client = new TombaClient();
const keys = new Keys(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = keys.deleteKey("");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Get All API Keys

```js
import { TombaClient, Keys } from "tomba";

// Init Tomba
const client = new TombaClient();
const keys = new Keys(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = keys.getKeys();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Reset API Key

```js
import { TombaClient, Keys } from "tomba";

// Init Tomba
const client = new TombaClient();
const keys = new Keys(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = keys.resetKey("");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Lead Attributes Management

#### Create Lead Attribute

```js
import { TombaClient, LeadsAttributes } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsAttributes = new LeadsAttributes(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsAttributes.createLeadAttribute();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Delete Lead Attribute

```js
import { TombaClient, LeadsAttributes } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsAttributes = new LeadsAttributes(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsAttributes.deleteLeadAttribute("[Lead_Attributes_ID]");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Get Lead Attributes

```js
import { TombaClient, LeadsAttributes } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsAttributes = new LeadsAttributes(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsAttributes.getLeadAttributes();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Update Lead Attribute

```js
import { TombaClient, LeadsAttributes } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsAttributes = new LeadsAttributes(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsAttributes.updateLeadAttribute("[Lead_Attributes_ID]");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Lead Lists Management

#### Create Lead List

```js
import { TombaClient, LeadsLists } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsLists = new LeadsLists(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsLists.createList();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Delete Lead List

```js
import { TombaClient, LeadsLists } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsLists = new LeadsLists(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsLists.deleteListId("[LIST_ID]");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Get All Lead Lists

```js
import { TombaClient, LeadsLists } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsLists = new LeadsLists(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsLists.getLists();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

#### Update Lead List

```js
import { TombaClient, LeadsLists } from "tomba";

// Init Tomba
const client = new TombaClient();
const leadsLists = new LeadsLists(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = leadsLists.updateListId("[List_ID]");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Activity Logs

```js
import { TombaClient, Logs } from "tomba";

// Init Tomba
const client = new TombaClient();
const logs = new Logs(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = logs.getLogs();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Email Sources

```js
import { TombaClient, Sources } from "tomba";

// Init Tomba
const client = new TombaClient();
const sources = new Sources(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = sources.emailSources("b.mohamed@tomba.io");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Domain and Company Status

#### Domain Status

```js
import { TombaClient, Status } from "tomba";

// Init Tomba
const client = new TombaClient();
const status = new Status(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = status.domainStatus("gmail.com");

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

### Usage Statistics

```js
import { TombaClient, Usage } from "tomba";

// Init Tomba
const client = new TombaClient();
const usage = new Usage(client);

client
    .setKey("ta_xxxx") // Your Key
    .setSecret("ts_xxxx"); // Your Secret

const result = usage.getUsage();

result
    .then((response) => {
        console.log(response);
    })
    .catch((err) => {
        console.log(err);
    });
```

For more sample codes, check the [**examples/**](https://github.com/tomba-io/node/tree/master/examples) folder.
