Skip to content

Commit

Permalink
Utilized formatAPIPath
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikZilber committed Jun 18, 2024
1 parent bb43a31 commit 04caf51
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
13 changes: 3 additions & 10 deletions account_oauth_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package linodego

import (
"context"
"fmt"
"net/url"
)

// OAuthClientStatus constants start with OAuthClient and include Linode API Instance Status values
Expand Down Expand Up @@ -94,9 +92,7 @@ func (c *Client) ListOAuthClients(ctx context.Context, opts *ListOptions) ([]OAu

// GetOAuthClient gets the OAuthClient with the provided ID
func (c *Client) GetOAuthClient(ctx context.Context, clientID string) (*OAuthClient, error) {
clientID = url.PathEscape(clientID)
e := fmt.Sprintf("account/oauth-clients/%s", clientID)

e := formatAPIPath("account/oauth-clients/%s", clientID)
response, err := doGETRequest[OAuthClient](ctx, c, e)
if err != nil {
return nil, err
Expand All @@ -118,9 +114,7 @@ func (c *Client) CreateOAuthClient(ctx context.Context, opts OAuthClientCreateOp

// UpdateOAuthClient updates the OAuthClient with the specified id
func (c *Client) UpdateOAuthClient(ctx context.Context, clientID string, opts OAuthClientUpdateOptions) (*OAuthClient, error) {
clientID = url.PathEscape(clientID)

e := fmt.Sprintf("account/oauth-clients/%s", clientID)
e := formatAPIPath("account/oauth-clients/%s", clientID)
response, err := doPUTRequest[OAuthClient](ctx, c, e, opts)
if err != nil {
return nil, err
Expand All @@ -131,8 +125,7 @@ func (c *Client) UpdateOAuthClient(ctx context.Context, clientID string, opts OA

// DeleteOAuthClient deletes the OAuthClient with the specified id
func (c *Client) DeleteOAuthClient(ctx context.Context, clientID string) error {
clientID = url.PathEscape(clientID)
e := fmt.Sprintf("account/oauth-clients/%s", clientID)
e := formatAPIPath("account/oauth-clients/%s", clientID)
err := doDELETERequest(ctx, c, e)
return err
}
4 changes: 1 addition & 3 deletions account_payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package linodego
import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/linode/linodego/internal/parseabletime"
Expand Down Expand Up @@ -68,8 +67,7 @@ func (c *Client) ListPayments(ctx context.Context, opts *ListOptions) ([]Payment

// GetPayment gets the payment with the provided ID
func (c *Client) GetPayment(ctx context.Context, paymentID int) (*Payment, error) {
e := fmt.Sprintf("account/payments/%d", paymentID)

e := formatAPIPath("account/payments/%d", paymentID)
response, err := doGETRequest[Payment](ctx, c, e)
if err != nil {
return nil, err
Expand Down
8 changes: 2 additions & 6 deletions account_user_grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package linodego

import (
"context"
"fmt"
"net/url"
)

type GrantPermissionLevel string
Expand Down Expand Up @@ -68,8 +66,7 @@ type UserGrantsUpdateOptions struct {
}

func (c *Client) GetUserGrants(ctx context.Context, username string) (*UserGrants, error) {
username = url.PathEscape(username)
e := fmt.Sprintf("account/users/%s/grants", username)
e := formatAPIPath("account/users/%s/grants", username)
response, err := doGETRequest[UserGrants](ctx, c, e)
if err != nil {
return nil, err
Expand All @@ -79,8 +76,7 @@ func (c *Client) GetUserGrants(ctx context.Context, username string) (*UserGrant
}

func (c *Client) UpdateUserGrants(ctx context.Context, username string, opts UserGrantsUpdateOptions) (*UserGrants, error) {
username = url.PathEscape(username)
e := fmt.Sprintf("account/users/%s/grants", username)
e := formatAPIPath("account/users/%s/grants", username)
response, err := doPUTRequest[UserGrants](ctx, c, e, opts)
if err != nil {
return nil, err
Expand Down

0 comments on commit 04caf51

Please sign in to comment.