refactor
This commit is contained in:
@@ -89,31 +89,19 @@ func (c *Client) do(ctx context.Context, method string, path string, in any, out
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) GetLoginURL(token string) string {
|
||||
func (c *Client) LoginURL(token string) string {
|
||||
return c.loginURL + token
|
||||
}
|
||||
|
||||
func (c *Client) CreateLoginToken(
|
||||
ctx context.Context,
|
||||
telegramID int64,
|
||||
username *string,
|
||||
) (string, error) {
|
||||
func (c *Client) CreateLoginToken(ctx context.Context, telegramID int64) (string, error) {
|
||||
req := struct {
|
||||
TelegramID int64 `json:"telegram_id"`
|
||||
Username *string `json:"username"`
|
||||
TelegramID int64 `json:"telegram_id"`
|
||||
}{
|
||||
TelegramID: telegramID,
|
||||
Username: username,
|
||||
}
|
||||
|
||||
var token string
|
||||
err := c.do(
|
||||
ctx,
|
||||
http.MethodPost,
|
||||
"api/v1/internal/auth/login-token",
|
||||
req,
|
||||
&token,
|
||||
)
|
||||
err := c.do(ctx, http.MethodPost, "api/v1/internal/auth/login-token", req, &token)
|
||||
|
||||
return token, err
|
||||
}
|
||||
@@ -313,6 +301,28 @@ func (c *Client) ForwardTelegramUpdate(
|
||||
)
|
||||
}
|
||||
|
||||
func (c *Client) SearchChannels(
|
||||
ctx context.Context,
|
||||
jwt string,
|
||||
username string,
|
||||
) ([]Channel, error) {
|
||||
path := fmt.Sprintf("api/v1/channels?username=%s", username)
|
||||
|
||||
var response struct {
|
||||
Items []Channel `json:"items"`
|
||||
}
|
||||
err := c.do(
|
||||
ctx,
|
||||
http.MethodGet,
|
||||
path,
|
||||
nil,
|
||||
&response,
|
||||
withBearer(jwt),
|
||||
)
|
||||
|
||||
return response.Items, err
|
||||
}
|
||||
|
||||
func (c *Client) AttachChannelToWorkspace(
|
||||
ctx context.Context,
|
||||
channelID string,
|
||||
|
||||
Reference in New Issue
Block a user