sencrop-js-api-client
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -84,2 +84,16 @@ /* eslint no-console:0 */ | ||
}, options) { | ||
${(parameters || []) | ||
.map(parameter => { | ||
if (parameter.required) { | ||
return `if( ${camelCase(parameter.name)} == null) { | ||
throw new Error('Missing required parameter : ${camelCase( | ||
parameter.name | ||
)}. Value : ' + ${camelCase(parameter.name)}); | ||
} | ||
`; | ||
} | ||
}) | ||
.join('')} | ||
const method = '${method}'; | ||
@@ -86,0 +100,0 @@ let urlParts = [${path |
@@ -5,28 +5,64 @@ 'use strict'; | ||
const path = require('path'); | ||
const axios = require('axios'); | ||
const inquirer = require('inquirer'); | ||
const { getSwaggerOperations } = require('swagger-http-router/src/utils'); | ||
const API = require(path.join(process.cwd(), process.argv[2])); | ||
const operations = getSwaggerOperations(API); | ||
var questions = [ | ||
{ | ||
type: 'input', | ||
name: 'url', | ||
message: "What's the api doc endpoint?", | ||
default: 'https://api.sencrop.com/master/openAPI', | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'token', | ||
message: "What's the api token (if secured endpoint)?", | ||
}, | ||
]; | ||
API.paths = operations.reduce((paths, operation) => { | ||
if (operation.tags && operation.tags.includes('private')) { | ||
return paths; | ||
} | ||
(async () => { | ||
try { | ||
const { url, token } = await inquirer.prompt(questions); | ||
API.host = 'api.sencrop.com'; | ||
const request = { | ||
method: 'GET', | ||
url: url, | ||
}; | ||
if (token) { | ||
request.headers = { | ||
Authorization: `Bearer ${token}`, | ||
}; | ||
} | ||
API.paths[operation.path][operation.method].tags = ( | ||
operation.tags || [] | ||
).filter(t => !(t.startsWith('memx') || t.startsWith('tx'))); | ||
const api = (await axios(request)).data; | ||
const operations = getSwaggerOperations(api); | ||
paths[operation.path] = paths[operation.path] || {}; | ||
paths[operation.path][operation.method] = | ||
API.paths[operation.path][operation.method]; | ||
api.paths = operations.reduce((paths, operation) => { | ||
if (operation.tags && operation.tags.includes('private')) { | ||
return paths; | ||
} | ||
return paths; | ||
}, {}); | ||
api.host = 'api.sencrop.com'; | ||
api.basePath = '/v1'; | ||
fs.writeFileSync( | ||
path.join(__dirname, '../src/swagger.api.json'), | ||
JSON.stringify(API, null, 2) | ||
); | ||
api.paths[operation.path][operation.method].tags = ( | ||
operation.tags || [] | ||
).filter(t => !(t.startsWith('memx') || t.startsWith('tx'))); | ||
paths[operation.path] = paths[operation.path] || {}; | ||
paths[operation.path][operation.method] = | ||
api.paths[operation.path][operation.method]; | ||
return paths; | ||
}, {}); | ||
fs.writeFileSync( | ||
path.join(__dirname, '../src/swagger.api.json'), | ||
JSON.stringify(api, null, 2) | ||
); | ||
} catch (err) { | ||
throw err; | ||
} | ||
})(); |
@@ -0,1 +1,14 @@ | ||
<a name="1.9.0"></a> | ||
# [1.9.0](https://github.com/sencrop/sencrop-js-api-client/compare/v1.8.0...v1.9.0) (2018-07-02) | ||
### Features | ||
* **build:** Throw error if required param not provided ([f0c2fbd](https://github.com/sencrop/sencrop-js-api-client/commit/f0c2fbd)) | ||
* **organisation:** New endpoints for organisation management ([e761f1c](https://github.com/sencrop/sencrop-js-api-client/commit/e761f1c)) | ||
* **organisations:** Adding endpoint for migration ([a959684](https://github.com/sencrop/sencrop-js-api-client/commit/a959684)) | ||
* **Swagger:** update swagger ([76b508d](https://github.com/sencrop/sencrop-js-api-client/commit/76b508d)) | ||
<a name="1.8.0"></a> | ||
@@ -2,0 +15,0 @@ # [1.8.0](https://github.com/sencrop/sencrop-js-api-client/compare/v1.7.0...v1.8.0) (2018-05-16) |
{ | ||
"name": "sencrop-js-api-client", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "The Sencrop JavaScript API client", | ||
@@ -64,2 +64,3 @@ "main": "dist/src/index.js", | ||
"eslint-plugin-prettier": "^2.5.0", | ||
"inquirer": "^5.2.0", | ||
"istanbul": "0.4.5", | ||
@@ -71,3 +72,3 @@ "jasmine-core": "^2.7.0", | ||
"karma": "^1.7.0", | ||
"karma-browserify": "^5.1.1", | ||
"karma-browserify": "^5.2.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
@@ -83,3 +84,3 @@ "karma-firefox-launcher": "^1.0.1", | ||
"swagger-http-router": "^0.1.0", | ||
"watchify": "^3.9.0" | ||
"watchify": "^3.11.0" | ||
}, | ||
@@ -86,0 +87,0 @@ "engines": { |
@@ -52,5 +52,5 @@ 'use strict'; | ||
deviceId: '1B28C5', | ||
startTime: new Date('2014-07-01T00:00:00.000Z').getTime(), | ||
endTime: new Date('2017-07-21T00:00:00.000Z').getTime(), | ||
authenticationToken: '902-771', | ||
startDate: new Date('2014-07-01T00:00:00.000Z').getTime(), | ||
endDate: new Date('2017-07-21T00:00:00.000Z').getTime(), | ||
authorization: '902-771', | ||
measures: ['RH_AIR_H1', 'TEMP_AIR_H1'], | ||
@@ -178,3 +178,3 @@ }).then(response => | ||
deviceId: '1B28C5', | ||
authenticationToken: '902-771', | ||
authorization: '902-771', | ||
body: { | ||
@@ -181,0 +181,0 @@ contents: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
840392
17335
1390
2
0
27