Add http status handling to all endpoint requests

This commit is contained in:
Evan Fiordeliso 2024-03-07 19:41:05 -05:00
parent fc50a199ef
commit b11a712ecc
130 changed files with 795 additions and 32 deletions

View File

@ -3,6 +3,7 @@ package ads
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -50,9 +51,13 @@ func (e *Ads) GetAdSchedule(ctx context.Context, broadcasterID string) (*GetAdSc
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 ad schedule (%d)", res.StatusCode)
}
var data GetAdScheduleResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package ads
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -41,9 +42,13 @@ func (e *Ads) SnoozeNextAd(ctx context.Context, broadcasterID string) (*SnoozeNe
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 snooze next ad (%d)", res.StatusCode)
}
var data SnoozeNextAdResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package ads
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -63,9 +64,13 @@ func (e *Ads) StartCommercial(ctx context.Context, body *StartCommercialRequest)
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 start commercial (%d)", res.StatusCode)
}
var data StartCommercialResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package analytics
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -93,9 +94,13 @@ func (e *Analytics) GetExtensionAnalytics(ctx context.Context, params GetExtensi
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 extension analytics (%d)", res.StatusCode)
}
var data GetExtensionAnalyticsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package analytics
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -94,9 +95,13 @@ func (e *Analytics) GetGameAnalytics(ctx context.Context, params GetGameAnalytic
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 game analytics (%d)", res.StatusCode)
}
var data GetGameAnalyticsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package bits
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -81,9 +82,13 @@ func (b *Bits) GetBitsLeaderboard(ctx context.Context, params *GetBitsLeaderboar
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 bits leaderboard (%d)", res.StatusCode)
}
var data GetBitsLeaderboardResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package bits
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -93,9 +94,13 @@ func (b *Bits) GetCheermotes(ctx context.Context, broadcasterID string) (*GetChe
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 cheermotes (%d)", res.StatusCode)
}
var data GetCheermotesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package bits
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -108,9 +109,13 @@ func (b *Bits) GetExtensionTransactions(ctx context.Context, params *GetExtensio
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 extension transactions (%d)", res.StatusCode)
}
var data GetExtensionTransactionsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package ccls
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -51,6 +52,11 @@ func (c *CCLS) GetContentClassificationLabels(ctx context.Context, params GetCon
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get content classification labels (%d)", res.StatusCode)
}
var data GetContentClassificationLabelsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channelpoints
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -91,9 +92,13 @@ func (c *ChannelPoints) CreateCustomRewards(ctx context.Context, broadcastID str
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 create custom rewards (%d)", res.StatusCode)
}
var data CreateCustomRewardsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package channelpoints
import (
"context"
"fmt"
"net/http"
"net/url"
@ -35,8 +36,12 @@ func (c *ChannelPoints) DeleteCustomReward(ctx context.Context, params *DeleteCu
if err != nil {
return err
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to delete custom reward (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package channelpoints
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -48,9 +49,13 @@ func (c *ChannelPoints) GetCustomReward(ctx context.Context, params *GetCustomRe
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 custom rewards (%d)", res.StatusCode)
}
var data GetCustomRewardResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channelpoints
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -64,9 +65,13 @@ func (c *ChannelPoints) GetCustomRewardRedemption(ctx context.Context, params *G
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 custom reward redemptions (%d)", res.StatusCode)
}
var data GetCustomRewardRedemptionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channelpoints
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -103,9 +104,13 @@ func (c *ChannelPoints) UpdateCustomReward(ctx context.Context, params *UpdateCu
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 update custom reward (%d)", res.StatusCode)
}
var data UpdateCustomRewardResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channelpoints
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -63,9 +64,13 @@ func (c *ChannelPoints) UpdateRedemptionStatus(ctx context.Context, params *Upda
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 update redemption status (%d)", res.StatusCode)
}
var data UpdateRedemptionStatusResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channels
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -39,9 +40,13 @@ func (c *Channels) GetChannelEditors(ctx context.Context, broadcasterID string)
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 channel editors (%d)", res.StatusCode)
}
var data GetChannelEditorsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channels
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -82,9 +83,13 @@ func (c *Channels) GetChannelFollowers(ctx context.Context, params *GetChannelFo
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 channel followers (%d)", res.StatusCode)
}
var data GetChannelFollowersResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channels
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -81,9 +82,13 @@ func (c *Channels) GetChannelInformation(ctx context.Context, params *GetChannel
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 channel information (%d)", res.StatusCode)
}
var data GetChannelInformdationResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channels
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -76,6 +77,11 @@ func (c *Channels) GetFollowedChannels(ctx context.Context, params *GetFollowedC
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get followed channels (%d)", res.StatusCode)
}
var data GetFollowedChannelsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package channels
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -71,9 +72,16 @@ func (c *Channels) ModifyChannelInformation(ctx context.Context, broadcasterID s
return err
}
if _, err := c.client.Do(req); err != nil {
res, err := c.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 modify channel information (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package charity
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -69,6 +70,11 @@ func (c *Charity) GetCharityCampaign(ctx context.Context, broadcasterID string)
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get charity campaign (%d)", res.StatusCode)
}
var data GetCharityCampaignResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package charity
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -71,6 +72,12 @@ func (c *Charity) GetCharityCampaignDonations(ctx context.Context, params *GetCh
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 charity campaign donations (%d)", res.StatusCode)
}
var respBody GetCharityCampaignDonationsResponse
if err := json.NewDecoder(res.Body).Decode(&respBody); err != nil {

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -32,6 +33,11 @@ func (c *Chat) GetChannelChatBadges(ctx context.Context, broadcasterID string) (
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get channel chat badges (%d)", res.StatusCode)
}
var data GetChannelChatBadgesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -95,14 +96,19 @@ func (c *Chat) GetChannelEmotes(ctx context.Context, broadcasterID string) (*Get
return nil, err
}
resp, err := c.client.Do(req)
res, err := c.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get channel emotes (%d)", res.StatusCode)
}
var response GetChannelEmotesResponse
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
return nil, err
}

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -48,6 +49,11 @@ func (c *Chat) GetChatSettings(ctx context.Context, params *GetChatSettingsParam
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get chat settings (%d)", res.StatusCode)
}
var data GetChatSettingsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -69,14 +70,19 @@ func (c *Chat) GetChatters(ctx context.Context, params *GetChattersParams) (*Get
return nil, err
}
resp, err := c.client.Do(req)
res, err := c.client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get chatters (%d)", res.StatusCode)
}
var response GetChattersResponse
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
return nil, err
}

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -107,6 +108,11 @@ func (c *Chat) GetEmoteSets(ctx context.Context, params *GetEmoteSetsParams) (*G
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get emote sets (%d)", res.StatusCode)
}
var data GetEmoteSetsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -30,6 +31,11 @@ func (c *Chat) GetGlobalChatBadges(ctx context.Context) (*GetGlobalChatBadgesRes
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get global chat badges (%d)", res.StatusCode)
}
var data GetGlobalChatBadgesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -77,6 +78,11 @@ func (c *Chat) GetGlobalEmotes(ctx context.Context) (*GetGlobalEmotesResponse, e
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get global emotes (%d)", res.StatusCode)
}
var data GetGlobalEmotesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -56,6 +57,11 @@ func (c *Chat) GetUserChatColor(ctx context.Context, params *GetUserChatColorPar
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get user chat color (%d)", res.StatusCode)
}
var data GetUserChatColorResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -60,5 +61,10 @@ func (c *Chat) SendChatAnnouncement(ctx context.Context, params *SendChatAnnounc
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to send chat announcement (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -76,6 +77,11 @@ func (c *Chat) SendChatMessage(ctx context.Context, body *SendChatMessageRequest
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to send chat message (%d)", res.StatusCode)
}
var data SendChatMessageResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package chat
import (
"context"
"fmt"
"net/http"
"net/url"
@ -51,5 +52,10 @@ func (c *Chat) SendShoutout(ctx context.Context, params *SendShoutoutParams) err
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to send shoutout (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package chat
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -116,6 +117,11 @@ func (c *Chat) UpdateChatSettings(ctx context.Context, params *UpdateChatSetting
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to update chat settings (%d)", res.StatusCode)
}
var data UpdateChatSettingsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package chat
import (
"context"
"fmt"
"net/http"
"net/url"
@ -39,5 +40,10 @@ func (c *Chat) UpdateUserChatColor(ctx context.Context, params *UpdateUserChatCo
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to update user chat color (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package conduit
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -44,6 +45,11 @@ func (c *Conduit) CreateConduits(ctx context.Context, body *CreateConduitsReques
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to create conduit (%d)", res.StatusCode)
}
var data CreateConduitsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package conduit
import (
"context"
"fmt"
"net/http"
"net/url"
)
@ -24,5 +25,10 @@ func (c *Conduit) DeleteConduit(ctx context.Context, id string) error {
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to delete conduit (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package conduit
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -47,6 +48,11 @@ func (c *Conduit) GetConduitShards(ctx context.Context, params *GetConduitShards
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get conduit shards (%d)", res.StatusCode)
}
var data GetConduitShardsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package conduit
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -29,6 +30,11 @@ func (c *Conduit) GetConduits(ctx context.Context) (*GetConduitsResponse, error)
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get conduits (%d)", res.StatusCode)
}
var data GetConduitsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package conduit
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -91,6 +92,11 @@ func (c *Conduit) UpdateConduitShards(ctx context.Context, body *UpdateConduitSh
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to update conduit shards (%d)", res.StatusCode)
}
var data UpdateConduitShardsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package conduit
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -49,6 +50,11 @@ func (c *Conduit) UpdateConduits(ctx context.Context, body *UpdateConduitsReques
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to update conduit (%d)", res.StatusCode)
}
var data UpdateConduitsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package entitlements
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -101,6 +102,12 @@ func (c *Entitlements) GetDropsEntitlements(ctx context.Context, params *GetDrop
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 drops entitlements (%d)", res.StatusCode)
}
var data GetDropsEntitlementsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {

View File

@ -3,6 +3,7 @@ package entitlements
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -60,6 +61,12 @@ func (c *Entitlements) UpdateDropsEntitlements(ctx context.Context, request *Upd
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 update drops entitlements (%d)", res.StatusCode)
}
var data UpdateDropsEntitlementsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {

View File

@ -3,6 +3,7 @@ package eventsub
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -74,6 +75,11 @@ func (e *EventSub) CreateEventSubSubscription(ctx context.Context, body *CreateE
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to create EventSub subscription (%d)", res.StatusCode)
}
var data CreateEventSubSubscriptionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package eventsub
import (
"context"
"fmt"
"net/http"
"net/url"
)
@ -21,9 +22,16 @@ func (e *EventSub) DeleteEventSubSubscription(ctx context.Context, id string) er
return err
}
if _, err := e.client.Do(req); err != nil {
res, err := e.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 delete EventSub subscription (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package eventsub
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -71,6 +72,11 @@ func (e *EventSub) GetEventSubSubscriptions(ctx context.Context, params *GetEven
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get EventSub subscriptions (%d)", res.StatusCode)
}
var data GetEventSubSubscriptionsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -49,6 +50,11 @@ func (c *Extensions) CreateExtensionSecret(ctx context.Context, params *CreateEx
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to create extension secret (%d)", res.StatusCode)
}
var data CreateExtensionSecretResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -37,6 +38,11 @@ func (c *Extensions) GetExtensionBitsProducts(ctx context.Context, params *GetEx
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get extension bits products (%d)", res.StatusCode)
}
var data GetExtensionBitsProductsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -72,6 +73,11 @@ func (c *Extensions) GetExtensionConfigurationSegment(ctx context.Context, param
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get extension configuration segment (%d)", res.StatusCode)
}
var data GetExtensionConfigurationSegmentResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -64,6 +65,11 @@ func (c *Extensions) GetExtensionLiveChannels(ctx context.Context, params *GetEx
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get extension live channels (%d)", res.StatusCode)
}
var response GetExtensionLiveChannelsResponse
if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -33,6 +34,11 @@ func (c *Extensions) GetExtensionSecrets(ctx context.Context, extensionID string
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get extension secrets (%d)", res.StatusCode)
}
var data GetExtensionSecretsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -45,6 +46,11 @@ func (c *Extensions) GetExtensions(ctx context.Context, params *GetExtensionsPar
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get extensions (%d)", res.StatusCode)
}
var data GetExtensionsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -40,6 +41,11 @@ func (c *Extensions) GetReleasedExtensions(ctx context.Context, params *GetRelea
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get released extensions (%d)", res.StatusCode)
}
var data GetReleasedExtensionsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -54,5 +55,10 @@ func (c *Extensions) SendExtensionChatMessage(ctx context.Context, broadcasterID
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to send extension chat message (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -65,5 +66,10 @@ func (c *Extensions) SendExtensionPubsubMessage(ctx context.Context, body *SendE
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to send extension pubsub message (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -61,5 +62,10 @@ func (c *Extensions) SetExtensionConfigurationSegment(ctx context.Context, body
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to set extension configuration segment: %s", res.Status)
}
return nil
}

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -55,5 +56,10 @@ func (c *Extensions) SetExtensionRequiredConfiguration(ctx context.Context, broa
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to set extension required configuration (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package extensions
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -75,6 +76,11 @@ func (c *Extensions) UpdateExtensionBitsProduct(ctx context.Context, body *Updat
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to update extension bits product (%d)", res.StatusCode)
}
var data UpdateExtensionBitsProductResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package games
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -49,6 +50,11 @@ func (c *Games) GetGames(ctx context.Context, params *GetGamesParams) (*GetGames
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get games (%d)", res.StatusCode)
}
var data GetGamesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package games
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -52,6 +53,11 @@ func (c *Games) GetTopGames(ctx context.Context, params *GetTopGamesParams) (*Ge
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get top games (%d)", res.StatusCode)
}
var data GetTopGamesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package goals
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -95,6 +96,11 @@ func (c *Goals) GetCreatorGoals(ctx context.Context, broadcasterID string) (*Get
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get creator goals (%d)", res.StatusCode)
}
var data GetCreatorGoalsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
@ -47,5 +48,10 @@ func (g *GuestStar) AssignGuestStarSlot(ctx context.Context, params *AssignGuest
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to assign guest star slot (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package gueststar
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -30,6 +31,11 @@ func (g *GuestStar) CreateGuestStarSession(ctx context.Context, broadcasterID st
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to create guest star session (%d)", res.StatusCode)
}
var data CreateGuestStarSessionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
@ -42,5 +43,10 @@ func (g *GuestStar) DeleteGuestStarInvite(ctx context.Context, params *DeleteGue
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to delete guest star invite (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
@ -49,5 +50,10 @@ func (g *GuestStar) DeleteGuestStarSlot(ctx context.Context, params *DeleteGuest
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to delete guest star slot (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package gueststar
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -42,6 +43,11 @@ func (g *GuestStar) EndGuestStarSession(ctx context.Context, params *EndGuestSta
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to end guest star session (%d)", res.StatusCode)
}
var data EndGuestStarSessionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package gueststar
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -41,6 +42,11 @@ func (g *GuestStar) GetChannelGuestStarSettings(ctx context.Context, params *Get
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get channel guest star settings (%d)", res.StatusCode)
}
var data GetChannelGuestStarSettingsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package gueststar
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -45,6 +46,11 @@ func (g *GuestStar) GetGuestStarInvites(ctx context.Context, params *GetGuestSta
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get guest star invites (%d)", res.StatusCode)
}
var data GetGuestStarInvitesResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package gueststar
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -42,6 +43,11 @@ func (g *GuestStar) GetGuestStarSession(ctx context.Context, params *GetGuestSta
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get guest star session (%d)", res.StatusCode)
}
var data GetGuestStarSessionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
@ -42,5 +43,10 @@ func (g *GuestStar) SendGuestStarInvite(ctx context.Context, params *SendGuestSt
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to send guest star invite (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
)
@ -51,5 +52,10 @@ func (g *GuestStar) UpdateChannelGuestStarSettings(ctx context.Context, Broadcas
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to update channel guest star settings (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
@ -45,5 +46,10 @@ func (g *GuestStar) UpdateGuestStarSlot(ctx context.Context, params *UpdateGuest
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to update guest star slot (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package gueststar
import (
"context"
"fmt"
"net/http"
"net/url"
@ -57,5 +58,10 @@ func (g *GuestStar) UpdateGuestStarSlotSettings(ctx context.Context, params *Upd
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to update guest star slot settings (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package hypetrain
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -131,6 +132,11 @@ func (h *Hypetrain) GetHypeTrainEvents(ctx context.Context, params *GetHypeTrain
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get Hype Train events (%d)", res.StatusCode)
}
var data GetHypeTrainEventsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -65,6 +66,11 @@ func (m *Moderation) AddBlockedTerm(ctx context.Context, params *AddBlockedTermP
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to add blocked term (%d)", res.StatusCode)
}
var data AddBlockedTermResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -36,5 +37,10 @@ func (m *Moderation) AddChannelModerator(ctx context.Context, params *AddChannel
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to add channel moderator (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -36,5 +37,10 @@ func (m *Moderation) AddChannelVIP(ctx context.Context, params *AddChannelVIPPar
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to add channel VIP (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -92,6 +93,11 @@ func (m *Moderation) BanUser(ctx context.Context, params *BanUserParams, body *B
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to ban user (%d)", res.StatusCode)
}
var data BanUserResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
@ -64,6 +65,11 @@ func (c *Moderation) CheckAutoModStatus(ctx context.Context, broadcasterID strin
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to check automod status (%d)", res.StatusCode)
}
var data CheckAutoModStatusResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -46,5 +47,10 @@ func (m *Moderation) DeleteChatMessages(ctx context.Context, params *DeleteChatM
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to delete chat messages (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -42,6 +43,11 @@ func (m *Moderation) GetAutoModSettings(ctx context.Context, params *GetAutoModS
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get automod settings (%d)", res.StatusCode)
}
var data GetAutoModSettingsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@ -95,6 +96,11 @@ func (m *Moderation) GetBannedUsers(ctx context.Context, params *GetBannedUsersP
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get banned users (%d)", res.StatusCode)
}
var data GetBannedUsersResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -56,6 +57,11 @@ func (m *Moderation) GetBlockedTerms(ctx context.Context, params *GetBlockedTerm
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get blocked terms (%d)", res.StatusCode)
}
var data GetBlockedTermsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -63,6 +64,11 @@ func (m *Moderation) GetModeratedChannels(ctx context.Context, params *GetModera
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get moderated channels (%d)", res.StatusCode)
}
var data GetModeratedChannelsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -73,6 +74,11 @@ func (m *Moderation) GetModerators(ctx context.Context, params *GetModeratorsPar
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get moderators (%d)", res.StatusCode)
}
var data GetModeratorsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -43,6 +44,11 @@ func (m *Moderation) GetShieldModeStatus(ctx context.Context, params *GetShieldM
}
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

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -69,6 +70,12 @@ func (m *Moderation) GetVIPs(ctx context.Context, params GetVIPsParams) (*GetVIP
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 VIPs (%d)", res.StatusCode)
}
var data GetVIPsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
)
@ -45,5 +46,10 @@ func (m *Moderation) ManageHeldAutoModMessages(ctx context.Context, body *Manage
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to manage held AutoMod messages (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -38,5 +39,10 @@ func (m *Moderation) RemoveBlockedTerm(ctx context.Context, params *RemoveBlocke
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to remove blocked term (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -36,5 +37,10 @@ func (m *Moderation) RemoveChannelModerator(ctx context.Context, params *RemoveC
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to remove channel moderator (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -39,5 +40,10 @@ func (m *Moderation) RemoveChannelVIP(ctx context.Context, params *RemoveChannel
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to remove channel VIP (%d)", res.StatusCode)
}
return nil
}

View File

@ -2,6 +2,7 @@ package moderation
import (
"context"
"fmt"
"net/http"
"net/url"
@ -40,5 +41,10 @@ func (m *Moderation) UnbanUser(ctx context.Context, params *UnbanUserParams) err
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to unban user (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -101,6 +102,11 @@ func (m *Moderation) UpdateAutoModSettings(ctx context.Context, params *UpdateAu
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to update automod settings (%d)", res.StatusCode)
}
var data UpdateAutoModSettingsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package moderation
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -60,6 +61,11 @@ func (m *Moderation) UpdateShieldModeStatus(ctx context.Context, params *UpdateS
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to update shield mode status (%d)", res.StatusCode)
}
var data UpdateShieldModeStatusResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package polls
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
@ -71,6 +72,11 @@ func (p *Polls) CreatePoll(ctx context.Context, body *CreatePollRequest) (*Creat
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to create poll (%d)", res.StatusCode)
}
var data CreatePollResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -2,6 +2,7 @@ package polls
import (
"context"
"fmt"
"net/http"
"net/url"
@ -42,5 +43,10 @@ func (p *Polls) EndPoll(ctx context.Context, params *EndPollParams) error {
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to end poll (%d)", res.StatusCode)
}
return nil
}

View File

@ -3,6 +3,7 @@ package polls
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -62,6 +63,11 @@ func (p *Polls) GetPolls(ctx context.Context, params *GetPollsParams) (*GetPolls
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get polls (%d)", res.StatusCode)
}
var data GetPollsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package predictions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -54,6 +55,11 @@ func (c *Predictions) CreatePrediction(ctx context.Context, params *CreatePredic
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to create prediction (%d)", res.StatusCode)
}
var data CreatePredictionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package predictions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -57,6 +58,11 @@ func (c *Predictions) EndPrediction(ctx context.Context, params *EndPredictionRe
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to end prediction (%d)", res.StatusCode)
}
var data EndPredictionResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package predictions
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
@ -60,6 +61,11 @@ func (c *Predictions) GetPredictions(ctx context.Context, params *GetPredictions
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return nil, fmt.Errorf("failed to get predictions (%d)", res.StatusCode)
}
var data GetPredictionsResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err

Some files were not shown because too many files have changed in this diff Show More