classy-pay-client
Advanced tools
Comparing version 1.0.0 to 1.0.1
17
index.js
'use strict'; | ||
const request = require('request'); | ||
const _ = require('lodash'); | ||
let apiUrl; | ||
@@ -8,2 +9,3 @@ let token; | ||
let HmacAuthorize; | ||
let errorNok; | ||
@@ -26,7 +28,15 @@ function payRequest(appId, method, resource, payload, callback) { | ||
request(options, function(error, response, body) { | ||
if (!error && response.statusCode === 200) { | ||
let status = _.get(response, 'statusCode'); | ||
let errorResponse = { | ||
status, | ||
error, | ||
response, | ||
body | ||
}; | ||
if (status === 200) { | ||
callback(null, body ? JSON.parse(body) : {}); | ||
} else if (errorNok) { | ||
callback(errorResponse); | ||
} else { | ||
callback(error || 'Response was not 200 OK: ' + | ||
JSON.stringify(response, null, 2)); | ||
callback(null, errorResponse); | ||
} | ||
@@ -45,2 +55,3 @@ }); | ||
timeout = config.timeout; | ||
errorNok = config.errorNok || true, | ||
HmacAuthorize = require('authorization-hmac256')({ | ||
@@ -47,0 +58,0 @@ service: 'CWS', |
{ | ||
"name": "classy-pay-client", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Client for Classy Pay.", | ||
@@ -26,2 +26,3 @@ "main": "index.js", | ||
"authorization-hmac256": "^1.0.0", | ||
"lodash": "^4.17.4", | ||
"request": "^2.81.0" | ||
@@ -28,0 +29,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5739
3
8
98
2
+ Addedlodash@^4.17.4
+ Addedlodash@4.17.21(transitive)