rename gts to gtsClient
This commit is contained in:
parent
6ef2aec560
commit
af24c5c561
2 changed files with 39 additions and 39 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
"codeflow.dananglin.me.uk/apollo/enbas/internal/model"
|
||||
)
|
||||
|
||||
func getAccountID(gts *client.Client, myAccount bool, accountName string) (string, error) {
|
||||
func getAccountID(gtsClient *client.Client, myAccount bool, accountName string) (string, error) {
|
||||
var (
|
||||
accountID string
|
||||
err error
|
||||
|
@ -16,12 +16,12 @@ func getAccountID(gts *client.Client, myAccount bool, accountName string) (strin
|
|||
|
||||
switch {
|
||||
case myAccount:
|
||||
accountID, err = getMyAccountID(gts)
|
||||
accountID, err = getMyAccountID(gtsClient)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to get your account ID; %w", err)
|
||||
}
|
||||
case accountName != "":
|
||||
accountID, err = getTheirAccountID(gts, accountName)
|
||||
accountID, err = getTheirAccountID(gtsClient, accountName)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to get their account ID; %w", err)
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ func getAccountID(gts *client.Client, myAccount bool, accountName string) (strin
|
|||
return accountID, nil
|
||||
}
|
||||
|
||||
func getTheirAccountID(gts *client.Client, accountURI string) (string, error) {
|
||||
account, err := getAccount(gts, accountURI)
|
||||
func getTheirAccountID(gtsClient *client.Client, accountURI string) (string, error) {
|
||||
account, err := getAccount(gtsClient, accountURI)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to retrieve your account; %w", err)
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ func getTheirAccountID(gts *client.Client, accountURI string) (string, error) {
|
|||
return account.ID, nil
|
||||
}
|
||||
|
||||
func getMyAccountID(gts *client.Client) (string, error) {
|
||||
account, err := getMyAccount(gts)
|
||||
func getMyAccountID(gtsClient *client.Client) (string, error) {
|
||||
account, err := getMyAccount(gtsClient)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("received an error while getting your account details; %w", err)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func getMyAccountID(gts *client.Client) (string, error) {
|
|||
return account.ID, nil
|
||||
}
|
||||
|
||||
func getMyAccount(gts *client.Client) (model.Account, error) {
|
||||
func getMyAccount(gtsClient *client.Client) (model.Account, error) {
|
||||
authConfig, err := config.NewAuthenticationConfigFromFile()
|
||||
if err != nil {
|
||||
return model.Account{}, fmt.Errorf("unable to retrieve the authentication configuration; %w", err)
|
||||
|
@ -58,7 +58,7 @@ func getMyAccount(gts *client.Client) (model.Account, error) {
|
|||
|
||||
accountURI := authConfig.CurrentAccount
|
||||
|
||||
account, err := getAccount(gts, accountURI)
|
||||
account, err := getAccount(gtsClient, accountURI)
|
||||
if err != nil {
|
||||
return model.Account{}, fmt.Errorf("unable to retrieve your account; %w", err)
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ func getMyAccount(gts *client.Client) (model.Account, error) {
|
|||
return account, nil
|
||||
}
|
||||
|
||||
func getAccount(gts *client.Client, accountURI string) (model.Account, error) {
|
||||
account, err := gts.GetAccount(accountURI)
|
||||
func getAccount(gtsClient *client.Client, accountURI string) (model.Account, error) {
|
||||
account, err := gtsClient.GetAccount(accountURI)
|
||||
if err != nil {
|
||||
return model.Account{}, fmt.Errorf("unable to retrieve the account details; %w", err)
|
||||
}
|
||||
|
|
|
@ -73,8 +73,8 @@ func (c *showCommand) Execute() error {
|
|||
return doFunc(gtsClient)
|
||||
}
|
||||
|
||||
func (c *showCommand) showInstance(gts *client.Client) error {
|
||||
instance, err := gts.GetInstance()
|
||||
func (c *showCommand) showInstance(gtsClient *client.Client) error {
|
||||
instance, err := gtsClient.GetInstance()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the instance details; %w", err)
|
||||
}
|
||||
|
@ -84,14 +84,14 @@ func (c *showCommand) showInstance(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showAccount(gts *client.Client) error {
|
||||
func (c *showCommand) showAccount(gtsClient *client.Client) error {
|
||||
var (
|
||||
account model.Account
|
||||
err error
|
||||
)
|
||||
|
||||
if c.myAccount {
|
||||
account, err = getMyAccount(gts)
|
||||
account, err = getMyAccount(gtsClient)
|
||||
if err != nil {
|
||||
return fmt.Errorf("received an error while getting the account details; %w", err)
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func (c *showCommand) showAccount(gts *client.Client) error {
|
|||
return flagNotSetError{flagText: accountNameFlag}
|
||||
}
|
||||
|
||||
account, err = getAccount(gts, c.accountName)
|
||||
account, err = getAccount(gtsClient, c.accountName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("received an error while getting the account details; %w", err)
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func (c *showCommand) showAccount(gts *client.Client) error {
|
|||
fmt.Println(account)
|
||||
|
||||
if !c.myAccount && c.showAccountRelationship {
|
||||
relationship, err := gts.GetAccountRelationship(account.ID)
|
||||
relationship, err := gtsClient.GetAccountRelationship(account.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the relationship to this account; %w", err)
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func (c *showCommand) showAccount(gts *client.Client) error {
|
|||
}
|
||||
|
||||
if c.myAccount && c.showUserPreferences {
|
||||
preferences, err := gts.GetUserPreferences()
|
||||
preferences, err := gtsClient.GetUserPreferences()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the user preferences; %w", err)
|
||||
}
|
||||
|
@ -129,12 +129,12 @@ func (c *showCommand) showAccount(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showStatus(gts *client.Client) error {
|
||||
func (c *showCommand) showStatus(gtsClient *client.Client) error {
|
||||
if c.statusID == "" {
|
||||
return flagNotSetError{flagText: statusIDFlag}
|
||||
}
|
||||
|
||||
status, err := gts.GetStatus(c.statusID)
|
||||
status, err := gtsClient.GetStatus(c.statusID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the status; %w", err)
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func (c *showCommand) showStatus(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showTimeline(gts *client.Client) error {
|
||||
func (c *showCommand) showTimeline(gtsClient *client.Client) error {
|
||||
var (
|
||||
timeline model.Timeline
|
||||
err error
|
||||
|
@ -152,21 +152,21 @@ func (c *showCommand) showTimeline(gts *client.Client) error {
|
|||
|
||||
switch c.timelineCategory {
|
||||
case "home":
|
||||
timeline, err = gts.GetHomeTimeline(c.limit)
|
||||
timeline, err = gtsClient.GetHomeTimeline(c.limit)
|
||||
case "public":
|
||||
timeline, err = gts.GetPublicTimeline(c.limit)
|
||||
timeline, err = gtsClient.GetPublicTimeline(c.limit)
|
||||
case "list":
|
||||
if c.listID == "" {
|
||||
return flagNotSetError{flagText: listIDFlag}
|
||||
}
|
||||
|
||||
timeline, err = gts.GetListTimeline(c.listID, c.limit)
|
||||
timeline, err = gtsClient.GetListTimeline(c.listID, c.limit)
|
||||
case "tag":
|
||||
if c.tag == "" {
|
||||
return flagNotSetError{flagText: tagFlag}
|
||||
}
|
||||
|
||||
timeline, err = gts.GetTagTimeline(c.tag, c.limit)
|
||||
timeline, err = gtsClient.GetTagTimeline(c.tag, c.limit)
|
||||
default:
|
||||
return invalidTimelineCategoryError{category: c.timelineCategory}
|
||||
}
|
||||
|
@ -186,17 +186,17 @@ func (c *showCommand) showTimeline(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showList(gts *client.Client) error {
|
||||
func (c *showCommand) showList(gtsClient *client.Client) error {
|
||||
if c.listID == "" {
|
||||
return c.showLists(gts)
|
||||
return c.showLists(gtsClient)
|
||||
}
|
||||
|
||||
list, err := gts.GetList(c.listID)
|
||||
list, err := gtsClient.GetList(c.listID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the list; %w", err)
|
||||
}
|
||||
|
||||
accounts, err := gts.GetAccountsFromList(c.listID, 0)
|
||||
accounts, err := gtsClient.GetAccountsFromList(c.listID, 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the accounts from the list; %w", err)
|
||||
}
|
||||
|
@ -215,8 +215,8 @@ func (c *showCommand) showList(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showLists(gts *client.Client) error {
|
||||
lists, err := gts.GetAllLists()
|
||||
func (c *showCommand) showLists(gtsClient *client.Client) error {
|
||||
lists, err := gtsClient.GetAllLists()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the lists; %w", err)
|
||||
}
|
||||
|
@ -233,13 +233,13 @@ func (c *showCommand) showLists(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showFollowers(gts *client.Client) error {
|
||||
accountID, err := getAccountID(gts, c.myAccount, c.accountName)
|
||||
func (c *showCommand) showFollowers(gtsClient *client.Client) error {
|
||||
accountID, err := getAccountID(gtsClient, c.myAccount, c.accountName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("received an error while getting the account ID; %w", err)
|
||||
}
|
||||
|
||||
followers, err := gts.GetFollowers(accountID, c.limit)
|
||||
followers, err := gtsClient.GetFollowers(accountID, c.limit)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the list of followers; %w", err)
|
||||
}
|
||||
|
@ -253,13 +253,13 @@ func (c *showCommand) showFollowers(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showFollowing(gts *client.Client) error {
|
||||
accountID, err := getAccountID(gts, c.myAccount, c.accountName)
|
||||
func (c *showCommand) showFollowing(gtsClient *client.Client) error {
|
||||
accountID, err := getAccountID(gtsClient, c.myAccount, c.accountName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("received an error while getting the account ID; %w", err)
|
||||
}
|
||||
|
||||
following, err := gts.GetFollowing(accountID, c.limit)
|
||||
following, err := gtsClient.GetFollowing(accountID, c.limit)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the list of followed accounts; %w", err)
|
||||
}
|
||||
|
@ -273,8 +273,8 @@ func (c *showCommand) showFollowing(gts *client.Client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *showCommand) showBlocked(gts *client.Client) error {
|
||||
blocked, err := gts.GetBlockedAccounts(c.limit)
|
||||
func (c *showCommand) showBlocked(gtsClient *client.Client) error {
|
||||
blocked, err := gtsClient.GetBlockedAccounts(c.limit)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to retrieve the list of blocked accounts; %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue