gn-api-sdk-node
Advanced tools
Comparing version 0.0.17 to 0.0.18
@@ -16,3 +16,3 @@ 'use strict'; | ||
GnEndpoints.prototype.run = function(name, params, body) { | ||
GnEndpoints.prototype.run = function (name, params, body) { | ||
var self = this; | ||
@@ -34,9 +34,9 @@ self.defer = q.defer(); | ||
GnEndpoints.prototype.getAccessToken = function() { | ||
GnEndpoints.prototype.getAccessToken = function () { | ||
var self = this; | ||
return this.gnAuth.getAccessToken() | ||
.then(function(response) { | ||
.then(function (response) { | ||
self.accessToken = response.access_token; | ||
return self.accessToken; | ||
}).catch(function(err) { | ||
}).catch(function (err) { | ||
return err; | ||
@@ -46,3 +46,3 @@ }); | ||
GnEndpoints.prototype.getResponse = function(response, body) { | ||
GnEndpoints.prototype.getResponse = function (response, body) { | ||
return this.options | ||
@@ -52,16 +52,16 @@ .raw_response ? response : body; | ||
GnEndpoints.prototype.req = function(callback) { | ||
GnEndpoints.prototype.req = function (callback) { | ||
request[this.endpoint.method](this.getParams.call(this, | ||
this.endpoint.route), callback); | ||
} | ||
}; | ||
GnEndpoints.prototype.directReq = function() { | ||
GnEndpoints.prototype.directReq = function () { | ||
this.req(this.directReqCallback.bind(this)); | ||
}; | ||
GnEndpoints.prototype.withTokenReq = function() { | ||
GnEndpoints.prototype.withTokenReq = function () { | ||
this.req(this.withTokenReqCallback.bind(this)); | ||
}; | ||
GnEndpoints.prototype.getParams = function(route) { | ||
GnEndpoints.prototype.getParams = function (route) { | ||
var self = this; | ||
@@ -77,4 +77,4 @@ var regex = /\:(\w+)/g; | ||
var getVariables = function() { | ||
return placeholders.map(function(item) { | ||
var getVariables = function () { | ||
return placeholders.map(function (item) { | ||
return item.replace(':', ''); | ||
@@ -84,5 +84,5 @@ }); | ||
var updateRoute = function() { | ||
var updateRoute = function () { | ||
var variables = getVariables(); | ||
variables.forEach(function(value, index) { | ||
variables.forEach(function (value, index) { | ||
if (params[value]) { | ||
@@ -95,6 +95,6 @@ route = route.replace(placeholders[index], params[value]); | ||
var getQueryString = function() { | ||
var getQueryString = function () { | ||
var keys = Object.keys(params); | ||
var initial = keys.length >= 1 ? '?' : ''; | ||
return keys.reduce(function(previous, current, index, array) { | ||
return keys.reduce(function (previous, current, index, array) { | ||
var next = (index === array.length - 1) ? '' : '&'; | ||
@@ -110,8 +110,14 @@ return [previous, current, '=', | ||
var headers = { | ||
'api-sdk': 'node-' + sdkPackage.version | ||
}; | ||
if (this.options.partner_token) { | ||
headers['partner-token'] = this.options.partner_token; | ||
} | ||
var req = { | ||
url: [this.options.baseUrl, route, query].join(''), | ||
json: true, | ||
headers: { | ||
'api-sdk': 'node-' + sdkPackage.version | ||
}, | ||
headers: headers, | ||
body: this.body | ||
@@ -129,3 +135,3 @@ }; | ||
GnEndpoints.prototype.withTokenReqCallback = function(err, httpResponse, httpResponseBody) { | ||
GnEndpoints.prototype.withTokenReqCallback = function (err, httpResponse, httpResponseBody) { | ||
var self = this; | ||
@@ -145,3 +151,3 @@ var response = self.getResponse(httpResponse, httpResponseBody); | ||
GnEndpoints.prototype.directReqCallback = function(err, httpResponse, bodyResponse) { | ||
GnEndpoints.prototype.directReqCallback = function (err, httpResponse, bodyResponse) { | ||
var response = this.getResponse(httpResponse, bodyResponse); | ||
@@ -148,0 +154,0 @@ |
{ | ||
"name": "gn-api-sdk-node", | ||
"description": "Module for integration with Gerencianet API", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"author": "Francisco Carvalho <f.thiene@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -20,3 +20,9 @@ # gn-api-sdk-node | ||
``` | ||
## Tested with | ||
``` | ||
node 0.12.7, 4.4.0 and 4.4.4 | ||
``` | ||
## Basic usage | ||
@@ -23,0 +29,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44147
1378
115