go-twitch/api/schedule/update_channel_stream_sched...

54 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package schedule
import (
"context"
"net/http"
"net/url"
"time"
"github.com/google/go-querystring/query"
)
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 broadcasters 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 broadcasters 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 broadcasters 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)
endpoint := s.baseUrl.ResolveReference(&url.URL{Path: "schedule/settings", RawQuery: v.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
if err != nil {
return err
}
res, err := s.client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
return nil
}