Last active
May 4, 2024 11:03
-
-
Save alandooz/978840c89b874f891e44165ccdde12d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run this code in your browser console in https://www.asociarmeaosde.com.ar | |
let content = { | |
"update": false, | |
"nombre": "OSDE", | |
"groups": [ | |
{ | |
"filled": true | |
} | |
], | |
"filled": true, | |
"email": "osde@osde.com" | |
} | |
content.edad = 18 | |
content.provinciaCotizacion = "Ciudad Autónoma de Buenos Aires" | |
content.modalidadDeTrabajo = 'monotributo' | |
content.familia = 'mi' | |
// content['modalidad de trabajo-check'] = false // IF trabajador medico | |
// content.parejaEdad = "20" // IF familia con pareja | |
// IF familia con hijos | |
// let hijosEdad = ["2", "21", "22", "26", "27"] | |
// content.hijos = String(hijosEdad.length) | |
// hijosEdad.forEach((edad, index) => { | |
// content[`edadDeHijos-${index}`] = edad | |
// }) | |
// content['sueldo-principal'] = "150000" // IF trabajo en dependencia | |
// IF trabajo en dependencia y tengo mas de un sueldo | |
// let sueldoAdicional = ["170000", "180000", "190000"] | |
// sueldoAdicional.forEach((sueldo, index) => { | |
// content[`sueldo-adicional-${index}`] = sueldo | |
// }) | |
// content['sueldo-pareja'] = "200000" // IF trabajo en dependencia y familia con pareja y elijo agregar sueldo de pareja | |
let edadList = [18, 28, 36] | |
// let provinciaList = ['Ciudad Autónoma de Buenos Aires', 'Buenos Aires', 'Catamarca', 'Entre Ríos', 'Misiones', 'Chubut', 'Tucumán', 'Mendoza', 'Salta', 'Neuquén', 'San Luis', 'Santa Cruz', 'Tierra del Fuego', 'Formosa', 'Corrientes', 'Jujuy', 'Río Negro', 'San Juan', 'Córdoba', 'La Pampa', 'Santa Fe', 'La Rioja', 'Chaco', 'Santiago del Estero'] | |
let trabajoList = [ | |
// 'dependencia', | |
'monotributo', | |
'inscripto', | |
'independiente' | |
] | |
// let familiaList = ['mi', 'pareja', 'parejahijos', 'yoymishijos'] | |
async function getOSDE(content, override = {}) { | |
return await fetch("https://www.asociarmeaosde.com.ar/api/cotizacion", { | |
"headers": { | |
"accept": "application/json, text/plain, */*", | |
"content-type": "application/json", | |
}, | |
"body": JSON.stringify({...content, ...override}), | |
"method": "POST", | |
}).then(response => response.json()); | |
} | |
let today = new Date() | |
let year = today.getFullYear() | |
let month = String(today.getMonth() + 1).padStart(2, '0') | |
let day = String(today.getDate()).padStart(2, '0') | |
let osdeData = { | |
date: `${year}-${month}-${day}` | |
} | |
trabajoList.forEach(async trabajo => { | |
osdeData[trabajo] ??= {} | |
edadList.forEach(async edad => { | |
let response = await getOSDE(content, {edad, modalidadDeTrabajo: trabajo}) | |
osdeData[trabajo][edad] ??= {} | |
response.listaCotizacionesyProyecciones.listaCotizaciones.forEach(cotizacion => { | |
osdeData[trabajo][edad][cotizacion.planCotizado] ??= Math.trunc(cotizacion.valorPlanCotizado) | |
}) | |
}) | |
}) | |
console.log(osdeData) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run this code in your browser console in https://asociarme.swissmedical.com.ar | |
let content = { | |
"email": "swissmedical@swissmedical.com", | |
"holder": { | |
"name": "Swiss Medical", | |
"document": { | |
"type": "DU", | |
"number": 38948872 | |
}, | |
"obraSocialId": "" | |
}, | |
"phone": { | |
"code": 11, | |
"number": 42233223 | |
}, | |
"location": { | |
"province": "2", | |
"district": "" | |
}, | |
"spouse": {}, | |
"kidsAmount": "1", | |
"kids": [], | |
"salary": 0, | |
"gclid": null, | |
"scoring": "Service unavailable" | |
} | |
content.holder.age = 28 | |
content.province = "2" | |
content.workType = 'monotributista' | |
content.contractType = 'me' | |
let edadList = [18, 28, 36] | |
// let provinciaList = [ | |
// { | |
// "name": "CAPITAL FEDERAL", | |
// "value": "2" | |
// }, | |
// { | |
// "name": "BUENOS AIRES", | |
// "value": "1" | |
// }, | |
// { | |
// "name": "CATAMARCA", | |
// "value": "3" | |
// }, | |
// { | |
// "name": "CHACO", | |
// "value": "4" | |
// }, | |
// { | |
// "name": "CHUBUT", | |
// "value": "5" | |
// }, | |
// { | |
// "name": "CORDOBA", | |
// "value": "6" | |
// }, | |
// { | |
// "name": "CORRIENTES", | |
// "value": "7" | |
// }, | |
// { | |
// "name": "ENTRE RIOS", | |
// "value": "8" | |
// }, | |
// { | |
// "name": "FORMOSA", | |
// "value": "9" | |
// }, | |
// { | |
// "name": "JUJUY", | |
// "value": "10" | |
// }, | |
// { | |
// "name": "LA PAMPA", | |
// "value": "11" | |
// }, | |
// { | |
// "name": "LA RIOJA", | |
// "value": "12" | |
// }, | |
// { | |
// "name": "MENDOZA", | |
// "value": "13" | |
// }, | |
// { | |
// "name": "MISIONES", | |
// "value": "14" | |
// }, | |
// { | |
// "name": "NEUQUEN", | |
// "value": "15" | |
// }, | |
// { | |
// "name": "RIO NEGRO", | |
// "value": "17" | |
// }, | |
// { | |
// "name": "SALTA", | |
// "value": "18" | |
// }, | |
// { | |
// "name": "SAN JUAN", | |
// "value": "19" | |
// }, | |
// { | |
// "name": "SAN LUIS", | |
// "value": "20" | |
// }, | |
// { | |
// "name": "SANTA CRUZ", | |
// "value": "21" | |
// }, | |
// { | |
// "name": "SANTA FE", | |
// "value": "22" | |
// }, | |
// { | |
// "name": "SANTIAGO DEL ESTERO", | |
// "value": "23" | |
// }, | |
// { | |
// "name": "TUCUMAN", | |
// "value": "25" | |
// }, | |
// { | |
// "name": "TIERRA DEL FUEGO", | |
// "value": "24" | |
// } | |
// ] | |
let trabajoList = [ | |
// 'relacionDependencia', | |
'monotributista', | |
'particular', | |
] | |
// let contractType = ['me', 'me_and_spouse', 'me_and_kids', 'me_and_family'] | |
async function getSwissMedical(content, override = {}) { | |
return await fetch("https://asociarme.swissmedical.com.ar/api/onboarding/quote", { | |
"headers": { | |
"accept": "application/json, text/plain, */*", | |
"cache-control": "no-cache", | |
"content-type": "application/json;charset=UTF-8", | |
}, | |
"body": JSON.stringify({...content, ...override}), | |
"method": "POST", | |
}).then(response => response.json()); | |
} | |
let today = new Date() | |
let year = today.getFullYear() | |
let month = String(today.getMonth() + 1).padStart(2, '0') | |
let day = String(today.getDate()).padStart(2, '0') | |
let swissMedicalData = { | |
date: `${year}-${month}-${day}` | |
} | |
let listOfPromises = [] | |
trabajoList.forEach(trabajo => { | |
swissMedicalData[trabajo] ??= {} | |
edadList.forEach(edad => { | |
swissMedicalData[trabajo][edad] ??= {} | |
listOfPromises.push(getSwissMedical(content, {holder: {...content.holder, age: edad}, workType: trabajo})) | |
}) | |
}) | |
Promise.all(listOfPromises).then(responses => { | |
let indexCounter = 0; | |
trabajoList.forEach((trabajo, trabajoIndex) => { | |
edadList.forEach((edad, edadIndex) => { | |
let response = responses[indexCounter++] | |
response?.cotizaciones?.forEach(cotizacion => { | |
swissMedicalData[trabajo][edad][cotizacion.plan] ??= Math.trunc(cotizacion.precio+cotizacion.iva) | |
}) | |
}) | |
}) | |
console.log(swissMedicalData) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment