Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaarbonel committed Sep 18, 2024
1 parent 7d06961 commit 923ff8b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ func main() {
userID := "your-user-id" // Replace with your server user id

// Initialize client
client, err := stream.NewStreamFromCredentials(apiKey, apiSecret)
client, err := stream.NewClient(apiKey, apiSecret)
if err != nil {
fmt.Printf("Error initializing client: %v\n", err)
return
}

// Or initialize using only environmental variables:
// (required) STREAM_API_KEY, (required) STREAM_API_SECRET
client, err = stream.NewStreamFromEnvVars()
client, err = stream.NewClientFromEnvVars()
if err != nil {
fmt.Printf("Error initializing client from env vars: %v\n", err)
return
Expand All @@ -75,25 +75,23 @@ func main() {
ctx := context.Background()

// Create a call
call := client.Video().Call("default", "unique-call-id")
call := client.Video.Call("default", "unique-call-id")

// Create or get a call
response, err := call.GetOrCreate(ctx, &stream.GetOrCreateCallRequest{
Data: &stream.CallRequest{
CreatedByID: stream.PtrTo(userID),
},
response, err := call.GetOrCreate(ctx, &stream.CallRequest{
CreatedBy: stream.UserRequest{ID: userID},
})
if err != nil {
fmt.Printf("Error creating/getting call: %v\n", err)
return
}

fmt.Printf("Call created/retrieved: %s\n", response.Data.Call.ID)
fmt.Printf("Call created/retrieved: %s\n", response.Call.ID)

// Update call settings
_, err = call.Update(ctx, &stream.UpdateCallRequest{
SettingsOverride: &stream.CallSettingsRequest{
Audio: &stream.AudioSettingsRequest{
Audio: &stream.AudioSettings{
MicDefaultOn: stream.PtrTo(true),
},
},
Expand All @@ -113,7 +111,7 @@ func main() {
fmt.Printf("Token for user %s: %s\n", userID, token)

// Query calls
callsResponse, err := client.Video().QueryCalls(ctx, &stream.QueryCallsRequest{
callsResponse, err := client.Video.QueryCalls(ctx, &stream.QueryCallsRequest{
FilterConditions: map[string]interface{}{
"created_by_user_id": userID,
},
Expand All @@ -123,7 +121,7 @@ func main() {
return
}

fmt.Printf("Found %d calls\n", len(callsResponse.Data.Calls))
fmt.Printf("Found %d calls\n", len(callsResponse.Calls))
}

// Helper function to create a pointer to a value
Expand Down

0 comments on commit 923ff8b

Please sign in to comment.