Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add send row request method
  • Loading branch information
Oleksandr Bilohura committed Jan 18, 2023
1 parent 87bcb16 commit 7010bf1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions api/sendpulse.js
Expand Up @@ -1273,6 +1273,30 @@ function smsDeleteCampaign(callback, campaign_id) {
sendRequest('sms/campaigns', 'DELETE', data, true, callback);
}

/**
* Send row request to RestAPI
*
* @param path
* @param method
* @param data
* @param callback
*/
function sendRowRequest(path, method, data, callback) {
if (data === undefined) {
data = {};
}
if (!callback) {
callback = function () {
}
}
var allowedMethods = ['POST', 'GET', 'DELETE', 'PUT', 'PATCH'];
if (!allowedMethods.includes(method)) {
return callback(returnError('Method not allowed'));
}

sendRequest(path, method, data, true, callback);
}

exports.init = init;
exports.listAddressBooks = listAddressBooks;
exports.createAddressBook = createAddressBook;
Expand Down Expand Up @@ -1331,3 +1355,4 @@ exports.smsCancelCampaign = smsCancelCampaign;
exports.smsGetCampaignCost = smsGetCampaignCost;
exports.smsDeleteCampaign = smsDeleteCampaign;
exports.getToken = getToken;
exports.sendRequest = sendRowRequest;
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "sendpulse-api",
"version": "1.1.5",
"version": "1.1.6",
"description": "A simple SendPulse REST client library and example for Node.js",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7010bf1

Please sign in to comment.