package moderation import ( "context" "encoding/json" "fmt" "net/http" "net/url" "github.com/google/go-querystring/query" ) type GetShieldModeStatusParams struct { // The ID of the broadcaster whose Shield Mode activation status you want to get. BroadcasterID string `url:"broadcaster_id"` // The ID of the broadcaster or a user that is one of the broadcaster’s moderators. This ID must match the user ID in the access token. ModeratorID string `url:"moderator_id"` } type GetShieldModeStatusResponse struct { // A list that contains a single object with the broadcaster’s Shield Mode status. Data []ShieldModeStatus `json:"data"` } // Gets the broadcaster’s Shield Mode activation status. // // To receive notification when the broadcaster activates and deactivates Shield Mode, // subscribe to the channel.shield_mode.begin and channel.shield_mode.end subscription types. // // Requires a user access token that includes the moderator:read:shield_mode or moderator:manage:shield_mode scope. func (m *Moderation) GetShieldModeStatus(ctx context.Context, params *GetShieldModeStatusParams) (*GetShieldModeStatusResponse, error) { v, _ := query.Values(params) endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/shield_mode", RawQuery: v.Encode()}) req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil) if err != nil { return nil, err } res, err := m.client.Do(req) if err != nil { return nil, err } defer res.Body.Close() statusOK := res.StatusCode >= 200 && res.StatusCode < 300 if !statusOK { return nil, fmt.Errorf("failed to get shield mode status (%d)", res.StatusCode) } var data GetShieldModeStatusResponse if err := json.NewDecoder(res.Body).Decode(&data); err != nil { return nil, err } return &data, nil }