Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- HOME="LAT LONG"
- L1="LAT LONG"
- function estimate {
- a=("$@")
- curl -s -H 'Authorization: Token PHwMpfN6RXKMUwp5Pf3Al0wCUBUhbS2mvSftYt-r' \
- -H 'Accept-Language: en_US' \
- -H 'Content-Type: application/json' \
- "https://api.uber.com/v1.2/estimates/price?start_latitude=${a[0]}&start_longitude=${a[1]}&end_latitude=${a[2]}&end_longitude=${a[3]}" \
- | jq '[.prices[] | {type: .localized_display_name, price: ((.low_estimate + .high_estimate)/2)} | {(.type): .price}] | reduce .[] as $item ({'"direction: \"${a[4]}\""'}; . + $item)'
- }
- function run_measurement {
- case "$1" in
- mode1) estimate $HOME $L1 home_to_l1;;
- mode1r) estimate $L1 $HOME l1_to_home;;
- esac
- }
- for S in mode1{,r}; do
- run_measurement $S
- done | jq -s '[.[] | {direction: .direction, entries: to_entries | map (select (.key != "direction"))} | .entries[].direction = .direction | .entries[] | .key = "\(.direction)_\(.key)"] | from_entries' | tr 'QWERTYUIOPASDFGHJKLZXCVBNM' 'qwertyuiopasdfghjklzxcvbnm'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement