Last active
September 19, 2024 05:28
-
-
Save MathewDominic/525a6fefe38b3607290f4bdcddebf2ab 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
// This script returns the bonus points one is supposed to get for vouchers bought from Axis Gyftr | |
// Run this script from console after logging in to https://www.gyftr.com/edgerewards | |
async function postData(url = '', data = {}) { | |
const response = await fetch("https://api.gyftr.com/axis-bank/api/order/getAllOrders/", { | |
"headers": { | |
"accept": "*/*", | |
"accept-language": "en-US,en;q=0.9,ml;q=0.8", | |
"content-type": "application/json", | |
"sec-ch-ua": "\"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"", | |
"sec-ch-ua-mobile": "?0", | |
"sec-ch-ua-platform": "\"macOS\"", | |
"sec-fetch-dest": "empty", | |
"sec-fetch-mode": "cors", | |
"sec-fetch-site": "same-site", | |
"token": localStorage.getItem('AUTH_ACCESS_TOKEN') // this is the token header sent in requests | |
}, | |
"referrer": "https://www.gyftr.com/", | |
"referrerPolicy": "strict-origin-when-cross-origin", | |
"body": "{\"days\":\"\",\"status\":\"C\",\"brand\":\"\",\"page\":1,\"limit\":250}", | |
"method": "POST", | |
"mode": "cors", | |
"credentials": "omit" | |
}); | |
return response.json(); | |
} | |
postData() | |
.then((data) => { | |
console.log(data); | |
x3 = ["Amazon"] | |
x5 = ["Amazon Shopping Voucher", "OLA CABS", "Flipkart", "Swiggy Money Voucher", "zomato GV", "Decathlon", "Croma", "Reliance Trends"]; | |
x10 = ["Myntra", "SonyLIV","MAX", "Apollo Pharmacy", "Lifestyle"]; | |
rows = ["Merchant,Date,amountPaidAfterDiscount,multiplier,normalPoints,bonusPoints"] | |
for(i in data["data"]) { | |
row = data["data"][i] | |
if(i > 0 && data["data"][i]["order_number"] == data["data"][i-1]["order_number"]) | |
continue; | |
voucherValue = row["face_value"] | |
amountPaidAfterDiscount = row["cash"] | |
if (x3.indexOf(row["brand_name"]) > -1) | |
multiplier = 3 | |
else if (x5.indexOf(row["brand_name"]) > -1) | |
multiplier = 5 | |
else if (x10.indexOf(row["brand_name"]) > -1) | |
multiplier = 10 | |
else { | |
multiplier = parseInt(prompt('Enter mulitplier for:' + row["brand_name"])) | |
console.log(multiplier) | |
if (multiplier == 3) { | |
x3.push(row["brand_name"]) | |
} | |
else if (multiplier == 5) { | |
x5.push(row["brand_name"]) | |
} | |
else if (multiplier == 10) { | |
x10.push(row["brand_name"]) | |
} | |
} | |
normalPoints = Math.floor(row["cash"]/200) * 12 | |
bonusPoints = normalPoints * (multiplier - 1) | |
rows.push([row["brand_name"],row["order_on"],amountPaidAfterDiscount,multiplier,normalPoints,bonusPoints].join(",")) | |
} | |
console.log(rows.join('\n')); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment