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"
|
"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 (
|
var (
|
||||||
accountID string
|
accountID string
|
||||||
err error
|
err error
|
||||||
|
@ -16,12 +16,12 @@ func getAccountID(gts *client.Client, myAccount bool, accountName string) (strin
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case myAccount:
|
case myAccount:
|
||||||
accountID, err = getMyAccountID(gts)
|
accountID, err = getMyAccountID(gtsClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("unable to get your account ID; %w", err)
|
return "", fmt.Errorf("unable to get your account ID; %w", err)
|
||||||
}
|
}
|
||||||
case accountName != "":
|
case accountName != "":
|
||||||
accountID, err = getTheirAccountID(gts, accountName)
|
accountID, err = getTheirAccountID(gtsClient, accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("unable to get their account ID; %w", err)
|
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
|
return accountID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTheirAccountID(gts *client.Client, accountURI string) (string, error) {
|
func getTheirAccountID(gtsClient *client.Client, accountURI string) (string, error) {
|
||||||
account, err := getAccount(gts, accountURI)
|
account, err := getAccount(gtsClient, accountURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("unable to retrieve your account; %w", err)
|
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
|
return account.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMyAccountID(gts *client.Client) (string, error) {
|
func getMyAccountID(gtsClient *client.Client) (string, error) {
|
||||||
account, err := getMyAccount(gts)
|
account, err := getMyAccount(gtsClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("received an error while getting your account details; %w", err)
|
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
|
return account.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMyAccount(gts *client.Client) (model.Account, error) {
|
func getMyAccount(gtsClient *client.Client) (model.Account, error) {
|
||||||
authConfig, err := config.NewAuthenticationConfigFromFile()
|
authConfig, err := config.NewAuthenticationConfigFromFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.Account{}, fmt.Errorf("unable to retrieve the authentication configuration; %w", err)
|
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
|
accountURI := authConfig.CurrentAccount
|
||||||
|
|
||||||
account, err := getAccount(gts, accountURI)
|
account, err := getAccount(gtsClient, accountURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.Account{}, fmt.Errorf("unable to retrieve your account; %w", err)
|
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
|
return account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAccount(gts *client.Client, accountURI string) (model.Account, error) {
|
func getAccount(gtsClient *client.Client, accountURI string) (model.Account, error) {
|
||||||
account, err := gts.GetAccount(accountURI)
|
account, err := gtsClient.GetAccount(accountURI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.Account{}, fmt.Errorf("unable to retrieve the account details; %w", err)
|
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)
|
return doFunc(gtsClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showInstance(gts *client.Client) error {
|
func (c *showCommand) showInstance(gtsClient *client.Client) error {
|
||||||
instance, err := gts.GetInstance()
|
instance, err := gtsClient.GetInstance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the instance details; %w", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showAccount(gts *client.Client) error {
|
func (c *showCommand) showAccount(gtsClient *client.Client) error {
|
||||||
var (
|
var (
|
||||||
account model.Account
|
account model.Account
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if c.myAccount {
|
if c.myAccount {
|
||||||
account, err = getMyAccount(gts)
|
account, err = getMyAccount(gtsClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account details; %w", err)
|
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}
|
return flagNotSetError{flagText: accountNameFlag}
|
||||||
}
|
}
|
||||||
|
|
||||||
account, err = getAccount(gts, c.accountName)
|
account, err = getAccount(gtsClient, c.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account details; %w", err)
|
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)
|
fmt.Println(account)
|
||||||
|
|
||||||
if !c.myAccount && c.showAccountRelationship {
|
if !c.myAccount && c.showAccountRelationship {
|
||||||
relationship, err := gts.GetAccountRelationship(account.ID)
|
relationship, err := gtsClient.GetAccountRelationship(account.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the relationship to this account; %w", err)
|
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 {
|
if c.myAccount && c.showUserPreferences {
|
||||||
preferences, err := gts.GetUserPreferences()
|
preferences, err := gtsClient.GetUserPreferences()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the user preferences; %w", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showStatus(gts *client.Client) error {
|
func (c *showCommand) showStatus(gtsClient *client.Client) error {
|
||||||
if c.statusID == "" {
|
if c.statusID == "" {
|
||||||
return flagNotSetError{flagText: statusIDFlag}
|
return flagNotSetError{flagText: statusIDFlag}
|
||||||
}
|
}
|
||||||
|
|
||||||
status, err := gts.GetStatus(c.statusID)
|
status, err := gtsClient.GetStatus(c.statusID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the status; %w", err)
|
return fmt.Errorf("unable to retrieve the status; %w", err)
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func (c *showCommand) showStatus(gts *client.Client) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showTimeline(gts *client.Client) error {
|
func (c *showCommand) showTimeline(gtsClient *client.Client) error {
|
||||||
var (
|
var (
|
||||||
timeline model.Timeline
|
timeline model.Timeline
|
||||||
err error
|
err error
|
||||||
|
@ -152,21 +152,21 @@ func (c *showCommand) showTimeline(gts *client.Client) error {
|
||||||
|
|
||||||
switch c.timelineCategory {
|
switch c.timelineCategory {
|
||||||
case "home":
|
case "home":
|
||||||
timeline, err = gts.GetHomeTimeline(c.limit)
|
timeline, err = gtsClient.GetHomeTimeline(c.limit)
|
||||||
case "public":
|
case "public":
|
||||||
timeline, err = gts.GetPublicTimeline(c.limit)
|
timeline, err = gtsClient.GetPublicTimeline(c.limit)
|
||||||
case "list":
|
case "list":
|
||||||
if c.listID == "" {
|
if c.listID == "" {
|
||||||
return flagNotSetError{flagText: listIDFlag}
|
return flagNotSetError{flagText: listIDFlag}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeline, err = gts.GetListTimeline(c.listID, c.limit)
|
timeline, err = gtsClient.GetListTimeline(c.listID, c.limit)
|
||||||
case "tag":
|
case "tag":
|
||||||
if c.tag == "" {
|
if c.tag == "" {
|
||||||
return flagNotSetError{flagText: tagFlag}
|
return flagNotSetError{flagText: tagFlag}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeline, err = gts.GetTagTimeline(c.tag, c.limit)
|
timeline, err = gtsClient.GetTagTimeline(c.tag, c.limit)
|
||||||
default:
|
default:
|
||||||
return invalidTimelineCategoryError{category: c.timelineCategory}
|
return invalidTimelineCategoryError{category: c.timelineCategory}
|
||||||
}
|
}
|
||||||
|
@ -186,17 +186,17 @@ func (c *showCommand) showTimeline(gts *client.Client) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showList(gts *client.Client) error {
|
func (c *showCommand) showList(gtsClient *client.Client) error {
|
||||||
if c.listID == "" {
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the list; %w", err)
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the accounts from the list; %w", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showLists(gts *client.Client) error {
|
func (c *showCommand) showLists(gtsClient *client.Client) error {
|
||||||
lists, err := gts.GetAllLists()
|
lists, err := gtsClient.GetAllLists()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the lists; %w", err)
|
return fmt.Errorf("unable to retrieve the lists; %w", err)
|
||||||
}
|
}
|
||||||
|
@ -233,13 +233,13 @@ func (c *showCommand) showLists(gts *client.Client) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showFollowers(gts *client.Client) error {
|
func (c *showCommand) showFollowers(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gts, c.myAccount, c.accountName)
|
accountID, err := getAccountID(gtsClient, c.myAccount, c.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID; %w", err)
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the list of followers; %w", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showFollowing(gts *client.Client) error {
|
func (c *showCommand) showFollowing(gtsClient *client.Client) error {
|
||||||
accountID, err := getAccountID(gts, c.myAccount, c.accountName)
|
accountID, err := getAccountID(gtsClient, c.myAccount, c.accountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("received an error while getting the account ID; %w", err)
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the list of followed accounts; %w", err)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *showCommand) showBlocked(gts *client.Client) error {
|
func (c *showCommand) showBlocked(gtsClient *client.Client) error {
|
||||||
blocked, err := gts.GetBlockedAccounts(c.limit)
|
blocked, err := gtsClient.GetBlockedAccounts(c.limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to retrieve the list of blocked accounts; %w", err)
|
return fmt.Errorf("unable to retrieve the list of blocked accounts; %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue