diff --git a/ynab/accounts.go b/ynab/accounts.go index 676fe7e..e4a29b9 100644 --- a/ynab/accounts.go +++ b/ynab/accounts.go @@ -8,7 +8,7 @@ import ( // Reference: https://api.ynab.com/v1#/Accounts/ -type Accounts struct { +type accounts struct { Data struct { Account struct { ID string `json:"id"` @@ -29,8 +29,8 @@ type Accounts struct { } `json:"data"` } -func (c *Client) GetAccount(accountID string) (*Accounts, error) { - response := Accounts{} +func (c *Client) getAccount(accountID string) (*accounts, error) { + response := accounts{} err := c.get(fmt.Sprintf("/accounts/%s", accountID), &response, url.Values{}) if err != nil { @@ -49,7 +49,7 @@ func (c *Client) SetAccountBalance(accountID string, balance int) error { return fmt.Errorf("failed to get ynab capital gains transaction ID: %v", err) } - ynabAccount, err := c.GetAccount(accountID) + ynabAccount, err := c.getAccount(accountID) if err != nil { return fmt.Errorf("failed to get ynab account with id '%s': %v", accountID, err) } diff --git a/ynab/transactions.go b/ynab/transactions.go index 067f014..dee45b5 100644 --- a/ynab/transactions.go +++ b/ynab/transactions.go @@ -7,7 +7,7 @@ import ( ) // Reference: https://api.ynab.com/v1#/Transactions/ -type Transaction struct { +type transaction struct { Type string `json:"type,omitempty"` ParentTransactionID interface{} `json:"parent_transaction_id,omitempty"` ID string `json:"id,omitempty"` @@ -31,31 +31,31 @@ type Transaction struct { } // Used for single transaction requests -type TransactionRequest struct { - Transaction Transaction `json:"transaction,omitempty"` +type transactionRequest struct { + Transaction transaction `json:"transaction,omitempty"` } // Used for single transaction responses -type TransactionResponse struct { +type transactionResponse struct { Data struct { TransactionIDs []string `json:"transaction_ids,omitempty"` - Transaction Transaction `json:"transaction"` + Transaction transaction `json:"transaction"` ServerKnowledge int `json:"server_knowledge,omitempty"` } } // Used for multiple transaction requests / responses -type TransactionsResponse struct { +type transactionListResponse struct { Data struct { - Transactions []Transaction `json:"transactions"` + Transactions []transaction `json:"transactions"` ServerKnowledge int `json:"server_knowledge"` } `json:"data"` } // Accepts a YNAB account ID and timestamp and returns all transactions in that account // since the date provided -func (c *Client) GetAccountTransactions(accountID string, sinceDate time.Time) (*TransactionsResponse, error) { - response := TransactionsResponse{} +func (c *Client) GetAccountTransactions(accountID string, sinceDate time.Time) (*transactionListResponse, error) { + response := transactionListResponse{} urlQuery := url.Values{} urlQuery.Add("since_date", sinceDate.Format("2006-01-02")) @@ -86,8 +86,8 @@ func (c *Client) getTodayYnabCapitalGainsTransaction(accountID string) (string, // Accepts a YNAB account ID, transaction ID and transaction amount and updates the YNAB transaction with the matching ID // If transaction ID is blank, a new transaction is created for the amount specified func (c *Client) updateTodayYNABCapitalGainsTransaction(accountID string, transactionID string, amount int) error { - request := TransactionRequest{ - Transaction: Transaction{ + request := transactionRequest{ + Transaction: transaction{ AccountID: accountID, Amount: amount, Date: time.Now().In(c.loc).Format("2006-01-02"), @@ -97,7 +97,7 @@ func (c *Client) updateTodayYNABCapitalGainsTransaction(accountID string, transa Memo: fmt.Sprintf("Quoted at: %s", time.Now().In(c.loc).Format("2006-01-02 15:04:05")), }, } - response := &TransactionResponse{} + response := &transactionResponse{} var err error if transactionID == "" { // create transaction err = c.post("/transactions", response, request)