44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package util
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
eiaapi "gitea.libretechconsulting.com/rmcguire/eia-api-go/api"
|
|
"gitea.libretechconsulting.com/rmcguire/eia-api-go/pkg/eia"
|
|
)
|
|
|
|
func GetRouteType(cmd *cobra.Command, route string) (eia.RouteType, error) {
|
|
client, err := Client(cmd)
|
|
if err != nil {
|
|
return eia.RouteTypeError, err
|
|
}
|
|
return client.GetRouteType(cmd.Context(), route, eia.DefaultMethodSubs(cmd.Context()))
|
|
}
|
|
|
|
func GetRoute(cmd *cobra.Command, route string) (*eiaapi.FinalRoute, *eiaapi.Routes, error) {
|
|
client, err := Client(cmd)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
return client.GetRoutesOrFinalRoute(cmd.Context(), route, eia.DefaultMethodSubs(cmd.Context()))
|
|
}
|
|
|
|
func GetFacet(cmd *cobra.Command, route string, facet string) (*eiaapi.FacetDetails, error) {
|
|
client, err := Client(cmd)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return client.GetFacet(cmd.Context(), route, facet, eia.DefaultMethodSubs(cmd.Context()))
|
|
}
|
|
|
|
func GetFacets(cmd *cobra.Command, route string) (*eiaapi.FacetOptionList, error) {
|
|
client, err := Client(cmd)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return client.GetFacets(cmd.Context(), route, eia.DefaultMethodSubs(cmd.Context()))
|
|
}
|