don't export BearerToken
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Steven Polley 2024-03-23 19:45:28 -06:00
parent e35f0ef659
commit 54417bf436

View File

@ -19,7 +19,7 @@ const apiBaseURL = "https://api.ynab.com/v1/budgets/"
// endpoints. It holds the login credentials, http client/transport, // endpoints. It holds the login credentials, http client/transport,
// rate limit information, and the login session timer. // rate limit information, and the login session timer.
type Client struct { type Client struct {
BearerToken string bearerToken string
BudgetID string BudgetID string
httpClient *http.Client httpClient *http.Client
transport *http.Transport transport *http.Transport
@ -32,7 +32,7 @@ func (c *Client) get(endpoint string, out interface{}, query url.Values) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create new GET request: %v", err) return fmt.Errorf("failed to create new GET request: %v", err)
} }
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.BearerToken)) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.bearerToken))
res, err := c.httpClient.Do(req) res, err := c.httpClient.Do(req)
if err != nil { if err != nil {
@ -58,7 +58,7 @@ func (c *Client) post(endpoint string, out interface{}, body interface{}) error
if err != nil { if err != nil {
return fmt.Errorf("failed to create new POST request: %v", err) return fmt.Errorf("failed to create new POST request: %v", err)
} }
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.BearerToken)) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.bearerToken))
req.Header.Add("Content-Type", "application/json") req.Header.Add("Content-Type", "application/json")
res, err := c.httpClient.Do(req) res, err := c.httpClient.Do(req)
@ -85,7 +85,7 @@ func (c *Client) put(endpoint string, out interface{}, body interface{}) error {
if err != nil { if err != nil {
return fmt.Errorf("failed to create new POST request: %v", err) return fmt.Errorf("failed to create new POST request: %v", err)
} }
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.BearerToken)) req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", c.bearerToken))
req.Header.Add("Content-Type", "application/json") req.Header.Add("Content-Type", "application/json")
res, err := c.httpClient.Do(req) res, err := c.httpClient.Do(req)
@ -140,7 +140,7 @@ func NewClient(budgetID, bearerToken string) (*Client, error) {
// Create a new client // Create a new client
c := &Client{ c := &Client{
BudgetID: budgetID, BudgetID: budgetID,
BearerToken: bearerToken, bearerToken: bearerToken,
httpClient: client, httpClient: client,
transport: transport, transport: transport,
loc: loc, loc: loc,