diff --git a/providers/bitcoin/address.go b/providers/bitcoin/address.go index a13c61c..562081d 100644 --- a/providers/bitcoin/address.go +++ b/providers/bitcoin/address.go @@ -25,7 +25,7 @@ type Address struct { // GetAddress returns an Address struct populated with data from blockstream.info // for a given BTC address -func (c *client) GetAddress(address string) (*Address, error) { +func (c *client) getAddress(address string) (*Address, error) { addressResponse := &Address{} err := c.get(fmt.Sprintf("address/%s", address), addressResponse, url.Values{}) diff --git a/providers/bitcoin/providerImpl.go b/providers/bitcoin/providerImpl.go index 1354f40..a28e524 100644 --- a/providers/bitcoin/providerImpl.go +++ b/providers/bitcoin/providerImpl.go @@ -51,7 +51,7 @@ func (p *Provider) GetBalances() ([]int, []string, error) { ynabAccountIDs := make([]string, 0) var satoshiBalance int for _, bitcoinAddress := range p.bitcoinAddresses { - addressResponse, err := p.client.GetAddress(bitcoinAddress) + addressResponse, err := p.client.getAddress(bitcoinAddress) if err != nil { return balances, ynabAccountIDs, fmt.Errorf("failed to get bitcoin address '%s': %v", bitcoinAddress, err) } diff --git a/providers/questrade/account.go b/providers/questrade/account.go index 431c35b..f369280 100644 --- a/providers/questrade/account.go +++ b/providers/questrade/account.go @@ -10,7 +10,7 @@ import ( // of which the API client is authorized. // // Ref: http://www.questrade.com/api/documentation/rest-operations/account-calls/accounts -type Account struct { +type account struct { // Type of the account (e.g., "Cash", "Margin"). Type string `json:"type"` @@ -34,7 +34,7 @@ type Account struct { // Balance belonging to an Account // // Ref: http://www.questrade.com/api/documentation/rest-operations/account-calls/accounts-id-balances -type Balance struct { +type balance struct { // Currency of the balance figure(e.g., "USD" or "CAD"). Currency string `json:"currency"` @@ -61,35 +61,35 @@ type Balance struct { // AccountBalances represents per-currency and combined balances for a specified account. // // Ref: http://www.questrade.com/api/documentation/rest-operations/account-calls/accounts-id-balances -type AccountBalances struct { - PerCurrencyBalances []Balance `json:"perCurrencyBalances"` - CombinedBalances []Balance `json:"combinedBalances"` - SODPerCurrencyBalances []Balance `json:"sodPerCurrencyBalances"` - SODCombinedBalances []Balance `json:"sodCombinedBalances"` +type accountBalances struct { + PerCurrencyBalances []balance `json:"perCurrencyBalances"` + CombinedBalances []balance `json:"combinedBalances"` + SODPerCurrencyBalances []balance `json:"sodPerCurrencyBalances"` + SODCombinedBalances []balance `json:"sodCombinedBalances"` } // GetAccounts returns the logged-in User ID, and a list of accounts // belonging to that user. -func (c *client) GetAccounts() (int, []Account, error) { +func (c *client) GetAccounts() (int, []account, error) { list := struct { UserID int `json:"userId"` - Accounts []Account `json:"accounts"` + Accounts []account `json:"accounts"` }{} err := c.get("v1/accounts", &list, url.Values{}) if err != nil { - return 0, []Account{}, err + return 0, []account{}, err } return list.UserID, list.Accounts, nil } // GetBalances returns the balances for the account with the specified account number -func (c *client) GetBalances(number string) (AccountBalances, error) { - bal := AccountBalances{} +func (c *client) GetBalances(number string) (accountBalances, error) { + bal := accountBalances{} err := c.get("v1/accounts/"+number+"/balances", &bal, url.Values{}) if err != nil { - return AccountBalances{}, err + return accountBalances{}, err } return bal, nil } diff --git a/providers/questrade/client.go b/providers/questrade/client.go index 000bca9..400383f 100644 --- a/providers/questrade/client.go +++ b/providers/questrade/client.go @@ -12,7 +12,7 @@ import ( const loginServerURL = "https://login.questrade.com/oauth2/" -type LoginCredentials struct { +type loginCredentials struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` @@ -24,7 +24,7 @@ type LoginCredentials struct { // endpoints. It holds the login credentials, http client/transport, // rate limit information, and the login session timer. type client struct { - Credentials LoginCredentials + Credentials loginCredentials SessionTimer *time.Timer RateLimitRemaining int RateLimitReset time.Time @@ -34,7 +34,7 @@ type client struct { // authHeader is a shortcut that returns a string to be placed // in the authorization header of API calls -func (l LoginCredentials) authHeader() string { +func (l loginCredentials) authHeader() string { return l.TokenType + " " + l.AccessToken } @@ -117,7 +117,7 @@ func newClient(refreshToken string) (*client, error) { // Create a new client c := &client{ - Credentials: LoginCredentials{ + Credentials: loginCredentials{ RefreshToken: refreshToken, }, httpClient: httpClient,