gravity-forms-api
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -26,5 +26,5 @@ 'use strict'; | ||
if (isValid(apiCreds)) { | ||
this.setup(apiCreds); | ||
this._setup(apiCreds); | ||
} else { | ||
this.throwError('Invalid api credentials'); | ||
this._throwError('Invalid api credentials'); | ||
} | ||
@@ -34,2 +34,27 @@ } | ||
_createClass(GravityFormsApi, [{ | ||
key: '_setup', | ||
value: function _setup(options) { | ||
var apiKey = options.apiKey; | ||
var domain = options.domain; | ||
var privateKey = options.privateKey; | ||
this.apiKey = apiKey; | ||
this.privateKey = privateKey; | ||
this.baseEndPoint = domain + '/gravityformsapi'; | ||
} | ||
}, { | ||
key: '_convertToFutureUnixTime', | ||
value: function _convertToFutureUnixTime(expirationInSeconds) { | ||
var currentDate = new Date(); | ||
var unixTimeInSeconds = parseInt(currentDate.getTime() / 1000, 10); | ||
return unixTimeInSeconds + expirationInSeconds; | ||
} | ||
}, { | ||
key: '_throwError', | ||
value: function _throwError(desc) { | ||
throw new Error(desc); | ||
} | ||
}, { | ||
key: 'createSignature', | ||
@@ -40,6 +65,6 @@ value: function createSignature(method, route) { | ||
if (!method || !route) { | ||
this.throwError('GravityFormsApi.createSignature is Missing required arguments'); | ||
this._throwError('GravityFormsApi.createSignature is Missing required arguments'); | ||
} | ||
var futureUnixTime = this.convertToFutureUnixTime(expirationInSeconds); | ||
var futureUnixTime = this._convertToFutureUnixTime(expirationInSeconds); | ||
@@ -61,6 +86,6 @@ var stringToSign = this.apiKey + ':' + method + ':' + route + ':' + futureUnixTime; | ||
if (!domain || !route || !signature) { | ||
this.throwError('GravityFormsApi.request is Missing required arguments'); | ||
this._throwError('GravityFormsApi.request is Missing required arguments'); | ||
} | ||
var futureUnixTime = this.convertToFutureUnixTime(expirationInSeconds); | ||
var futureUnixTime = this._convertToFutureUnixTime(expirationInSeconds); | ||
var url = this.baseEndPoint + '/' + route + '?api_key=' + this.apiKey + '&signature=' + signature + ('&expires=' + futureUnixTime + '&paging[page_size]=' + maxResults); | ||
@@ -70,27 +95,2 @@ | ||
} | ||
}], [{ | ||
key: 'setup', | ||
value: function setup(options) { | ||
var apiKey = options.apiKey; | ||
var domain = options.domain; | ||
var privateKey = options.privateKey; | ||
this.apiKey = apiKey; | ||
this.privateKey = privateKey; | ||
this.baseEndPoint = domain + '/gravityformsapi'; | ||
} | ||
}, { | ||
key: 'convertToFutureUnixTime', | ||
value: function convertToFutureUnixTime(expirationInSeconds) { | ||
var currentDate = new Date(); | ||
var unixTimeInSeconds = parseInt(currentDate.getTime() / 1000, 10); | ||
return unixTimeInSeconds + expirationInSeconds; | ||
} | ||
}, { | ||
key: 'throwError', | ||
value: function throwError(desc) { | ||
throw new Error(desc); | ||
} | ||
}]); | ||
@@ -97,0 +97,0 @@ |
{ | ||
"name": "gravity-forms-api", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Basic module that creates signatures and requests data from gravity forms endpoints", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
6221