Skip to content
This repository was archived by the owner on May 18, 2020. It is now read-only.

Commit cbdeec9

Browse files
committed
API-55: Create npm for node.js SIB Api
1 parent 6e39ece commit cbdeec9

File tree

6 files changed

+553
-173
lines changed

6 files changed

+553
-173
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,35 @@ This is [SendinBlue](https://www.sendinblue.com) provided API V2 npm library. It
55
SendinBlue API's use HTTP Authentication through an api key. You can create your api key from [API Console](https://my.sendinblue.com/advanced/apikey), after you sign up for an account with SendinBlue. You must use latest version 2.0, access key, for accessing APIs.
66

77

8-
## Installation
8+
## Install Package
99

10-
``` npm install sendinblue-api --save ```
10+
The following recommended installation requires [npm](https://npmjs.org/). If you are unfamiliar with npm, see the [npm docs](https://npmjs.org/doc/).
11+
12+
Add the following to your `package.json` file:
13+
14+
```json
15+
{
16+
...
17+
"dependencies": {
18+
...
19+
"sendinblue-api": "^1.0.0"
20+
}
21+
}
22+
```
23+
24+
Install sendinblue-api and its dependencies:
25+
26+
```bash
27+
npm install
28+
```
29+
30+
### Alternative Installation
31+
32+
You can also install sendinblue-api locally with the following command:
33+
34+
```bash
35+
npm install sendinblue-api
36+
```
1137

1238

1339
## Dependencies

examples/create_update_user.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@ var sendinblue = require('../sendinblue-api');
22
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000);
33

44
var input = { 'email': 'example@example.net',
5-
'attributes': {
6-
'NAME': 'example',
7-
'SURNAME': 'example'
8-
},
9-
'blacklisted': 0,
10-
'listid': [291]
5+
'attributes': {
6+
'NAME': 'example',
7+
'SURNAME': 'example'
8+
},
9+
'blacklisted': 0,
10+
'listid': [291]
1111
};
1212

13-
sendinObj.create_update_user(input).on('complete', function(data) {
14-
data = JSON.parse(data);
15-
console.log(data);
13+
sendinObj.create_update_user(input, function(err, response){
14+
console.log(response);
1615
});
1716

1817
/*
1918
Output Response
2019
{
2120
code: 'success',
2221
message: 'Email was updated successfully. ',
23-
data:[]
22+
data: { id: 5, updated: 'true' }
2423
}
2524
*/

examples/delete_user.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key
33

44
var input = { 'email': 'example@example.net' };
55

6-
sendinObj.delete_user(input).on('complete', function(data) {
7-
data = JSON.parse(data);
8-
console.log(data);
6+
sendinObj.delete_user(input, function(err, response){
7+
console.log(response);
98
});
109

1110
/*

examples/get_account.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
var sendinblue = require('../sendinblue-api');
2-
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000);
2+
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0', 'your_api_key', 5000);
33

4-
sendinObj.get_account().on('complete', function(data) {
5-
data = JSON.parse(data);
6-
console.log(data);
4+
var input = {};
5+
sendinObj.get_account(input, function(err, response){
6+
console.log(response);
77
});
88

99
/*

examples/send_email.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
var sendinblue = require('../sendinblue-api');
22
var sendinObj = new sendinblue('https://api.sendinblue.com/v2.0/', 'your_api_key', 5000);
33

4-
var input = { 'to': { 'to@example.net': 'to whom!' },
4+
var input = { 'to': { 'ektagupta@sendinblue': 'to whom!' },
55
'from': ['from@email.com', 'from email!'],
66
'subject': 'Test mail form sendinblue',
77
'html': 'This is the <h1>HTML</h1>'
88
};
99

10-
sendinObj.send_email(input).on('complete', function(data) {
11-
data = JSON.parse(data);
12-
console.log(data);
10+
sendinObj.send_email(input, function(err, response){
11+
console.log(response);
1312
});
1413

1514
/*

0 commit comments

Comments
 (0)