From 19426faddc0568aa7d25e5295f4dbaaa4018bd97 Mon Sep 17 00:00:00 2001 From: Miguel Fernandez Date: Tue, 8 Dec 2020 16:34:43 +0100 Subject: [PATCH] =?UTF-8?q?a=C3=B1ado=20funciones=20del=20bot=20para=20con?= =?UTF-8?q?eseguir=20los=20items=20de=20una=20marca=20#43?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/brand.js | 12 ++++++------ functions/data.json | 4 ++-- functions/{wBrand.js => getBrand.js} | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) rename functions/{wBrand.js => getBrand.js} (84%) diff --git a/functions/brand.js b/functions/brand.js index 11f5db3..244c777 100644 --- a/functions/brand.js +++ b/functions/brand.js @@ -1,4 +1,4 @@ -const brand = require('./wBrand') +const brand = require('./getBrand') exports.handler = async function(event, context){ try{ @@ -9,19 +9,19 @@ exports.handler = async function(event, context){ if(text){ switch(text){ case "/puma": - item = brand.wBrand("PUMA"); + item = brand.gBrand("PUMA"); break; case "/adidas": - item = brand.wBrand("ADIDAS"); + item = brand.gBrand("ADIDAS"); break; case "/kappa": - item = brand.wBrand("KAPPA"); + item = brand.gBrand("KAPPA"); break; case "/nike": - item = brand.wBrand("NIKE"); + item = brand.gBrand("NIKE"); break; case "/joma": - item = brand.wBrand("JOMA"); + item = brand.gBrand("JOMA"); break; default: item = "Para ver los objetos de marca Puma utilice /puma, para Adidas /adidas , para Kappa /kappa. para Nike /nike y para Joma /joma" diff --git a/functions/data.json b/functions/data.json index 2515d7f..e94de8f 100644 --- a/functions/data.json +++ b/functions/data.json @@ -1,5 +1,5 @@ { - "items": [ + "items": { { "type":"HOODIE", "size":"M", @@ -45,6 +45,6 @@ "color":"BLACK", "price": 50, "season":"FALL_WINTER" + } } - ] } diff --git a/functions/wBrand.js b/functions/getBrand.js similarity index 84% rename from functions/wBrand.js rename to functions/getBrand.js index 109451c..1d2eeff 100644 --- a/functions/wBrand.js +++ b/functions/getBrand.js @@ -1,6 +1,6 @@ const data = require('./data.json'); -function wBrand(b){ +function gBrand(b){ item = ""; for(i = 1; i <= 6; i++){ type = ""; @@ -8,7 +8,7 @@ function wBrand(b){ if (data['items'][i]["brand"] == b){ if (data['items'][i]["type"].length > 0){ for( j = 0; j < data['items'][i]["type"].length; j++){ - type += "\n Tarea: " + data['items'][i]["type"][j] + + type += "\n Type: " + data['items'][i]["type"][j] + "\n Size: " + data['items'][i]["size"][j]; } } @@ -22,4 +22,4 @@ function wBrand(b){ return item; } - module.exports={wBrand} + module.exports={gBrand}