-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproximus-data-script.sh
73 lines (63 loc) · 2.42 KB
/
proximus-data-script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
prompt_cookie() {
read -s -p "Enter the cookie 'iiamsid' value : " cookie_value
echo
}
prompt_executions() {
read -p "How many packs ? : " num_executions
if ! [[ "$num_executions" =~ ^[1-9]$|^10$ ]]; then
echo "Invalid input! Please enter a number between 1 and 10."
prompt_executions
fi
}
use_previous_cookie() {
read -p "Do you want to use the previous cookie? [Y/n]: " choice
case $choice in
yes|Yes|YES|y|Y)
if [ -f "cookie" ]; then
cookie_value=$(<cookie)
else
echo "No previous cookie found. Enter a new one."
prompt_cookie
fi
;;
no|No|NO|n|N)
prompt_cookie
;;
*)
echo "Invalid choice. Please enter 'yes' or 'no'."
use_previous_cookie
;;
esac
}
use_previous_cookie
prompt_executions
# Store the cookie value in the "cookie" file
echo "$cookie_value" > cookie
# Retrieve ServiceID from account
serviceID=$(curl -s 'https://www.proximus.be/rest/products-aggregator/user-product-overview' \
-X GET -H "Cookie: iiamsid=$cookie_value" \
| jq -r '.FLS.inPackProducts[0].products[] | select(.technicalName == "internet") | .accessNumber')
pids=()
#Curl command in async + logging
execute_async() {
local i=$1
curl -s "https://www.proximus.be/rest/shopping-basket/product/FI?serviceId=$serviceID" -X POST -H 'Content-Type: application/json' \
--data-raw '{"actions":[{"name":"MyProximusConfirmAction","parameters":{"MPC_UUID":"KIIGH"},"type":"serverSide","dependsOnSubStepId":false,"dependsOnOtherFieldsWithSameId":false}],"configuration":{},"cpvComponent":{"mpcUuid":"KIIGH","chargeEvent":"PR","chargeCode":"KETKR","action":"PROVIDE"}}' \
-H "Cookie: iiamsid=$cookie_value" | (
result="$(cat)"
if [[ -z "$result" ]]; then
echo "Result ($i/$num_executions) : Failed.. (Wrong cookie?)"
else
# Process non-empty output with jq
echo "Result ($i/$num_executions) : $(echo "$result" | jq -r '.validationResult.status // "Failed.. (Create an issue on github for this one)"')"
fi
) &
pids[$i]="$!"
}
#Request a pack X times
for ((i = 1; i <= num_executions; i++)); do
echo "Requesting 300GB... ($i/$num_executions)"
execute_async $i
done
wait "${pids[@]}" # Wait for all PIDs in the pids array (wait for all curl commands to finish)