Skip to content

Commit 7010bf1

Browse files
author
Oleksandr Bilohura
committed
Add send row request method
1 parent 87bcb16 commit 7010bf1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

api/sendpulse.js

+25
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,30 @@ function smsDeleteCampaign(callback, campaign_id) {
12731273
sendRequest('sms/campaigns', 'DELETE', data, true, callback);
12741274
}
12751275

1276+
/**
1277+
* Send row request to RestAPI
1278+
*
1279+
* @param path
1280+
* @param method
1281+
* @param data
1282+
* @param callback
1283+
*/
1284+
function sendRowRequest(path, method, data, callback) {
1285+
if (data === undefined) {
1286+
data = {};
1287+
}
1288+
if (!callback) {
1289+
callback = function () {
1290+
}
1291+
}
1292+
var allowedMethods = ['POST', 'GET', 'DELETE', 'PUT', 'PATCH'];
1293+
if (!allowedMethods.includes(method)) {
1294+
return callback(returnError('Method not allowed'));
1295+
}
1296+
1297+
sendRequest(path, method, data, true, callback);
1298+
}
1299+
12761300
exports.init = init;
12771301
exports.listAddressBooks = listAddressBooks;
12781302
exports.createAddressBook = createAddressBook;
@@ -1331,3 +1355,4 @@ exports.smsCancelCampaign = smsCancelCampaign;
13311355
exports.smsGetCampaignCost = smsGetCampaignCost;
13321356
exports.smsDeleteCampaign = smsDeleteCampaign;
13331357
exports.getToken = getToken;
1358+
exports.sendRequest = sendRowRequest;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sendpulse-api",
3-
"version": "1.1.5",
3+
"version": "1.1.6",
44
"description": "A simple SendPulse REST client library and example for Node.js",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)