summaryrefslogtreecommitdiffstats
path: root/internal/client/x.go
blob: 7dd0b2a25a0cbb31594cd21c5237e661b03bbfd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package client

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

func (c *Client) SearchTwitterHistory(username string) (*models.XResponse, error) {
	path := fmt.Sprintf("/x/search/%s", url.PathEscape(username))
	data, err := c.Get(path, nil)
	if err != nil {
		return nil, err
	}

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

	return &response, nil
}