summaryrefslogtreecommitdiffstats
path: root/cmd/skiptrace.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/skiptrace.go')
-rw-r--r--cmd/skiptrace.go199
1 files changed, 199 insertions, 0 deletions
diff --git a/cmd/skiptrace.go b/cmd/skiptrace.go
new file mode 100644
index 0000000..68fb832
--- /dev/null
+++ b/cmd/skiptrace.go
@@ -0,0 +1,199 @@
+package cmd
+
+import (
+ "dborg/internal/client"
+ "dborg/internal/config"
+ "dborg/internal/models"
+ "encoding/json"
+ "fmt"
+ "strconv"
+
+ "github.com/spf13/cobra"
+)
+
+var skiptraceCmd = &cobra.Command{
+ Use: "skiptrace",
+ Short: "Premium skiptrace operations (requires premium API access)",
+ Long: `Search for people, phone numbers, and email addresses using premium skiptrace data.
+
+Note: All skiptrace commands require a premium API key. If you receive a 403 error,
+contact support to upgrade your account for premium access.`,
+}
+
+var skiptracePeopleCmd = &cobra.Command{
+ Use: "people",
+ Short: "Search for people by name",
+ Long: `Search for people by first name, last name, and optional location/age filters`,
+ RunE: runSkiptracePeople,
+}
+
+var skiptraceReportCmd = &cobra.Command{
+ Use: "report [sx_key] [selection]",
+ Short: "Get detailed report for selected person",
+ Long: `Retrieve detailed report for a person from previous search results using sx_key and selection number`,
+ Args: cobra.ExactArgs(2),
+ RunE: runSkiptraceReport,
+}
+
+var skiptracePhoneCmd = &cobra.Command{
+ Use: "phone [phone_number]",
+ Short: "Search for phone number",
+ Long: `Look up information about a phone number (10 digits, no +1 prefix)`,
+ Args: cobra.ExactArgs(1),
+ RunE: runSkiptracePhone,
+}
+
+var skiptraceEmailCmd = &cobra.Command{
+ Use: "email [email_address]",
+ Short: "Search for email address",
+ Long: `Look up information about an email address`,
+ Args: cobra.ExactArgs(1),
+ RunE: runSkiptraceEmail,
+}
+
+func init() {
+ rootCmd.AddCommand(skiptraceCmd)
+ skiptraceCmd.AddCommand(skiptracePeopleCmd)
+ skiptraceCmd.AddCommand(skiptraceReportCmd)
+ skiptraceCmd.AddCommand(skiptracePhoneCmd)
+ skiptraceCmd.AddCommand(skiptraceEmailCmd)
+
+ skiptracePeopleCmd.Flags().StringP("first-name", "f", "", "First name (required)")
+ skiptracePeopleCmd.Flags().StringP("last-name", "l", "", "Last name (required)")
+ skiptracePeopleCmd.Flags().StringP("city", "c", "", "City")
+ skiptracePeopleCmd.Flags().StringP("state", "s", "", "State (2-letter code)")
+ skiptracePeopleCmd.Flags().StringP("age", "a", "", "Age")
+ skiptracePeopleCmd.MarkFlagRequired("first-name")
+ skiptracePeopleCmd.MarkFlagRequired("last-name")
+}
+
+func getSkiptraceClient(cmd *cobra.Command) (*client.Client, error) {
+ apiKey, _ := cmd.Flags().GetString("api-key")
+ cfg := config.New().WithAPIKey(apiKey)
+ return client.New(cfg)
+}
+
+func runSkiptracePeople(cmd *cobra.Command, args []string) error {
+ c, err := getSkiptraceClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ params := &models.SkiptraceParams{}
+ params.FirstName, _ = cmd.Flags().GetString("first-name")
+ params.LastName, _ = cmd.Flags().GetString("last-name")
+ params.City, _ = cmd.Flags().GetString("city")
+ params.State, _ = cmd.Flags().GetString("state")
+ params.Age, _ = cmd.Flags().GetString("age")
+
+ response, err := c.SearchPeople(params)
+ if err != nil {
+ return err
+ }
+
+ if response.Data != nil && len(response.Data) > 0 {
+ output, err := json.MarshalIndent(response.Data, "", " ")
+ if err != nil {
+ return fmt.Errorf("failed to format response: %w", err)
+ }
+ fmt.Println(string(output))
+ }
+
+ return nil
+}
+
+func runSkiptraceReport(cmd *cobra.Command, args []string) error {
+ c, err := getSkiptraceClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ sxKey := args[0]
+ selection, err := strconv.Atoi(args[1])
+ if err != nil {
+ return fmt.Errorf("invalid selection number: %s", args[1])
+ }
+
+ response, err := c.GetPersonReport(sxKey, selection)
+ if err != nil {
+ return err
+ }
+
+ if response.Error != "" {
+ return fmt.Errorf("API error: %s", response.Error)
+ }
+
+ if response.Data != nil && len(response.Data) > 0 {
+ output, err := json.MarshalIndent(response.Data, "", " ")
+ if err != nil {
+ return fmt.Errorf("failed to format response: %w", err)
+ }
+ fmt.Println(string(output))
+ }
+
+ if response.Message != "" {
+ fmt.Println(response.Message)
+ }
+
+ return nil
+}
+
+func runSkiptracePhone(cmd *cobra.Command, args []string) error {
+ c, err := getSkiptraceClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ response, err := c.SearchPhone(args[0])
+ if err != nil {
+ return err
+ }
+
+ if response.Error != "" {
+ return fmt.Errorf("API error: %s", response.Error)
+ }
+
+ if response.Data != nil && len(response.Data) > 0 {
+ output, err := json.MarshalIndent(response.Data, "", " ")
+ if err != nil {
+ return fmt.Errorf("failed to format response: %w", err)
+ }
+ fmt.Println(string(output))
+ }
+
+ if response.Message != "" {
+ fmt.Println(response.Message)
+ }
+
+ return nil
+}
+
+func runSkiptraceEmail(cmd *cobra.Command, args []string) error {
+ c, err := getSkiptraceClient(cmd)
+ if err != nil {
+ return err
+ }
+
+ response, err := c.SearchEmail(args[0])
+ if err != nil {
+ return err
+ }
+
+ if response.Error != "" {
+ return fmt.Errorf("API error: %s", response.Error)
+ }
+
+ if response.Data != nil && len(response.Data) > 0 {
+ output, err := json.MarshalIndent(response.Data, "", " ")
+ if err != nil {
+ return fmt.Errorf("failed to format response: %w", err)
+ }
+ fmt.Println(string(output))
+ }
+
+ if response.Message != "" {
+ fmt.Println(response.Message)
+ }
+
+ return nil
+}