package schedule import ( "context" "fmt" "net/http" "time" "github.com/google/go-querystring/query" "go.fifitido.net/twitch/api/endpoint" ) type UpdateChannelStreamScheduleParams struct { // The ID of the broadcaster whose schedule settings you want to update. // The ID must match the user ID in the user access token. BroadcasterId string `url:"broadcaster_id"` // A Boolean value that indicates whether the broadcaster has scheduled a vacation. // Set to true to enable Vacation Mode and add vacation dates, or false to cancel a previously scheduled vacation. IsVacationEnabled *bool `url:"is_vacation_enabled,omitempty"` // The UTC date and time of when the broadcaster’s vacation starts. // Specify the date and time in RFC3339 format (for example, 2021-05-16T00:00:00Z). VacationStartTime *time.Time `url:"vacation_start_time,omitempty"` // The UTC date and time of when the broadcaster’s vacation ends. // Specify the date and time in RFC3339 format (for example, 2021-05-30T23:59:59Z). VacationEndTime *time.Time `url:"vacation_end_time,omitempty"` // The time zone that the broadcaster broadcasts from. // Specify the time zone using IANA time zone database format (for example, America/New_York). Timezone *time.Location `url:"timezone,omitempty"` } // Updates the broadcaster’s schedule settings, such as scheduling a vacation. // // Requires a user access token that includes the channel:manage:schedule scope. func (s *Schedule) UpdateChannelStreamSchedule(ctx context.Context, params *UpdateChannelStreamScheduleParams) error { v, _ := query.Values(params) req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(s.baseUrl, "schedule/settings", v), nil) if err != nil { return err } res, err := s.client.Do(req) if err != nil { return err } defer res.Body.Close() statusOK := res.StatusCode >= 200 && res.StatusCode < 300 if !statusOK { return fmt.Errorf("failed to update channel stream schedule (%d)", res.StatusCode) } return nil }