make client interface

This commit is contained in:
Mike Mason
2023-07-18 13:36:41 +00:00
parent 05762f5d75
commit f828546cfe
10 changed files with 72 additions and 46 deletions

View File

@@ -29,7 +29,7 @@ func MustViperFlags(v *viper.Viper, flags *pflag.FlagSet) {
// WithConfig applies all configurations defined in the config.
func WithConfig(config Config) Option {
return func(c *Client) error {
return func(c *client) error {
var options []Option
if config.BaseURL != "" {
@@ -52,7 +52,7 @@ func WithConfig(config Config) Option {
// WithBaseURL updates the baseurl used by the client.
func WithBaseURL(baseURL string) Option {
return func(c *Client) error {
return func(c *client) error {
u, err := url.Parse(baseURL)
if err != nil {
return fmt.Errorf("failed to parse emapi base url %s: %w", baseURL, err)
@@ -66,7 +66,7 @@ func WithBaseURL(baseURL string) Option {
// WithBearerToken sets the bearer token to authenticate the request with.
func WithBearerToken(token string) Option {
return func(c *Client) error {
return func(c *client) error {
c.token = token
return nil