package main
import (
"context"
"fmt"
"log"
grantex "github.com/mishrasanjeev/grantex-go"
)
func main() {
client := grantex.NewClient("gx_live_...")
ctx := context.Background()
// Check current period usage
current, err := client.Usage.Current(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Period: %s\n", current.Period)
fmt.Printf("Total requests: %d\n", current.TotalRequests)
fmt.Printf(" Authorizations: %d\n", current.Authorizations)
fmt.Printf(" Token exchanges: %d\n", current.TokenExchanges)
fmt.Printf(" Verifications: %d\n", current.Verifications)
// Get last 30 days of usage
history, err := client.Usage.History(ctx, 30)
if err != nil {
log.Fatal(err)
}
totalMonth := 0
for _, e := range history.Entries {
totalMonth += e.TotalRequests
}
fmt.Printf("\nLast 30 days: %d total requests\n", totalMonth)
}