eia-api-go/cmd/eia-client/internal/util/util_reflect.go

44 lines
1.1 KiB
Go
Raw Normal View History

2024-11-26 15:54:55 +00:00
package util
import (
"github.com/spf13/cobra"
eiaapi "gitea.libretechconsulting.com/50W/eia-api-go/api"
2024-11-26 22:12:39 +00:00
"gitea.libretechconsulting.com/50W/eia-api-go/pkg/eia"
2024-11-26 15:54:55 +00:00
)
2024-12-04 21:01:07 +00:00
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()))
}
2024-11-29 21:58:12 +00:00
func GetRoute(cmd *cobra.Command, route string) (*eiaapi.FinalRoute, *eiaapi.Routes, error) {
2024-11-27 02:34:51 +00:00
client, err := Client(cmd)
if err != nil {
2024-11-29 21:58:12 +00:00
return nil, nil, err
2024-11-27 02:34:51 +00:00
}
2024-11-29 21:58:12 +00:00
return client.GetRoutesOrFinalRoute(cmd.Context(), route, eia.DefaultMethodSubs(cmd.Context()))
2024-11-27 02:34:51 +00:00
}
2024-11-26 22:12:39 +00:00
func GetFacet(cmd *cobra.Command, route string, facet string) (*eiaapi.FacetDetails, error) {
2024-11-26 15:54:55 +00:00
client, err := Client(cmd)
if err != nil {
return nil, err
}
2024-11-26 22:12:39 +00:00
return client.GetFacet(cmd.Context(), route, facet, eia.DefaultMethodSubs(cmd.Context()))
}
2024-11-26 22:12:39 +00:00
func GetFacets(cmd *cobra.Command, route string) (*eiaapi.FacetOptionList, error) {
client, err := Client(cmd)
if err != nil {
return nil, err
}
2024-11-26 22:12:39 +00:00
return client.GetFacets(cmd.Context(), route, eia.DefaultMethodSubs(cmd.Context()))
}