package main
import (
"context"
"fmt"
"os"
"time"
leadping "github.com/leadpingai/leadping-go"
auth "github.com/microsoft/kiota-abstractions-go/authentication"
kiotahttp "github.com/microsoft/kiota-http-go"
)
func main() {
credential := os.Getenv("LEADPING_API_KEY")
if credential == "" {
panic("LEADPING_API_KEY is not set")
}
authProvider, err := auth.NewApiKeyAuthenticationProviderWithValidHosts(
"Bearer "+credential,
"Authorization",
auth.HEADER_KEYLOCATION,
[]string{"api.leadping.ai"},
)
if err != nil {
panic(err)
}
adapter, err := kiotahttp.NewNetHttpRequestAdapter(authProvider)
if err != nil {
panic(err)
}
client := leadping.NewLeadpingOpenApiClient(adapter)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
lead, err := client.Leads().ById("lead-id").Get(ctx, nil)
if err != nil {
panic(err)
}
if lead == nil || lead.GetId() == nil {
panic("Leadping returned no lead ID")
}
fmt.Println(*lead.GetId())
}