Advertisement
Guest User

Untitled

a guest
Sep 4th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. HOME="LAT LONG"
  4. L1="LAT LONG"
  5.  
  6. function estimate {
  7. a=("$@")
  8. curl -s -H 'Authorization: Token PHwMpfN6RXKMUwp5Pf3Al0wCUBUhbS2mvSftYt-r' \
  9. -H 'Accept-Language: en_US' \
  10. -H 'Content-Type: application/json' \
  11. "https://api.uber.com/v1.2/estimates/price?start_latitude=${a[0]}&start_longitude=${a[1]}&end_latitude=${a[2]}&end_longitude=${a[3]}" \
  12. | jq '[.prices[] | {type: .localized_display_name, price: ((.low_estimate + .high_estimate)/2)} | {(.type): .price}] | reduce .[] as $item ({'"direction: \"${a[4]}\""'}; . + $item)'
  13. }
  14.  
  15. function run_measurement {
  16. case "$1" in
  17. mode1) estimate $HOME $L1 home_to_l1;;
  18. mode1r) estimate $L1 $HOME l1_to_home;;
  19. esac
  20. }
  21.  
  22. for S in mode1{,r}; do
  23. run_measurement $S
  24. 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