#!/bin/bash

electricBill="https://login.auth.aps.com/apsprodb2c.onmicrosoft.com/oauth2/v2.0/authorize?p=b2c_1a_aps_paassitecoresignin&response_type=code&client_id=874546d6-0a39-4299-b663-68cd9346f21f&redirect_uri=https://www.aps.com/authorization/loginredirect&scope=https://APSPRODB2C.onmicrosoft.com/APSBusinessAPI/user_impersonation%20offline_access%20openid&nonce=f0984d65-2e3a-479c-9bdb-3ad6ca7ef21c&response_mode=form_post&resource=%20https%3A%2F%2FAPSPRODB2C.onmicrosoft.com%2FAPSBusinessAPI"
gasBill="https://uesaz.com"
internetBill="https://customer.sparklight.com/securelogin/login.aspx"
waterBill="https://xpressbillpay.com/"

main_menu(){
    PS3="Enter a number: "
    select bill in Electric Gas Internet Water
    do

        case "${REPLY}" in
            1) xdg-open "${electricBill}"
            ;;

            2) xdg-open "${gasBill}"
            ;;

            3) xdg-open "${internetBill}"
            ;;

            4) xdg-open "${waterBill}"
            ;;

            q) exit 0
            ;;

            *) echo "Please choose an existing option"
            ;;

        esac
    done
}


case "${1}" in

    -e) xdg-open "${electricBill}"
    ;;

    -g) xdg-open "${gasBill}"
    ;;

    -i) xdg-open "${internetBill}"
    ;;

    -w) xdg-open "${waterBill}"
    ;;

    -h|--help|help)

        echo """
        $0 [-e] [-g] [-i] [-w]
        
        -e    Electric bill
        -g    Gas bill
        -i    Internet bill
        -w    Water bill
        """
    ;;

    *) main_menu
    ;;

    esac