zocrmsdkmiblu 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/js/util.js +17 -18
  2. package/package.json +1 -1
package/lib/js/util.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  function promiseResponse(request) {
3
2
 
4
3
  var crmclient = require('./ZCRMRestClient');
@@ -6,7 +5,7 @@ function promiseResponse(request) {
6
5
 
7
6
  return new Promise(function (resolve, reject) {
8
7
  var persistenceModule = require(crmclient.getPersistenceModule());
9
- getAuthToken().then(resp=>{
8
+ getAuthToken().then(resp => {
10
9
  makeapicall(request).then(function (response) {
11
10
 
12
11
  try {
@@ -14,14 +13,14 @@ function promiseResponse(request) {
14
13
  if (isExpire.code == 'INVALID_TOKEN') {
15
14
  //Update Token
16
15
 
17
- getAuthToken(true).then(resp=>{
16
+ getAuthToken(true).then(resp => {
18
17
  makeapicall(request).then(function (response) {
19
-
18
+
20
19
  resolve(response);
21
-
20
+
22
21
  })
23
22
  })
24
- }else{
23
+ } else {
25
24
  resolve(response);
26
25
  }
27
26
  } catch (error) {
@@ -30,7 +29,7 @@ function promiseResponse(request) {
30
29
 
31
30
  })
32
31
  })
33
-
32
+
34
33
  })
35
34
  }
36
35
 
@@ -85,7 +84,7 @@ function makeapicall(request) {
85
84
  api_headers.Authorization = 'Zoho-oauthtoken ' + access_token;
86
85
  api_headers["User-Agent"] = 'Zoho CRM Node SDK';
87
86
 
88
- console.log({
87
+ console.log({
89
88
 
90
89
  uri: baseUrl,
91
90
  method: request.type,
@@ -93,7 +92,7 @@ function makeapicall(request) {
93
92
  body: req_body,
94
93
  encoding: encoding
95
94
 
96
- },crmclient.getVersion(allrecords));
95
+ }, crmclient.getVersion(allrecords));
97
96
  httpclient({
98
97
 
99
98
  uri: baseUrl,
@@ -121,7 +120,7 @@ function makeapicall(request) {
121
120
  var filename;
122
121
  var disposition = response.headers["content-disposition"];//No I18N
123
122
  if (disposition && disposition.indexOf('attachment') !== -1) {
124
- var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
123
+ var filenameRegex = /filename[^;=\n]=((['"]).?\2|[^;\n]*)/;
125
124
  var matches = filenameRegex.exec(disposition);
126
125
  if (matches != null && matches[1]) {
127
126
  filename = matches[1].replace(/['"]/g, '');
@@ -144,7 +143,7 @@ function getAuthToken(isInvalid) {
144
143
  var crmclient = require('./ZCRMRestClient');
145
144
  var OAuth = require('./OAuth');
146
145
 
147
-
146
+
148
147
  return new Promise(function (resolve, reject) {
149
148
 
150
149
  var persistenceModule = require(crmclient.getPersistenceModule());
@@ -159,8 +158,8 @@ function getAuthToken(isInvalid) {
159
158
  var result_obj = (response);
160
159
 
161
160
  if ((current_time > expires_in) || isInvalid) {
162
- if(isInvalid)console.info("============== REGENERATE TOKEN BY INVALID =============");
163
- if(!isInvalid)console.info("============== REGENERATE TOKEN BY TIME =============");
161
+ if (isInvalid) console.info("============== REGENERATE TOKEN BY INVALID =============");
162
+ if (!isInvalid) console.info("============== REGENERATE TOKEN BY TIME =============");
164
163
 
165
164
  var config = crmclient.getConfig_refresh(refresh_token)
166
165
  new OAuth(config, 'refresh_access_token');
@@ -174,7 +173,7 @@ function getAuthToken(isInvalid) {
174
173
  });
175
174
  })
176
175
  }
177
-
176
+
178
177
 
179
178
  else {
180
179
  //console.info("============== TOKEN NO EXPIRADO =============")
@@ -219,12 +218,12 @@ function constructRequestDetails(input, url, type, isModuleParam) {
219
218
  url = url.replace("{api_name}", input.api_name);
220
219
 
221
220
 
222
- var params = {};
223
- if (input.params && Object.keys(input.params).length > 0) {
224
- requestDetails.params = createParams(input.params) + (input.module && isModuleParam ? "module=" + input.module : "");//No I18N
225
- }
221
+ var params = input.params || {};
226
222
  params.auth_type = "apikey";
227
223
  input.params = params;
224
+ if (Object.keys(input.params).length > 0) {
225
+ requestDetails.params = createParams(input.params) + (input.module && isModuleParam ? "module=" + input.module : "");
226
+ }
228
227
  }
229
228
  else {
230
229
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zocrmsdkmiblu",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "author": "Julio Bodero",
5
5
  "license": "MIT",
6
6
  "dependencies": {