summaryrefslogtreecommitdiffstats
path: root/internal/client/telegram.go
blob: 33b4ac2e841606de8e7c19d2f7a10f35d9c48d4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package client

import (
	"encoding/json"
	"fmt"
	"git.db.org.ai/dborg/internal/models"
	"strings"
)

func (c *Client) GetTelegramPhone(identifier string) (*models.TelegramPhoneResponse, error) {
	identifier = strings.TrimSpace(identifier)
	if identifier == "" {
		return nil, fmt.Errorf("identifier cannot be empty")
	}

	path := fmt.Sprintf("/telegram/phone/%s", identifier)
	data, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

	var response models.TelegramPhoneResponse
	if err := json.Unmarshal(data, &response); err != nil {
		return nil, fmt.Errorf("failed to parse telegram response: %w", err)
	}

	return &response, nil
}