Skip to content

Commit

Permalink
Subida inicial
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel E. Fernández Pera committed Sep 27, 2019
0 parents commit fd70b9a
Show file tree
Hide file tree
Showing 13 changed files with 881 additions and 0 deletions.
Binary file added assets/build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/developer-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/json-node.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/json-npm-install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/polen-services-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/polen-services.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions json/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const request = require("request-promise-native");

handle();

// Task handler simulation
async function handle(handlerInput) {
// Make request
const r = await request(
prepareOptions("http://www.zaragoza.es/sede/servicio/informacion-polen")
);

// Parse response
const json = JSON.parse(r.body);

// Do stuff with response
console.log("---------------------------");
console.log("| Raw body |");
console.log("---------------------------");
console.log(r.body);

console.log("\n");
console.log("---------------------------");
console.log("| Parsed JSON |");
console.log("---------------------------");
console.log(json);

console.log("\n");
console.log("-------------------------------------");
console.log("| Extracted values - General |");
console.log("-------------------------------------");
var talkResultGeneral = "";
const resultElements = json.result;
resultElements.forEach(element => {
console.log(element.title);
console.log("\t Observaciones: " + element.observation);
console.log("\t Observaciones (texto): " + JSON.stringify(element.observation));
console.log("\t Nivel: " + element.observation[0].value);

talkResultGeneral += element.title + ":" + element.observation[0].value + ",";
});
console.log("\nTalk result - General: \n\t" + talkResultGeneral);

console.log("\n");
console.log("-------------------------------------");
console.log("| Extracted values - By level |");
console.log("-------------------------------------");
const level = "bajo";
var talkResultLevel = "";
const resultElementsLevel = json.result;
resultElementsLevel.forEach(element => {
if(element.observation[0].value === level)
talkResultLevel += element.title + ",";
});
if(talkResultLevel === "")
talkResultLevel = "No hay medidas de nivel '" + level + "'";
console.log("\nTalk result - By level: \n\t" + talkResultLevel);
}

// Utility function
function prepareOptions(url) {
return {
url: url,
headers: {
Accept: "application/json"
},
resolveWithFullResponse: true
};
}
Loading

0 comments on commit fd70b9a

Please sign in to comment.