Skip to content

Commit

Permalink
Refactoring client
Browse files Browse the repository at this point in the history
  • Loading branch information
mchavez committed Apr 18, 2024
1 parent 1c888fb commit e841d47
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
"net/url"

"github.com/conductorone/baton-sdk/pkg/uhttp"
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
)

type VGSClient struct {
httpClient *http.Client
httpClient *uhttp.BaseHttpClient
token *JWT
endpoint string
}
Expand Down Expand Up @@ -55,7 +56,7 @@ func New(ctx context.Context, clientId string, clientSecret string) (*VGSClient,
return nil, err
}

httpClient, err := uhttp.NewClient(ctx, uhttp.WithLogger(true, nil))
httpClient, err := uhttp.NewClient(ctx, uhttp.WithLogger(true, ctxzap.Extract(ctx)))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -89,7 +90,7 @@ func New(ctx context.Context, clientId string, clientSecret string) (*VGSClient,
}

vc := VGSClient{
httpClient: httpClient,
httpClient: cli,
token: &JWT{
AccessToken: jwt.AccessToken,
ExpiresIn: jwt.ExpiresIn,
Expand All @@ -109,8 +110,8 @@ func (v *VGSClient) GetToken() string {
}

func (v *VGSClient) GetOrganizations(ctx context.Context) ([]Organization, error) {
url, _ := url.JoinPath(v.endpoint, "/organizations")
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
uri, _ := url.JoinPath(v.endpoint, "/organizations")
req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e841d47

Please sign in to comment.