This commit is contained in:
Artem Tsyrulnikov
2026-01-09 13:11:32 +03:00
parent 9fbb6fdbbf
commit a0b12dbcca
10 changed files with 257 additions and 119 deletions

View File

@@ -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,