github.com/muxinc/mux-go@v1.1.1/examples/video/delivery-usage/exercise-delivery-usage.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "time" 7 8 "github.com/muxinc/mux-go" 9 "github.com/muxinc/mux-go/examples/common" 10 ) 11 12 func main() { 13 14 t := int32(time.Now().Unix()) 15 fmt.Println(t) 16 17 18 // API Client Initialization 19 client := muxgo.NewAPIClient( 20 muxgo.NewConfiguration( 21 muxgo.WithBasicAuth(os.Getenv("MUX_TOKEN_ID"), os.Getenv("MUX_TOKEN_SECRET")), 22 )) 23 24 // ========== list-delivery-usage ========== 25 // OK, so here's the deal. Until we have actual meaningful data flowing into an account this is 26 // really hard to to test, so instead I just create a timeframe that's valid and call the API. 27 // We've manually verified this works during development. 28 // To use specific times: 29 // p := muxgo.ListDeliveryUsageParams{Timeframe: []string{"1574175600", "1574305200"}} 30 // du, err := client.DeliveryUsageApi.ListDeliveryUsage(muxgo.WithParams(&p)) 31 // Default time window is 1 hour representing usage from 13th to 12th hour from when the request is made. 32 du, err := client.DeliveryUsageApi.ListDeliveryUsage() 33 common.AssertNoError(err) 34 common.AssertNotNil(du.Data) 35 fmt.Println("list-delivery-usage OK ✅") 36 }