activecampaign
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -49,3 +49,7 @@ var http = require("http"), | ||
if (params) { | ||
request_url += "&" + params; | ||
var separator = "?"; | ||
if (request_url.match(/\?/)) { | ||
separator = "&"; | ||
} | ||
request_url += separator + params; | ||
} | ||
@@ -62,3 +66,29 @@ if (this.debug) { | ||
}, | ||
/** | ||
* Parses an object and makes it into a URL query string for use with the API request. | ||
* | ||
* @param array params The object of URL data in key=value format. Example: {"one":1, "two":2, "three": {"three1":31}} | ||
* @return string The encoded URL query string. | ||
*/ | ||
http_build_query: function(params) { | ||
var params_str = ""; | ||
for (var i in params) { | ||
if (typeof(params[i]) == "object") { | ||
for (var j in params[i]) { | ||
var obj_length = Object.keys(params[i]).length; | ||
params_str += i + encodeURIComponent("[" + j + "]") + "=" + encodeURIComponent(params[i][j]); | ||
params_str += "&"; | ||
} | ||
} else { | ||
var obj_length = Object.keys(params).length; | ||
params_str += i + "=" + encodeURIComponent(params[i]); | ||
params_str += "&"; | ||
} | ||
} | ||
// Trim off trailing "&" character. | ||
params_str = params_str.substring(0, params_str.length - 1); | ||
return params_str; | ||
}, | ||
curl: function(url, post_data) { | ||
@@ -76,3 +106,7 @@ if (this.version == 1) { | ||
} else if (this.version == 2) { | ||
url += "?api_key=" + this.api_key; | ||
var separator = "?"; | ||
if (url.match(/\?/)) { | ||
separator = "&"; | ||
} | ||
url += separator + "api_key=" + this.api_key; | ||
} | ||
@@ -79,0 +113,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "ActiveCampaign <help@activecampaign.com>", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -21,2 +21,3 @@ # ActiveCampaign Node.js API wrapper | ||
```javascript | ||
var ActiveCampaign = require("activecampaign"); | ||
@@ -74,2 +75,3 @@ | ||
}); | ||
``` | ||
@@ -82,2 +84,2 @@ ## Full Documentation | ||
We'd love to help if you have questions or problems. Report issues using the [Github Issue Tracker](https://github.com/ActiveCampaign/activecampaign-api-nodejs/issues) or email [help@activecampaign.com](mailto:help@activecampaign.com). | ||
We'd love to help if you have questions or problems. Report issues using the [Github Issue Tracker](https://github.com/ActiveCampaign/activecampaign-api-nodejs/issues) or email [help@activecampaign.com](mailto:help@activecampaign.com). |
18502
23
518
83