Last active
February 3, 2017 23:12
-
-
Save andreyvital/c20fa85346fd9079d17a9566d3c9c9d4 to your computer and use it in GitHub Desktop.
Total gasto no cartão Nubank https://nubank.com.br/. Uso: `nubank.sh <CPF> <senha>`
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
#!/usr/bin/env bash | |
set -e | |
JQ="jq --raw-output" | |
acquireTokenPayload=$(cat <<EOT | |
{ | |
"client_id": "other.conta", | |
"client_secret": "yQPeLzoHuJzlMMSAjC-LgNUJdUecx8XO", | |
"grant_type": "password", | |
"login": "$1", | |
"password": "$2" | |
} | |
EOT) | |
acquireTokenPayload=$(echo -n $acquireTokenPayload) | |
response=$( | |
curl -s -H "Content-Type: application/json" -X POST -d "$acquireTokenPayload" \ | |
https://prod-global-auth.nubank.com.br/api/token | |
) | |
eventsHref=$(echo $response |$JQ '._links.events.href') | |
accessToken=$(echo $response |$JQ '.access_token') | |
curl -s -H "Authorization: Bearer $accessToken" $eventsHref |\ | |
$JQ '.events[] | select(.category == "transaction" and .amount > 0) | .amount' |\ | |
xargs |\ | |
sed 's/ /+/g' |\ | |
bc |awk '{print "R$ " $1/100}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment