From 8383a241fc3cf5b022c9c53f8f19690edf04177b Mon Sep 17 00:00:00 2001 From: s Date: Mon, 10 Nov 2025 15:22:32 -0500 Subject: refactor: restructure client modules and add config file support - Split large osint.go client into focused modules (bssid.go, breachforum.go, buckets.go, etc.) - Add config file support with init command for API key management - Remove api-key flag in favor of config file + env var fallback - Update API paths to remove /osint prefix - Add crawl endpoint streaming support - Improve error handling with 402 payment required status --- internal/client/shortlinks.go | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 internal/client/shortlinks.go (limited to 'internal/client/shortlinks.go') diff --git a/internal/client/shortlinks.go b/internal/client/shortlinks.go new file mode 100644 index 0000000..0815b73 --- /dev/null +++ b/internal/client/shortlinks.go @@ -0,0 +1,47 @@ +package client + +import ( + "encoding/json" + "fmt" + "git.db.org.ai/dborg/internal/models" + "net/url" +) + +func (c *Client) SearchShortlinks(params *models.ShortlinksSearchParams) (*models.ShortlinksSearchResponse, error) { + path := "/shortlinks" + + queryParams := url.Values{} + if params.Keywords != "" { + queryParams.Add("keywords", params.Keywords) + } + if params.Ext != "" { + queryParams.Add("ext", params.Ext) + } + if params.Order != "" { + queryParams.Add("order", params.Order) + } + if params.Direction != "" { + queryParams.Add("direction", params.Direction) + } + if params.Regexp { + queryParams.Add("regexp", "true") + } + if params.Limit > 0 { + queryParams.Add("limit", fmt.Sprintf("%d", params.Limit)) + } + if params.Start > 0 { + queryParams.Add("start", fmt.Sprintf("%d", params.Start)) + } + + data, err := c.Get(path, queryParams) + if err != nil { + return nil, err + } + + var response models.ShortlinksSearchResponse + if err := json.Unmarshal(data, &response); err != nil { + return nil, fmt.Errorf("failed to parse shortlinks search response: %w", err) + } + + return &response, nil +} -- cgit v1.2.3