make private if not part of provider interface
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5eea9ede3a
commit
47e460a9dc
@ -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{})
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user