2020-11-11 16:13:40 +01:00
|
|
|
#!/bin/bash
|
2020-11-11 18:09:05 +01:00
|
|
|
set -e
|
|
|
|
source ./config.sh
|
|
|
|
# Get the Netflix Billing Page
|
|
|
|
[[ -f "BillingActivity.html" ]] || curl -v 'https://www.netflix.com/BillingActivity'\
|
2020-11-11 16:13:40 +01:00
|
|
|
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'\
|
2020-11-11 18:09:05 +01:00
|
|
|
--compressed \
|
|
|
|
--config .env.browser_fingerprint\
|
|
|
|
--config .env.netflix_cookies > BillingActivity.html
|
2020-11-11 16:13:40 +01:00
|
|
|
|
2020-11-11 18:09:05 +01:00
|
|
|
# Download the last invoice
|
|
|
|
LAST_INVOICE_URL=$(cat BillingActivity.html | grep -o '/invoice/print/[^"]*' | head -1)
|
|
|
|
[[ -f "LastInvoice.html" ]] || curl -v --compressed --config .env.netflix_cookies "$NETFLIX_BASE_URL$LAST_INVOICE_URL" > LastInvoice.html
|
2020-11-11 16:13:40 +01:00
|
|
|
|
2020-11-11 18:09:05 +01:00
|
|
|
# Convert to pdf
|
|
|
|
[[ -f "LastInvoice.pdf" ]] || wkhtmltopdf LastInvoice.html LastInvoice.pdf
|
2020-11-11 16:13:40 +01:00
|
|
|
|
2020-11-11 18:09:05 +01:00
|
|
|
# Leeto login
|
|
|
|
[[ -f "leeto_auth_payload.json" ]] || curl -v 'https://api.leeto.co/api/v2/users/sign_in?locale=fr'\
|
|
|
|
-H 'Accept: application/json, text/plain, */*'\
|
|
|
|
--config .env.browser_fingerprint\
|
|
|
|
--compressed -H 'Content-Type: application/json'\
|
|
|
|
--data-raw '{"user":{"email":"'"$LEETO_EMAIL"'","password":"'"$LEETO_PASSWORD"'"}}' > leeto_auth_payload.json
|
|
|
|
|
|
|
|
LEETO_BEARER_TOKEN=$(cat leeto_auth_payload.json | jq --raw-output '.token')
|
|
|
|
LEETO_USER_ID=$(cat leeto_auth_payload.json | jq --raw-output '.id')
|
|
|
|
|
|
|
|
curl -v "https://api.leeto.co/api/v2/organisations/$LEETO_ORGANISATION_ID/reimbursement_requests?locale=fr"\
|
|
|
|
-H 'Accept: application/json, text/plain, */*'\
|
|
|
|
--compressed \
|
|
|
|
--header "Authorization: Bearer $LEETO_BEARER_TOKEN"\
|
|
|
|
--config .env.browser_fingerprint\
|
|
|
|
--form "reimbursement_request[user_id]=$LEETO_USER_ID"\
|
|
|
|
--form "reimbursement_request[grantable_id]=$LEETO_USER_ID"\
|
|
|
|
--form "reimbursement_request[grantable_type]=User"\
|
|
|
|
--form "reimbursement_request[amount]=$LEETO_AMOUNT"\
|
|
|
|
--form "reimbursement_request[quotum_id]=$LEETO_QUOTUM_ID"\
|
|
|
|
--form "reimbursement_request[receipts_attributes][][image]=@LastInvoice.pdf"
|