fix: Create endpoint make utility to build endpoints
This commit is contained in:
parent
858c3c5adc
commit
fce339d8c5
|
@ -7,6 +7,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetAdScheduleResponse struct {
|
type GetAdScheduleResponse struct {
|
||||||
|
@ -39,15 +41,15 @@ type GetAdScheduleData struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:read:ads scope.
|
// Requires a user access token that includes the channel:read:ads scope.
|
||||||
// The user_id in the user access token must match the broadcaster_id.
|
// The user_id in the user access token must match the broadcaster_id.
|
||||||
func (e *Ads) GetAdSchedule(ctx context.Context, broadcasterID string) (*GetAdScheduleResponse, error) {
|
func (a *Ads) GetAdSchedule(ctx context.Context, broadcasterID string) (*GetAdScheduleResponse, error) {
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "channels/ads", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(a.baseUrl, "channels/ads", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := e.client.Do(req)
|
res, err := a.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnoozeNextAdResponse struct {
|
type SnoozeNextAdResponse struct {
|
||||||
|
@ -31,9 +33,9 @@ type SnoozeNextAdData struct {
|
||||||
// Requires a user access token that includes the channel:manage:ads scope.
|
// Requires a user access token that includes the channel:manage:ads scope.
|
||||||
// The user_id in the user access token must match the broadcaster_id.
|
// The user_id in the user access token must match the broadcaster_id.
|
||||||
func (e *Ads) SnoozeNextAd(ctx context.Context, broadcasterID string) (*SnoozeNextAdResponse, error) {
|
func (e *Ads) SnoozeNextAd(ctx context.Context, broadcasterID string) (*SnoozeNextAdResponse, error) {
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "channels/ads/schedule/snooze", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequest(http.MethodPost, endpoint.Make(e.baseUrl, "channels/ads/schedule/snooze", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StartCommercialRequest struct {
|
type StartCommercialRequest struct {
|
||||||
|
@ -42,8 +43,7 @@ type StartCommercialData struct {
|
||||||
// NOTE: Only the broadcaster may start a commercial; the broadcaster’s editors and moderators may not start commercials on behalf of the broadcaster.
|
// NOTE: Only the broadcaster may start a commercial; the broadcaster’s editors and moderators may not start commercials on behalf of the broadcaster.
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:edit:commercial scope.
|
// Requires a user access token that includes the channel:edit:commercial scope.
|
||||||
func (e *Ads) StartCommercial(ctx context.Context, body *StartCommercialRequest) (*StartCommercialResponse, error) {
|
func (a *Ads) StartCommercial(ctx context.Context, body *StartCommercialRequest) (*StartCommercialResponse, error) {
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "channels/commercial"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ func (e *Ads) StartCommercial(ctx context.Context, body *StartCommercialRequest)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(a.baseUrl, "channels/commercial"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := e.client.Do(req)
|
res, err := a.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -81,16 +81,15 @@ type ExtensionAnalyticsReport struct {
|
||||||
// Learn More: https://dev.twitch.tv/docs/insights
|
// Learn More: https://dev.twitch.tv/docs/insights
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the analytics:read:extensions scope.
|
// Requires a user access token that includes the analytics:read:extensions scope.
|
||||||
func (e *Analytics) GetExtensionAnalytics(ctx context.Context, params GetExtensionAnalyticsParams) (*GetExtensionAnalyticsResponse, error) {
|
func (a *Analytics) GetExtensionAnalytics(ctx context.Context, params GetExtensionAnalyticsParams) (*GetExtensionAnalyticsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "analytics/extensions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequest(http.MethodGet, endpoint.Make(a.baseUrl, "analytics/extensions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := e.client.Do(req)
|
res, err := a.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -82,16 +82,15 @@ type GameAnalyticsReport struct {
|
||||||
// Learn more: https://dev.twitch.tv/docs/insights
|
// Learn more: https://dev.twitch.tv/docs/insights
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the analytics:read:games scope.
|
// Requires a user access token that includes the analytics:read:games scope.
|
||||||
func (e *Analytics) GetGameAnalytics(ctx context.Context, params GetGameAnalyticsParams) (*GetGameAnalyticsResponse, error) {
|
func (a *Analytics) GetGameAnalytics(ctx context.Context, params GetGameAnalyticsParams) (*GetGameAnalyticsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "analytics/games", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(a.baseUrl, "analytics/games", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := e.client.Do(req)
|
res, err := a.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -71,9 +71,8 @@ type LeaderboardEntry struct {
|
||||||
// Requires a user access token that includes the bits:read scope.
|
// Requires a user access token that includes the bits:read scope.
|
||||||
func (b *Bits) GetBitsLeaderboard(ctx context.Context, params *GetBitsLeaderboardParams) (*GetBitsLeaderboardResponse, error) {
|
func (b *Bits) GetBitsLeaderboard(ctx context.Context, params *GetBitsLeaderboardParams) (*GetBitsLeaderboardResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := b.baseUrl.ResolveReference(&url.URL{Path: "bits/leaderboard", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(b.baseUrl, "bits/leaderboard", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetCheermotesResponse struct {
|
type GetCheermotesResponse struct {
|
||||||
|
@ -83,9 +85,9 @@ type CheermoteImageSizes struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (b *Bits) GetCheermotes(ctx context.Context, broadcasterID string) (*GetCheermotesResponse, error) {
|
func (b *Bits) GetCheermotes(ctx context.Context, broadcasterID string) (*GetCheermotesResponse, error) {
|
||||||
endpoint := b.baseUrl.ResolveReference(&url.URL{Path: "bits/cheermotes", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(b.baseUrl, "bits/cheermotes", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -98,9 +98,8 @@ type ProductDataCost struct {
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (b *Bits) GetExtensionTransactions(ctx context.Context, params *GetExtensionTransactionsParams) (*GetExtensionTransactionsResponse, error) {
|
func (b *Bits) GetExtensionTransactions(ctx context.Context, params *GetExtensionTransactionsParams) (*GetExtensionTransactionsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := b.baseUrl.ResolveReference(&url.URL{Path: "extensions/transactions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(b.baseUrl, "extensions/transactions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,9 +39,8 @@ type ContentClassificationLabelData struct {
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *CCLS) GetContentClassificationLabels(ctx context.Context, params GetContentClassificationLabelsParams) (*GetContentClassificationLabelsResponse, error) {
|
func (c *CCLS) GetContentClassificationLabels(ctx context.Context, params GetContentClassificationLabelsParams) (*GetContentClassificationLabelsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "content_classification_labels", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "content_classification_labels", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateCustomRewardsRequest struct {
|
type CreateCustomRewardsRequest struct {
|
||||||
|
@ -71,7 +73,7 @@ type CreateCustomRewardsResponse struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:manage:redemptions scope.
|
// Requires a user access token that includes the channel:manage:redemptions scope.
|
||||||
func (c *ChannelPoints) CreateCustomRewards(ctx context.Context, broadcastID string, body *CreateCustomRewardsRequest) (*CreateCustomRewardsResponse, error) {
|
func (c *ChannelPoints) CreateCustomRewards(ctx context.Context, broadcastID string, body *CreateCustomRewardsRequest) (*CreateCustomRewardsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards", RawQuery: "broadcaster_id=" + broadcastID})
|
v := url.Values{"broadcaster_id": {broadcastID}}
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ func (c *ChannelPoints) CreateCustomRewards(ctx context.Context, broadcastID str
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(c.baseUrl, "channel_points/custom_rewards", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteCustomRewardParams struct {
|
type DeleteCustomRewardParams struct {
|
||||||
|
@ -25,9 +25,8 @@ type DeleteCustomRewardParams struct {
|
||||||
// Requires a user access token that includes the channel:manage:redemptions scope.
|
// Requires a user access token that includes the channel:manage:redemptions scope.
|
||||||
func (c *ChannelPoints) DeleteCustomReward(ctx context.Context, params *DeleteCustomRewardParams) error {
|
func (c *ChannelPoints) DeleteCustomReward(ctx context.Context, params *DeleteCustomRewardParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(c.baseUrl, "channel_points/custom_rewards", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetCustomRewardParams struct {
|
type GetCustomRewardParams struct {
|
||||||
|
@ -38,9 +38,8 @@ type GetCustomRewardResponse struct {
|
||||||
// Requires a user access token that includes the channel:read:redemptions or channel:manage:redemptions scope.
|
// Requires a user access token that includes the channel:read:redemptions or channel:manage:redemptions scope.
|
||||||
func (c *ChannelPoints) GetCustomReward(ctx context.Context, params *GetCustomRewardParams) (*GetCustomRewardResponse, error) {
|
func (c *ChannelPoints) GetCustomReward(ctx context.Context, params *GetCustomRewardParams) (*GetCustomRewardResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "channel_points/custom_rewards", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -54,9 +54,8 @@ type GetCustomRewardRedemptionResponse struct {
|
||||||
// Requires a user access token that includes the channel:read:redemptions or channel:manage:redemptions scope.
|
// Requires a user access token that includes the channel:read:redemptions or channel:manage:redemptions scope.
|
||||||
func (c *ChannelPoints) GetCustomRewardRedemption(ctx context.Context, params *GetCustomRewardRedemptionParams) (*GetCustomRewardRedemptionResponse, error) {
|
func (c *ChannelPoints) GetCustomRewardRedemption(ctx context.Context, params *GetCustomRewardRedemptionParams) (*GetCustomRewardRedemptionResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards/redemptions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "channel_points/custom_rewards/redemptions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateCustomRewardParams struct {
|
type UpdateCustomRewardParams struct {
|
||||||
|
@ -83,7 +83,6 @@ type UpdateCustomRewardResponse struct {
|
||||||
// Requires a user access token that includes the channel:manage:redemptions scope.
|
// Requires a user access token that includes the channel:manage:redemptions scope.
|
||||||
func (c *ChannelPoints) UpdateCustomReward(ctx context.Context, params *UpdateCustomRewardParams, body *UpdateCustomRewardRequest) (*UpdateCustomRewardResponse, error) {
|
func (c *ChannelPoints) UpdateCustomReward(ctx context.Context, params *UpdateCustomRewardParams, body *UpdateCustomRewardRequest) (*UpdateCustomRewardResponse, error) {
|
||||||
v, _ := query.Values(body)
|
v, _ := query.Values(body)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -95,7 +94,7 @@ func (c *ChannelPoints) UpdateCustomReward(ctx context.Context, params *UpdateCu
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(c.baseUrl, "channel_points/custom_rewards", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateRedemptionStatusParams struct {
|
type UpdateRedemptionStatusParams struct {
|
||||||
|
@ -43,7 +43,6 @@ type UpdateRedemptionStatusResponse struct {
|
||||||
// Requires a user access token that includes the channel:manage:redemptions scope.
|
// Requires a user access token that includes the channel:manage:redemptions scope.
|
||||||
func (c *ChannelPoints) UpdateRedemptionStatus(ctx context.Context, params *UpdateRedemptionStatusParams, body *UpdateRedemptionStatusRequest) (*UpdateRedemptionStatusResponse, error) {
|
func (c *ChannelPoints) UpdateRedemptionStatus(ctx context.Context, params *UpdateRedemptionStatusParams, body *UpdateRedemptionStatusRequest) (*UpdateRedemptionStatusResponse, error) {
|
||||||
v, _ := query.Values(body)
|
v, _ := query.Values(body)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channel_points/custom_rewards/redemptions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ func (c *ChannelPoints) UpdateRedemptionStatus(ctx context.Context, params *Upda
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(c.baseUrl, "channel_points/custom_rewards/redemptions", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetChannelEditorsResponse struct {
|
type GetChannelEditorsResponse struct {
|
||||||
|
@ -29,9 +31,9 @@ type ChannelEditor struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:read:editors scope.
|
// Requires a user access token that includes the channel:read:editors scope.
|
||||||
func (c *Channels) GetChannelEditors(ctx context.Context, broadcasterID string) (*GetChannelEditorsResponse, error) {
|
func (c *Channels) GetChannelEditors(ctx context.Context, broadcasterID string) (*GetChannelEditorsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channels/editors", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "channels/editors", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,9 +72,8 @@ type ChannelFollower struct {
|
||||||
// only the total follower count will be included in the response.
|
// only the total follower count will be included in the response.
|
||||||
func (c *Channels) GetChannelFollowers(ctx context.Context, params *GetChannelFollowersParams) (*GetChannelFollowersResponse, error) {
|
func (c *Channels) GetChannelFollowers(ctx context.Context, params *GetChannelFollowersParams) (*GetChannelFollowersResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channels/followers", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "channels/followers", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"go.fifitido.net/twitch/api/ccls"
|
"go.fifitido.net/twitch/api/ccls"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetChannelInformationParams struct {
|
type GetChannelInformationParams struct {
|
||||||
|
@ -71,9 +71,8 @@ type ChannelInformation struct {
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Channels) GetChannelInformation(ctx context.Context, params *GetChannelInformationParams) (*GetChannelInformdationResponse, error) {
|
func (c *Channels) GetChannelInformation(ctx context.Context, params *GetChannelInformationParams) (*GetChannelInformdationResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channels", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "channels", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,9 +63,8 @@ type FollowedChannel struct {
|
||||||
// Requires a user access token that includes the user:read:follows scope.
|
// Requires a user access token that includes the user:read:follows scope.
|
||||||
func (c *Channels) GetFollowedChannels(ctx context.Context, params *GetFollowedChannelsParams) (*GetFollowedChannelsResponse, error) {
|
func (c *Channels) GetFollowedChannels(ctx context.Context, params *GetFollowedChannelsParams) (*GetFollowedChannelsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "users/follows", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "users/follows", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"go.fifitido.net/twitch/api/ccls"
|
"go.fifitido.net/twitch/api/ccls"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModifyChannelInformationRequest struct {
|
type ModifyChannelInformationRequest struct {
|
||||||
|
@ -55,7 +56,7 @@ type ModifyContentClassificationLabel struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:manage:broadcast scope.
|
// Requires a user access token that includes the channel:manage:broadcast scope.
|
||||||
func (c *Channels) ModifyChannelInformation(ctx context.Context, broadcasterID string, body *ModifyChannelInformationRequest) error {
|
func (c *Channels) ModifyChannelInformation(ctx context.Context, broadcasterID string, body *ModifyChannelInformationRequest) error {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "channels", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ func (c *Channels) ModifyChannelInformation(ctx context.Context, broadcasterID s
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(c.baseUrl, "channels", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,9 +57,9 @@ type CharityCampaign struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:read:charity scope.
|
// Requires a user access token that includes the channel:read:charity scope.
|
||||||
func (c *Charity) GetCharityCampaign(ctx context.Context, broadcasterID string) (*GetCharityCampaignResponse, error) {
|
func (c *Charity) GetCharityCampaign(ctx context.Context, broadcasterID string) (*GetCharityCampaignResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "charity/campaigns", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "charity/campaigns", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,9 +61,8 @@ type CharityCampaignDonation struct {
|
||||||
// Requires a user access token that includes the channel:read:charity scope.
|
// Requires a user access token that includes the channel:read:charity scope.
|
||||||
func (c *Charity) GetCharityCampaignDonations(ctx context.Context, params *GetCharityCampaignDonationsParams) (*GetCharityCampaignDonationsResponse, error) {
|
func (c *Charity) GetCharityCampaignDonations(ctx context.Context, params *GetCharityCampaignDonationsParams) (*GetCharityCampaignDonationsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "charity/campaigns/donations", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "charity/campaigns/donations", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetChannelChatBadgesResponse struct {
|
type GetChannelChatBadgesResponse struct {
|
||||||
|
@ -20,9 +22,9 @@ type GetChannelChatBadgesResponse struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetChannelChatBadges(ctx context.Context, broadcasterID string) (*GetChannelChatBadgesResponse, error) {
|
func (c *Chat) GetChannelChatBadges(ctx context.Context, broadcasterID string) (*GetChannelChatBadgesResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/badges", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/badges", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetChannelEmotesResponse struct {
|
type GetChannelEmotesResponse struct {
|
||||||
|
@ -89,9 +91,9 @@ type ChannelEmote struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetChannelEmotes(ctx context.Context, broadcasterID string) (*GetChannelEmotesResponse, error) {
|
func (c *Chat) GetChannelEmotes(ctx context.Context, broadcasterID string) (*GetChannelEmotesResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/emotes", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/emotes", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetChatSettingsParams struct {
|
type GetChatSettingsParams struct {
|
||||||
|
@ -36,9 +36,8 @@ type GetChatSettingsResponse struct {
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetChatSettings(ctx context.Context, params *GetChatSettingsParams) (*GetChatSettingsResponse, error) {
|
func (c *Chat) GetChatSettings(ctx context.Context, params *GetChatSettingsParams) (*GetChatSettingsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/settings", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/settings", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -63,9 +63,8 @@ type Chatter struct {
|
||||||
// Requires a user access token that includes the moderator:read:chatters scope.
|
// Requires a user access token that includes the moderator:read:chatters scope.
|
||||||
func (c *Chat) GetChatters(ctx context.Context, params *GetChattersParams) (*GetChattersResponse, error) {
|
func (c *Chat) GetChatters(ctx context.Context, params *GetChattersParams) (*GetChattersResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/chatters", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/chatters", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetEmoteSetsParams struct {
|
type GetEmoteSetsParams struct {
|
||||||
|
@ -95,9 +95,8 @@ type EmoteSetEmote struct {
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetEmoteSets(ctx context.Context, params *GetEmoteSetsParams) (*GetEmoteSetsResponse, error) {
|
func (c *Chat) GetEmoteSets(ctx context.Context, params *GetEmoteSetsParams) (*GetEmoteSetsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/emotes/set", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/emotes/set", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetGlobalChatBadgesResponse struct {
|
type GetGlobalChatBadgesResponse struct {
|
||||||
|
@ -18,9 +19,7 @@ type GetGlobalChatBadgesResponse struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetGlobalChatBadges(ctx context.Context) (*GetGlobalChatBadgesResponse, error) {
|
func (c *Chat) GetGlobalChatBadges(ctx context.Context) (*GetGlobalChatBadgesResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/badges/global"})
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/badges/global"), nil)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetGlobalEmotesResponse struct {
|
type GetGlobalEmotesResponse struct {
|
||||||
|
@ -65,9 +66,7 @@ type GlobalEmote struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetGlobalEmotes(ctx context.Context) (*GetGlobalEmotesResponse, error) {
|
func (c *Chat) GetGlobalEmotes(ctx context.Context) (*GetGlobalEmotesResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/emotes/global"})
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/emotes/global"), nil)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetUserChatColorParams struct {
|
type GetUserChatColorParams struct {
|
||||||
|
@ -44,9 +44,8 @@ type UserChatColor struct {
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Chat) GetUserChatColor(ctx context.Context, params *GetUserChatColorParams) (*GetUserChatColorResponse, error) {
|
func (c *Chat) GetUserChatColor(ctx context.Context, params *GetUserChatColorParams) (*GetUserChatColorResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/color", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "chat/color", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ type SendChatAnnouncementRequest struct {
|
||||||
// Requires a user access token that includes the moderator:manage:announcements scope.
|
// Requires a user access token that includes the moderator:manage:announcements scope.
|
||||||
func (c *Chat) SendChatAnnouncement(ctx context.Context, params *SendChatAnnouncementParams, body *SendChatAnnouncementRequest) error {
|
func (c *Chat) SendChatAnnouncement(ctx context.Context, params *SendChatAnnouncementParams, body *SendChatAnnouncementRequest) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/announcements", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ func (c *Chat) SendChatAnnouncement(ctx context.Context, params *SendChatAnnounc
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(c.baseUrl, "chat/announcements", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendChatMessageRequest struct {
|
type SendChatMessageRequest struct {
|
||||||
|
@ -54,8 +55,6 @@ type DropReason struct {
|
||||||
// If app access token used, then additionally requires user:bot scope from chatting user,
|
// If app access token used, then additionally requires user:bot scope from chatting user,
|
||||||
// and either channel:bot scope from broadcaster or moderator status.
|
// and either channel:bot scope from broadcaster or moderator status.
|
||||||
func (c *Chat) SendChatMessage(ctx context.Context, body *SendChatMessageRequest) (*SendChatMessageResponse, error) {
|
func (c *Chat) SendChatMessage(ctx context.Context, body *SendChatMessageRequest) (*SendChatMessageResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/messages"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -66,7 +65,7 @@ func (c *Chat) SendChatMessage(ctx context.Context, body *SendChatMessageRequest
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(c.baseUrl, "chat/messages"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendShoutoutParams struct {
|
type SendShoutoutParams struct {
|
||||||
|
@ -39,9 +39,8 @@ type SendShoutoutParams struct {
|
||||||
// Requires a user access token that includes the moderator:manage:shoutouts scope.
|
// Requires a user access token that includes the moderator:manage:shoutouts scope.
|
||||||
func (c *Chat) SendShoutout(ctx context.Context, params *SendShoutoutParams) error {
|
func (c *Chat) SendShoutout(ctx context.Context, params *SendShoutoutParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/shoutouts", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(c.baseUrl, "chat/shoutouts", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateChatSettingsParams struct {
|
type UpdateChatSettingsParams struct {
|
||||||
|
@ -94,7 +94,6 @@ type UpdateChatSettingsResponse struct {
|
||||||
// Requires a user access token that includes the moderator:manage:chat_settings scope.
|
// Requires a user access token that includes the moderator:manage:chat_settings scope.
|
||||||
func (c *Chat) UpdateChatSettings(ctx context.Context, params *UpdateChatSettingsParams, body *UpdateChatSettingsRequest) (*UpdateChatSettingsResponse, error) {
|
func (c *Chat) UpdateChatSettings(ctx context.Context, params *UpdateChatSettingsParams, body *UpdateChatSettingsRequest) (*UpdateChatSettingsResponse, error) {
|
||||||
v, _ := query.Values(body)
|
v, _ := query.Values(body)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/settings", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -106,7 +105,7 @@ func (c *Chat) UpdateChatSettings(ctx context.Context, params *UpdateChatSetting
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(c.baseUrl, "chat/settings", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateUserChatColorParams struct {
|
type UpdateUserChatColorParams struct {
|
||||||
|
@ -27,9 +27,8 @@ type UpdateUserChatColorParams struct {
|
||||||
// Requires a user access token that includes the user:manage:chat_color scope.
|
// Requires a user access token that includes the user:manage:chat_color scope.
|
||||||
func (c *Chat) UpdateUserChatColor(ctx context.Context, params *UpdateUserChatColorParams) error {
|
func (c *Chat) UpdateUserChatColor(ctx context.Context, params *UpdateUserChatColorParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "chat/color", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.Make(c.baseUrl, "chat/color", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateConduitsRequest struct {
|
type CreateConduitsRequest struct {
|
||||||
|
@ -22,8 +23,6 @@ type CreateConduitsResponse struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (c *Conduit) CreateConduits(ctx context.Context, body *CreateConduitsRequest) (*CreateConduitsResponse, error) {
|
func (c *Conduit) CreateConduits(ctx context.Context, body *CreateConduitsRequest) (*CreateConduitsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -34,7 +33,7 @@ func (c *Conduit) CreateConduits(ctx context.Context, body *CreateConduitsReques
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(c.baseUrl, "eventsub/conduits"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deletes a specified conduit.
|
// Deletes a specified conduit.
|
||||||
|
@ -12,9 +14,9 @@ import (
|
||||||
//
|
//
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (c *Conduit) DeleteConduit(ctx context.Context, id string) error {
|
func (c *Conduit) DeleteConduit(ctx context.Context, id string) error {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits", RawQuery: "id=" + id})
|
v := url.Values{"id": {id}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(c.baseUrl, "eventsub/conduits", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,9 +35,8 @@ type GetConduitShardsResponse struct {
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (c *Conduit) GetConduitShards(ctx context.Context, params *GetConduitShardsParams) (*GetConduitShardsResponse, error) {
|
func (c *Conduit) GetConduitShards(ctx context.Context, params *GetConduitShardsParams) (*GetConduitShardsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits/shards", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "eventsub/conduits/shards", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetConduitsResponse struct {
|
type GetConduitsResponse struct {
|
||||||
|
@ -17,9 +18,7 @@ type GetConduitsResponse struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (c *Conduit) GetConduits(ctx context.Context) (*GetConduitsResponse, error) {
|
func (c *Conduit) GetConduits(ctx context.Context) (*GetConduitsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits"})
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(c.baseUrl, "eventsub/conduits"), nil)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/eventsub"
|
"go.fifitido.net/twitch/api/eventsub"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -69,8 +69,6 @@ type UpdateConduitShardsError struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (c *Conduit) UpdateConduitShards(ctx context.Context, body *UpdateConduitShardsRequest) (*UpdateConduitShardsResponse, error) {
|
func (c *Conduit) UpdateConduitShards(ctx context.Context, body *UpdateConduitShardsRequest) (*UpdateConduitShardsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits/shards"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -81,7 +79,7 @@ func (c *Conduit) UpdateConduitShards(ctx context.Context, body *UpdateConduitSh
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(c.baseUrl, "eventsub/conduits/shards"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateConduitsRequest struct {
|
type UpdateConduitsRequest struct {
|
||||||
|
@ -27,8 +28,6 @@ type UpdateConduitsResponse struct {
|
||||||
//
|
//
|
||||||
// Requires an app access token.
|
// Requires an app access token.
|
||||||
func (c *Conduit) UpdateConduits(ctx context.Context, body *UpdateConduitsRequest) (*UpdateConduitsResponse, error) {
|
func (c *Conduit) UpdateConduits(ctx context.Context, body *UpdateConduitsRequest) (*UpdateConduitsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "eventsub/conduits"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -39,7 +38,7 @@ func (c *Conduit) UpdateConduits(ctx context.Context, body *UpdateConduitsReques
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(c.baseUrl, "eventsub/conduits"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package endpoint
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Make(baseUrl *url.URL, path string, vals ...url.Values) string {
|
||||||
|
var sb strings.Builder
|
||||||
|
sb.WriteString(baseUrl.String())
|
||||||
|
sb.WriteString("/")
|
||||||
|
sb.WriteString(path)
|
||||||
|
if len(vals) > 0 {
|
||||||
|
sb.WriteString("?")
|
||||||
|
sb.WriteString(vals[0].Encode())
|
||||||
|
}
|
||||||
|
return sb.String()
|
||||||
|
|
||||||
|
}
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -89,16 +89,15 @@ type Entitlement struct {
|
||||||
// User | game_id | The request returns all entitlements that the specified game granted to the user identified in the access token.
|
// User | game_id | The request returns all entitlements that the specified game granted to the user identified in the access token.
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token. The client ID in the access token must own the game.
|
// Requires an app access token or user access token. The client ID in the access token must own the game.
|
||||||
func (c *Entitlements) GetDropsEntitlements(ctx context.Context, params *GetDropsEntitlementsParams) (*GetDropsEntitlementsResponse, error) {
|
func (e *Entitlements) GetDropsEntitlements(ctx context.Context, params *GetDropsEntitlementsParams) (*GetDropsEntitlementsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "entitlements/drops", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "entitlements/drops", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateDropsEntitlementsRequest struct {
|
type UpdateDropsEntitlementsRequest struct {
|
||||||
|
@ -39,9 +40,7 @@ type UpdateDropsEntitlementsData struct {
|
||||||
// User | Updates all entitlements owned by the user in the access token and where the benefits are owned by the organization in the access token.
|
// User | Updates all entitlements owned by the user in the access token and where the benefits are owned by the organization in the access token.
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token. The client ID in the access token must own the game.
|
// Requires an app access token or user access token. The client ID in the access token must own the game.
|
||||||
func (c *Entitlements) UpdateDropsEntitlements(ctx context.Context, request *UpdateDropsEntitlementsRequest) (*UpdateDropsEntitlementsResponse, error) {
|
func (e *Entitlements) UpdateDropsEntitlements(ctx context.Context, request *UpdateDropsEntitlementsRequest) (*UpdateDropsEntitlementsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "entitlements/drops"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -52,12 +51,12 @@ func (c *Entitlements) UpdateDropsEntitlements(ctx context.Context, request *Upd
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(e.baseUrl, "entitlements/drops"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateEventSubSubscriptionRequest struct {
|
type CreateEventSubSubscriptionRequest struct {
|
||||||
|
@ -51,7 +52,6 @@ type CreateEventSubSubscriptionResponse struct {
|
||||||
// If you use Conduits to receive events, the request must specify an app access token.
|
// If you use Conduits to receive events, the request must specify an app access token.
|
||||||
// The request will fail if you use a user access token.
|
// The request will fail if you use a user access token.
|
||||||
func (e *EventSub) CreateEventSubSubscription(ctx context.Context, body *CreateEventSubSubscriptionRequest) (*CreateEventSubSubscriptionResponse, error) {
|
func (e *EventSub) CreateEventSubSubscription(ctx context.Context, body *CreateEventSubSubscriptionRequest) (*CreateEventSubSubscriptionResponse, error) {
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "eventsub/subscriptions"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func (e *EventSub) CreateEventSubSubscription(ctx context.Context, body *CreateE
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(e.baseUrl, "eventsub/subscriptions"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deletes an EventSub subscription.
|
// Deletes an EventSub subscription.
|
||||||
|
@ -15,9 +17,9 @@ import (
|
||||||
// If you use WebSockets to receive events, the request must specify a user access token.
|
// If you use WebSockets to receive events, the request must specify a user access token.
|
||||||
// The request will fail if you use an app access token. The token may include any scopes.
|
// The request will fail if you use an app access token. The token may include any scopes.
|
||||||
func (e *EventSub) DeleteEventSubSubscription(ctx context.Context, id string) error {
|
func (e *EventSub) DeleteEventSubSubscription(ctx context.Context, id string) error {
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "eventsub/subscriptions", RawQuery: "id=" + id})
|
v := url.Values{"id": {id}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(e.baseUrl, "eventsub/subscriptions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,9 +58,8 @@ type GetEventSubSubscriptionsResponse struct {
|
||||||
// The request will fail if you use an app access token. The token may include any scopes.
|
// The request will fail if you use an app access token. The token may include any scopes.
|
||||||
func (e *EventSub) GetEventSubSubscriptions(ctx context.Context, params *GetEventSubSubscriptionsParams) (*GetEventSubSubscriptionsResponse, error) {
|
func (e *EventSub) GetEventSubSubscriptions(ctx context.Context, params *GetEventSubSubscriptionsParams) (*GetEventSubSubscriptionsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "eventsub/subscriptions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "eventsub/subscriptions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateExtensionSecretParams struct {
|
type CreateExtensionSecretParams struct {
|
||||||
|
@ -35,16 +35,15 @@ type CreateExtensionSecretResponse struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// The role field must be set to external.
|
// The role field must be set to external.
|
||||||
func (c *Extensions) CreateExtensionSecret(ctx context.Context, params *CreateExtensionSecretParams) (*CreateExtensionSecretResponse, error) {
|
func (e *Extensions) CreateExtensionSecret(ctx context.Context, params *CreateExtensionSecretParams) (*CreateExtensionSecretResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/jwt/secrets", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(e.baseUrl, "extensions/jwt/secrets", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetExtensionBitsProductsParams struct {
|
type GetExtensionBitsProductsParams struct {
|
||||||
|
@ -23,16 +23,15 @@ type GetExtensionBitsProductsResponse struct {
|
||||||
// Gets the list of Bits products that belongs to the extension. The client ID in the app access token identifies the extension.
|
// Gets the list of Bits products that belongs to the extension. The client ID in the app access token identifies the extension.
|
||||||
//
|
//
|
||||||
// Requires an app access token. The client ID in the app access token must be the extension’s client ID.
|
// Requires an app access token. The client ID in the app access token must be the extension’s client ID.
|
||||||
func (c *Extensions) GetExtensionBitsProducts(ctx context.Context, params *GetExtensionBitsProductsParams) (*GetExtensionBitsProductsResponse, error) {
|
func (e *Extensions) GetExtensionBitsProducts(ctx context.Context, params *GetExtensionBitsProductsParams) (*GetExtensionBitsProductsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "bits/extensions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "bits/extensions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetExtensionConfigurationSegmentParams struct {
|
type GetExtensionConfigurationSegmentParams struct {
|
||||||
|
@ -58,16 +58,15 @@ type ConfigurationSegmentData struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// The role field must be set to external.
|
// The role field must be set to external.
|
||||||
func (c *Extensions) GetExtensionConfigurationSegment(ctx context.Context, params *GetExtensionConfigurationSegmentParams) (*GetExtensionConfigurationSegmentResponse, error) {
|
func (e *Extensions) GetExtensionConfigurationSegment(ctx context.Context, params *GetExtensionConfigurationSegmentParams) (*GetExtensionConfigurationSegmentResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/configurations", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "extensions/configurations", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,16 +50,15 @@ type ExtensionLiveChannel struct {
|
||||||
// It may take a few minutes for the list to include or remove broadcasters that have recently gone live or stopped broadcasting.
|
// It may take a few minutes for the list to include or remove broadcasters that have recently gone live or stopped broadcasting.
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Extensions) GetExtensionLiveChannels(ctx context.Context, params *GetExtensionLiveChannelsParams) (*GetExtensionLiveChannelsResponse, error) {
|
func (e *Extensions) GetExtensionLiveChannels(ctx context.Context, params *GetExtensionLiveChannelsParams) (*GetExtensionLiveChannelsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/live", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "extensions/live", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetExtensionSecretsResponse struct {
|
type GetExtensionSecretsResponse struct {
|
||||||
|
@ -20,15 +22,15 @@ type GetExtensionSecretsResponse struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// The role field must be set to external.
|
// The role field must be set to external.
|
||||||
func (c *Extensions) GetExtensionSecrets(ctx context.Context, extensionID string) (*GetExtensionSecretsResponse, error) {
|
func (e *Extensions) GetExtensionSecrets(ctx context.Context, extensionID string) (*GetExtensionSecretsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/jwt/secrets", RawQuery: "extension_id=" + extensionID})
|
v := url.Values{"extension_id": {extensionID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "extensions/jwt/secrets", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetExtensionsParams struct {
|
type GetExtensionsParams struct {
|
||||||
|
@ -31,16 +31,15 @@ type GetExtensionsResponse struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// The role field must be set to external.
|
// The role field must be set to external.
|
||||||
func (c *Extensions) GetExtensions(ctx context.Context, params *GetExtensionsParams) (*GetExtensionsResponse, error) {
|
func (e *Extensions) GetExtensions(ctx context.Context, params *GetExtensionsParams) (*GetExtensionsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "extensions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetReleasedExtensionsParams struct {
|
type GetReleasedExtensionsParams struct {
|
||||||
|
@ -26,16 +26,15 @@ type GetReleasedExtensionsResponse struct {
|
||||||
// Gets information about a released extension. Returns the extension if its state is Released.
|
// Gets information about a released extension. Returns the extension if its state is Released.
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Extensions) GetReleasedExtensions(ctx context.Context, params *GetReleasedExtensionsParams) (*GetReleasedExtensionsResponse, error) {
|
func (e *Extensions) GetReleasedExtensions(ctx context.Context, params *GetReleasedExtensionsParams) (*GetReleasedExtensionsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/released", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(e.baseUrl, "extensions/released", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendExtensionChatMessageRequest struct {
|
type SendExtensionChatMessageRequest struct {
|
||||||
|
@ -31,8 +33,8 @@ type SendExtensionChatMessageRequest struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// The role field must be set to external.
|
// The role field must be set to external.
|
||||||
func (c *Extensions) SendExtensionChatMessage(ctx context.Context, broadcasterID string, body *SendExtensionChatMessageRequest) error {
|
func (e *Extensions) SendExtensionChatMessage(ctx context.Context, broadcasterID string, body *SendExtensionChatMessageRequest) error {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/chat", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -44,12 +46,12 @@ func (c *Extensions) SendExtensionChatMessage(ctx context.Context, broadcasterID
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(e.baseUrl, "extensions/chat", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendExtensionPubsubMessageRequest struct {
|
type SendExtensionPubsubMessageRequest struct {
|
||||||
|
@ -42,9 +43,7 @@ type SendExtensionPubsubMessageRequest struct {
|
||||||
// To send the message to a specific channel, set the channel_id field in the JWT to the channel’s ID and set the pubsub_perms.send array to broadcast.
|
// To send the message to a specific channel, set the channel_id field in the JWT to the channel’s ID and set the pubsub_perms.send array to broadcast.
|
||||||
//
|
//
|
||||||
// To send the message to all channels on which your extension is active, set the channel_id field to all and set the pubsub_perms.send array to global.
|
// To send the message to all channels on which your extension is active, set the channel_id field to all and set the pubsub_perms.send array to global.
|
||||||
func (c *Extensions) SendExtensionPubsubMessage(ctx context.Context, body *SendExtensionPubsubMessageRequest) error {
|
func (e *Extensions) SendExtensionPubsubMessage(ctx context.Context, body *SendExtensionPubsubMessageRequest) error {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/pubsub"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -55,12 +54,12 @@ func (c *Extensions) SendExtensionPubsubMessage(ctx context.Context, body *SendE
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(e.baseUrl, "extensions/pubsub"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SetExtensionConfigurationSegmentRequest struct {
|
type SetExtensionConfigurationSegmentRequest struct {
|
||||||
|
@ -38,8 +39,7 @@ type SetExtensionConfigurationSegmentRequest struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// The role field must be set to external.
|
// The role field must be set to external.
|
||||||
func (c *Extensions) SetExtensionConfigurationSegment(ctx context.Context, body *SetExtensionConfigurationSegmentRequest) error {
|
func (e *Extensions) SetExtensionConfigurationSegment(ctx context.Context, body *SetExtensionConfigurationSegmentRequest) error {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/configurations"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ func (c *Extensions) SetExtensionConfigurationSegment(ctx context.Context, body
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.Make(e.baseUrl, "extensions/configurations"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SetExtensionRequiredConfigurationRequest struct {
|
type SetExtensionRequiredConfigurationRequest struct {
|
||||||
|
@ -32,8 +34,8 @@ type SetExtensionRequiredConfigurationRequest struct {
|
||||||
// The signed JWT must include the role, user_id, and exp fields
|
// The signed JWT must include the role, user_id, and exp fields
|
||||||
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
// (see JWT Schema: https://dev.twitch.tv/docs/extensions/reference/#jwt-schema).
|
||||||
// Set the role field to external and the user_id field to the ID of the user that owns the extension.
|
// Set the role field to external and the user_id field to the ID of the user that owns the extension.
|
||||||
func (c *Extensions) SetExtensionRequiredConfiguration(ctx context.Context, broadcasterID string, body *SetExtensionRequiredConfigurationRequest) error {
|
func (e *Extensions) SetExtensionRequiredConfiguration(ctx context.Context, broadcasterID string, body *SetExtensionRequiredConfigurationRequest) error {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "extensions/required_configuration", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -45,12 +47,12 @@ func (c *Extensions) SetExtensionRequiredConfiguration(ctx context.Context, broa
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.Make(e.baseUrl, "extensions/required_configuration", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateExtensionBitsProductRequest struct {
|
type UpdateExtensionBitsProductRequest struct {
|
||||||
|
@ -52,9 +53,7 @@ type UpdateExtensionBitsProductResponse struct {
|
||||||
// If the SKU doesn’t exist, the product is added. You may update all fields except the sku field.
|
// If the SKU doesn’t exist, the product is added. You may update all fields except the sku field.
|
||||||
//
|
//
|
||||||
// Requires an app access token. The client ID in the app access token must match the extension’s client ID.
|
// Requires an app access token. The client ID in the app access token must match the extension’s client ID.
|
||||||
func (c *Extensions) UpdateExtensionBitsProduct(ctx context.Context, body *UpdateExtensionBitsProductRequest) (*UpdateExtensionBitsProductResponse, error) {
|
func (e *Extensions) UpdateExtensionBitsProduct(ctx context.Context, body *UpdateExtensionBitsProductRequest) (*UpdateExtensionBitsProductResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "bits/extensions"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -65,12 +64,12 @@ func (c *Extensions) UpdateExtensionBitsProduct(ctx context.Context, body *Updat
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.Make(e.baseUrl, "bits/extensions"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := e.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetGamesParams struct {
|
type GetGamesParams struct {
|
||||||
|
@ -35,16 +35,15 @@ type GetGamesResponse struct {
|
||||||
// You may get up to 100 categories or games by specifying their ID or name. You may specify all IDs, all names, or a combination of IDs and names. If you specify a combination of IDs and names, the total number of IDs and names must not exceed 100.
|
// You may get up to 100 categories or games by specifying their ID or name. You may specify all IDs, all names, or a combination of IDs and names. If you specify a combination of IDs and names, the total number of IDs and names must not exceed 100.
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Games) GetGames(ctx context.Context, params *GetGamesParams) (*GetGamesResponse, error) {
|
func (g *Games) GetGames(ctx context.Context, params *GetGamesParams) (*GetGamesResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "games", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(g.baseUrl, "games", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := g.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,16 +38,15 @@ type GetTopGamesResponse struct {
|
||||||
// Gets information about all broadcasts on Twitch.
|
// Gets information about all broadcasts on Twitch.
|
||||||
//
|
//
|
||||||
// Requires an app access token or user access token.
|
// Requires an app access token or user access token.
|
||||||
func (c *Games) GetTopGames(ctx context.Context, params *GetTopGamesParams) (*GetTopGamesResponse, error) {
|
func (g *Games) GetTopGames(ctx context.Context, params *GetTopGamesParams) (*GetTopGamesResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "games/top", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(g.baseUrl, "games/top", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := g.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetCreatorGoalsResponse struct {
|
type GetCreatorGoalsResponse struct {
|
||||||
|
@ -82,15 +84,15 @@ type Goal struct {
|
||||||
// using the channel.goal.progress subscription type. Read More: https://dev.twitch.tv/docs/api/goals#requesting-event-notifications
|
// using the channel.goal.progress subscription type. Read More: https://dev.twitch.tv/docs/api/goals#requesting-event-notifications
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:read:goals scope.
|
// Requires a user access token that includes the channel:read:goals scope.
|
||||||
func (c *Goals) GetCreatorGoals(ctx context.Context, broadcasterID string) (*GetCreatorGoalsResponse, error) {
|
func (g *Goals) GetCreatorGoals(ctx context.Context, broadcasterID string) (*GetCreatorGoalsResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "goals", RawQuery: "broadcaster_id=" + broadcasterID})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(g.baseUrl, "goals", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := g.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AssignGuestStarSlot struct {
|
type AssignGuestStarSlot struct {
|
||||||
|
@ -35,9 +35,8 @@ type AssignGuestStarSlot struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) AssignGuestStarSlot(ctx context.Context, params *AssignGuestStarSlot) error {
|
func (g *GuestStar) AssignGuestStarSlot(ctx context.Context, params *AssignGuestStarSlot) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/slot", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(g.baseUrl, "guest_star/slot", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreateGuestStarSessionResponse struct {
|
type CreateGuestStarSessionResponse struct {
|
||||||
|
@ -18,9 +20,9 @@ type CreateGuestStarSessionResponse struct {
|
||||||
// Query parameter broadcaster_id must match the user_id in the User-Access token
|
// Query parameter broadcaster_id must match the user_id in the User-Access token
|
||||||
// Requires OAuth Scope: channel:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star
|
||||||
func (g *GuestStar) CreateGuestStarSession(ctx context.Context, broadcasterID string) (*CreateGuestStarSessionResponse, error) {
|
func (g *GuestStar) CreateGuestStarSession(ctx context.Context, broadcasterID string) (*CreateGuestStarSessionResponse, error) {
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/session", RawQuery: url.Values{"broadcaster_id": {broadcasterID}}.Encode()})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(g.baseUrl, "guest_star/session", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteGuestStarInviteParams struct {
|
type DeleteGuestStarInviteParams struct {
|
||||||
|
@ -30,9 +30,8 @@ type DeleteGuestStarInviteParams struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) DeleteGuestStarInvite(ctx context.Context, params *DeleteGuestStarInviteParams) error {
|
func (g *GuestStar) DeleteGuestStarInvite(ctx context.Context, params *DeleteGuestStarInviteParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/invite", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(g.baseUrl, "guest_star/invite", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteGuestStarSlotParams struct {
|
type DeleteGuestStarSlotParams struct {
|
||||||
|
@ -37,9 +37,8 @@ type DeleteGuestStarSlotParams struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) DeleteGuestStarSlot(ctx context.Context, params *DeleteGuestStarSlotParams) error {
|
func (g *GuestStar) DeleteGuestStarSlot(ctx context.Context, params *DeleteGuestStarSlotParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/slot", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(g.baseUrl, "guest_star/slot", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EndGuestStarSession struct {
|
type EndGuestStarSession struct {
|
||||||
|
@ -30,9 +30,8 @@ type EndGuestStarSessionResponse struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star
|
||||||
func (g *GuestStar) EndGuestStarSession(ctx context.Context, params *EndGuestStarSession) (*EndGuestStarSessionResponse, error) {
|
func (g *GuestStar) EndGuestStarSession(ctx context.Context, params *EndGuestStarSession) (*EndGuestStarSessionResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/session", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(g.baseUrl, "guest_star/session", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetChannelGuestStarSettingsParams struct {
|
type GetChannelGuestStarSettingsParams struct {
|
||||||
|
@ -29,9 +29,8 @@ type GetChannelGuestStarSettingsResponse struct {
|
||||||
// Requires OAuth Scope: channel:read:guest_star, channel:manage:guest_star, moderator:read:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:read:guest_star, channel:manage:guest_star, moderator:read:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) GetChannelGuestStarSettings(ctx context.Context, params *GetChannelGuestStarSettingsParams) (*GetChannelGuestStarSettingsResponse, error) {
|
func (g *GuestStar) GetChannelGuestStarSettings(ctx context.Context, params *GetChannelGuestStarSettingsParams) (*GetChannelGuestStarSettingsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/channel_settings", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(g.baseUrl, "guest_star/channel_settings", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetGuestStarInvitesParams struct {
|
type GetGuestStarInvitesParams struct {
|
||||||
|
@ -33,9 +33,8 @@ type GetGuestStarInvitesResponse struct {
|
||||||
// Requires OAuth Scope: channel:read:guest_star, channel:manage:guest_star, moderator:read:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:read:guest_star, channel:manage:guest_star, moderator:read:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) GetGuestStarInvites(ctx context.Context, params *GetGuestStarInvitesParams) (*GetGuestStarInvitesResponse, error) {
|
func (g *GuestStar) GetGuestStarInvites(ctx context.Context, params *GetGuestStarInvitesParams) (*GetGuestStarInvitesResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/invites", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(g.baseUrl, "guest_star/invites", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetGuestStarSessionParams struct {
|
type GetGuestStarSessionParams struct {
|
||||||
|
@ -30,9 +30,8 @@ type GetGuestStarSessionResponse struct {
|
||||||
// Guests must be either invited or assigned a slot within the session
|
// Guests must be either invited or assigned a slot within the session
|
||||||
func (g *GuestStar) GetGuestStarSession(ctx context.Context, params *GetGuestStarSessionParams) (*GetGuestStarSessionResponse, error) {
|
func (g *GuestStar) GetGuestStarSession(ctx context.Context, params *GetGuestStarSessionParams) (*GetGuestStarSessionResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/session", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(g.baseUrl, "guest_star/session", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SendGuestStarInviteParams struct {
|
type SendGuestStarInviteParams struct {
|
||||||
|
@ -30,9 +30,8 @@ type SendGuestStarInviteParams struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) SendGuestStarInvite(ctx context.Context, params *SendGuestStarInviteParams) error {
|
func (g *GuestStar) SendGuestStarInvite(ctx context.Context, params *SendGuestStarInviteParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/invite", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(g.baseUrl, "guest_star/invite", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateChannelGuestStarSettingsRequest struct {
|
type UpdateChannelGuestStarSettingsRequest struct {
|
||||||
|
@ -39,9 +41,9 @@ type UpdateChannelGuestStarSettingsRequest struct {
|
||||||
// Query parameter broadcaster_id must match the user_id in the User-Access token
|
// Query parameter broadcaster_id must match the user_id in the User-Access token
|
||||||
// Requires OAuth Scope: channel:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star
|
||||||
func (g *GuestStar) UpdateChannelGuestStarSettings(ctx context.Context, BroadcasterID string, body *UpdateChannelGuestStarSettingsRequest) error {
|
func (g *GuestStar) UpdateChannelGuestStarSettings(ctx context.Context, BroadcasterID string, body *UpdateChannelGuestStarSettingsRequest) error {
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/channel_settings", RawQuery: url.Values{"broadcaster_id": {BroadcasterID}}.Encode()})
|
v := url.Values{"broadcaster_id": {BroadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.Make(g.baseUrl, "guest_star/channel_settings", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateGuestStarSlot struct {
|
type UpdateGuestStarSlot struct {
|
||||||
|
@ -33,9 +33,8 @@ type UpdateGuestStarSlot struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) UpdateGuestStarSlot(ctx context.Context, params *UpdateGuestStarSlot) error {
|
func (g *GuestStar) UpdateGuestStarSlot(ctx context.Context, params *UpdateGuestStarSlot) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/slot", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(g.baseUrl, "guest_star/slot", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateGuestStarSlotSettingsParams struct {
|
type UpdateGuestStarSlotSettingsParams struct {
|
||||||
|
@ -45,9 +45,8 @@ type UpdateGuestStarSlotSettingsParams struct {
|
||||||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||||||
func (g *GuestStar) UpdateGuestStarSlotSettings(ctx context.Context, params *UpdateGuestStarSlotSettingsParams) error {
|
func (g *GuestStar) UpdateGuestStarSlotSettings(ctx context.Context, params *UpdateGuestStarSlotSettingsParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/slot_settings", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(g.baseUrl, "guest_star/slot_settings", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -119,9 +119,8 @@ type GetHypeTrainEventsResponse struct {
|
||||||
// Requires a user access token that includes the channel:read:hype_train scope.
|
// Requires a user access token that includes the channel:read:hype_train scope.
|
||||||
func (h *Hypetrain) GetHypeTrainEvents(ctx context.Context, params *GetHypeTrainEventsParams) (*GetHypeTrainEventsResponse, error) {
|
func (h *Hypetrain) GetHypeTrainEvents(ctx context.Context, params *GetHypeTrainEventsParams) (*GetHypeTrainEventsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := h.baseUrl.ResolveReference(&url.URL{Path: "hypetrain/events", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(h.baseUrl, "hypetrain/events", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddBlockedTermParams struct {
|
type AddBlockedTermParams struct {
|
||||||
|
@ -43,7 +43,6 @@ type AddBlockedTermResponse struct {
|
||||||
// Requires a user access token that includes the moderator:manage:blocked_terms scope.
|
// Requires a user access token that includes the moderator:manage:blocked_terms scope.
|
||||||
func (m *Moderation) AddBlockedTerm(ctx context.Context, params *AddBlockedTermParams, body *AddBlockedTermRequest) (*AddBlockedTermResponse, error) {
|
func (m *Moderation) AddBlockedTerm(ctx context.Context, params *AddBlockedTermParams, body *AddBlockedTermRequest) (*AddBlockedTermResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/blocked_terms", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ func (m *Moderation) AddBlockedTerm(ctx context.Context, params *AddBlockedTermP
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(m.baseUrl, "moderation/blocked_terms", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddChannelModeratorParams struct {
|
type AddChannelModeratorParams struct {
|
||||||
|
@ -24,9 +24,8 @@ type AddChannelModeratorParams struct {
|
||||||
// Requires a user access token that includes the channel:manage:moderators scope.
|
// Requires a user access token that includes the channel:manage:moderators scope.
|
||||||
func (m *Moderation) AddChannelModerator(ctx context.Context, params *AddChannelModeratorParams) error {
|
func (m *Moderation) AddChannelModerator(ctx context.Context, params *AddChannelModeratorParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/moderators", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(m.baseUrl, "moderation/moderators", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddChannelVIPParams struct {
|
type AddChannelVIPParams struct {
|
||||||
|
@ -24,9 +24,8 @@ type AddChannelVIPParams struct {
|
||||||
// Requires a user access token that includes the channel:manage:vips scope.
|
// Requires a user access token that includes the channel:manage:vips scope.
|
||||||
func (m *Moderation) AddChannelVIP(ctx context.Context, params *AddChannelVIPParams) error {
|
func (m *Moderation) AddChannelVIP(ctx context.Context, params *AddChannelVIPParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "channels/vips", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(m.baseUrl, "channels/vips", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BanUserParams struct {
|
type BanUserParams struct {
|
||||||
|
@ -70,7 +70,6 @@ type BanUserResponseData struct {
|
||||||
// Requires a user access token that includes the moderator:manage:banned_users scope.
|
// Requires a user access token that includes the moderator:manage:banned_users scope.
|
||||||
func (m *Moderation) BanUser(ctx context.Context, params *BanUserParams, body *BanUserRequest) (*BanUserResponse, error) {
|
func (m *Moderation) BanUser(ctx context.Context, params *BanUserParams, body *BanUserRequest) (*BanUserResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/bans", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ func (m *Moderation) BanUser(ctx context.Context, params *BanUserParams, body *B
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(m.baseUrl, "moderation/bans", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CheckAutoModStatusRequest struct {
|
type CheckAutoModStatusRequest struct {
|
||||||
|
@ -51,15 +53,15 @@ type CheckAutoModStatusResponseData struct {
|
||||||
// The rate limit headers in the response represent the Twitch rate limits and not the above limits.
|
// The rate limit headers in the response represent the Twitch rate limits and not the above limits.
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the moderation:read scope.
|
// Requires a user access token that includes the moderation:read scope.
|
||||||
func (c *Moderation) CheckAutoModStatus(ctx context.Context, broadcasterID string, params *CheckAutoModStatusRequest) (*CheckAutoModStatusResponse, error) {
|
func (m *Moderation) CheckAutoModStatus(ctx context.Context, broadcasterID string, params *CheckAutoModStatusRequest) (*CheckAutoModStatusResponse, error) {
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "modetation/enforcements/status", RawQuery: url.Values{"broadcaster_id": {broadcasterID}}.Encode()})
|
v := url.Values{"broadcaster_id": {broadcasterID}}
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(m.baseUrl, "moderation/enforcements/status", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := m.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeleteChatMessagesParams struct {
|
type DeleteChatMessagesParams struct {
|
||||||
|
@ -34,9 +34,8 @@ type DeleteChatMessagesParams struct {
|
||||||
// Requires a user access token that includes the moderator:manage:chat_messages scope.
|
// Requires a user access token that includes the moderator:manage:chat_messages scope.
|
||||||
func (m *Moderation) DeleteChatMessages(ctx context.Context, params *DeleteChatMessagesParams) error {
|
func (m *Moderation) DeleteChatMessages(ctx context.Context, params *DeleteChatMessagesParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/chat", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "moderation/chat", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetAutoModSettingsParams struct {
|
type GetAutoModSettingsParams struct {
|
||||||
|
@ -30,9 +30,8 @@ type GetAutoModSettingsResponse struct {
|
||||||
// Requires a user access token that includes the moderator:read:automod_settings scope.
|
// Requires a user access token that includes the moderator:read:automod_settings scope.
|
||||||
func (m *Moderation) GetAutoModSettings(ctx context.Context, params *GetAutoModSettingsParams) (*GetAutoModSettingsResponse, error) {
|
func (m *Moderation) GetAutoModSettings(ctx context.Context, params *GetAutoModSettingsParams) (*GetAutoModSettingsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/automod/settings", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/automod/settings", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,9 +83,8 @@ type GetBannedUsersResponseData struct {
|
||||||
// Requires a user access token that includes the moderation:read or moderator:manage:banned_users scope.
|
// Requires a user access token that includes the moderation:read or moderator:manage:banned_users scope.
|
||||||
func (m *Moderation) GetBannedUsers(ctx context.Context, params *GetBannedUsersParams) (*GetBannedUsersResponse, error) {
|
func (m *Moderation) GetBannedUsers(ctx context.Context, params *GetBannedUsersParams) (*GetBannedUsersResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/banned", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/banned", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,9 +44,8 @@ type GetBlockedTermsResponse struct {
|
||||||
// Requires a user access token that includes the moderator:read:blocked_terms or moderator:manage:blocked_terms scope.
|
// Requires a user access token that includes the moderator:read:blocked_terms or moderator:manage:blocked_terms scope.
|
||||||
func (m *Moderation) GetBlockedTerms(ctx context.Context, params *GetBlockedTermsParams) (*GetBlockedTermsResponse, error) {
|
func (m *Moderation) GetBlockedTerms(ctx context.Context, params *GetBlockedTermsParams) (*GetBlockedTermsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/blocked_terms", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/blocked_terms", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -51,9 +51,8 @@ type GetModeratedChannelsResponseData struct {
|
||||||
// Requires OAuth Scope: user:read:moderated_channels
|
// Requires OAuth Scope: user:read:moderated_channels
|
||||||
func (m *Moderation) GetModeratedChannels(ctx context.Context, params *GetModeratedChannelsParams) (*GetModeratedChannelsResponse, error) {
|
func (m *Moderation) GetModeratedChannels(ctx context.Context, params *GetModeratedChannelsParams) (*GetModeratedChannelsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/channels", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/channels", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,9 +61,8 @@ type GetModeratorsResponseData struct {
|
||||||
// If your app also adds and removes moderators, you can use the channel:manage:moderators scope instead.
|
// If your app also adds and removes moderators, you can use the channel:manage:moderators scope instead.
|
||||||
func (m *Moderation) GetModerators(ctx context.Context, params *GetModeratorsParams) (*GetModeratorsResponse, error) {
|
func (m *Moderation) GetModerators(ctx context.Context, params *GetModeratorsParams) (*GetModeratorsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/moderators", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/moderators", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetShieldModeStatusParams struct {
|
type GetShieldModeStatusParams struct {
|
||||||
|
@ -31,9 +31,8 @@ type GetShieldModeStatusResponse struct {
|
||||||
// Requires a user access token that includes the moderator:read:shield_mode or moderator:manage:shield_mode scope.
|
// 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) {
|
func (m *Moderation) GetShieldModeStatus(ctx context.Context, params *GetShieldModeStatusParams) (*GetShieldModeStatusResponse, error) {
|
||||||
v, _ := query.Values(params)
|
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)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/shield_mode", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -59,9 +59,8 @@ type GetVIPsResponseData struct {
|
||||||
// If your app also adds and removes VIP status, you can use the channel:manage:vips scope instead.
|
// If your app also adds and removes VIP status, you can use the channel:manage:vips scope instead.
|
||||||
func (m *Moderation) GetVIPs(ctx context.Context, params GetVIPsParams) (*GetVIPsResponse, error) {
|
func (m *Moderation) GetVIPs(ctx context.Context, params GetVIPsParams) (*GetVIPsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/vips", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(m.baseUrl, "moderation/vips", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AutoModAction string
|
type AutoModAction string
|
||||||
|
@ -33,9 +34,8 @@ type ManageHeldAutoModMessagesRequest struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the moderator:manage:automod scope.
|
// Requires a user access token that includes the moderator:manage:automod scope.
|
||||||
func (m *Moderation) ManageHeldAutoModMessages(ctx context.Context, body *ManageHeldAutoModMessagesRequest) error {
|
func (m *Moderation) ManageHeldAutoModMessages(ctx context.Context, body *ManageHeldAutoModMessagesRequest) error {
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/automod/message"})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(m.baseUrl, "moderation/automod/message"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RemoveBlockedTermParams struct {
|
type RemoveBlockedTermParams struct {
|
||||||
|
@ -26,9 +26,8 @@ type RemoveBlockedTermParams struct {
|
||||||
// Requires a user access token that includes the moderator:manage:blocked_terms scope.
|
// Requires a user access token that includes the moderator:manage:blocked_terms scope.
|
||||||
func (m *Moderation) RemoveBlockedTerm(ctx context.Context, params *RemoveBlockedTermParams) error {
|
func (m *Moderation) RemoveBlockedTerm(ctx context.Context, params *RemoveBlockedTermParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/blocks", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "moderation/blocks", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RemoveChannelModeratorParams struct {
|
type RemoveChannelModeratorParams struct {
|
||||||
|
@ -24,9 +24,8 @@ type RemoveChannelModeratorParams struct {
|
||||||
// Requires a user access token that includes the channel:manage:moderators scope.
|
// Requires a user access token that includes the channel:manage:moderators scope.
|
||||||
func (m *Moderation) RemoveChannelModerator(ctx context.Context, params *RemoveChannelModeratorParams) error {
|
func (m *Moderation) RemoveChannelModerator(ctx context.Context, params *RemoveChannelModeratorParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/moderators", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "moderation/moderators", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RemoveChannelVIPParams struct {
|
type RemoveChannelVIPParams struct {
|
||||||
|
@ -27,9 +27,8 @@ type RemoveChannelVIPParams struct {
|
||||||
// Requires a user access token that includes the channel:manage:vips scope.
|
// Requires a user access token that includes the channel:manage:vips scope.
|
||||||
func (m *Moderation) RemoveChannelVIP(ctx context.Context, params *RemoveChannelVIPParams) error {
|
func (m *Moderation) RemoveChannelVIP(ctx context.Context, params *RemoveChannelVIPParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "channels/vips", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "channels/vips", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UnbanUserParams struct {
|
type UnbanUserParams struct {
|
||||||
|
@ -28,9 +28,8 @@ type UnbanUserParams struct {
|
||||||
// Requires a user access token that includes the moderator:manage:banned_users scope.
|
// Requires a user access token that includes the moderator:manage:banned_users scope.
|
||||||
func (m *Moderation) UnbanUser(ctx context.Context, params *UnbanUserParams) error {
|
func (m *Moderation) UnbanUser(ctx context.Context, params *UnbanUserParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/bans", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "moderation/bans", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateAutoModSettingsParams struct {
|
type UpdateAutoModSettingsParams struct {
|
||||||
|
@ -79,7 +79,6 @@ type UpdateAutoModSettingsResponse struct {
|
||||||
// Requires a user access token that includes the moderator:manage:automod_settings scope.
|
// Requires a user access token that includes the moderator:manage:automod_settings scope.
|
||||||
func (m *Moderation) UpdateAutoModSettings(ctx context.Context, params *UpdateAutoModSettingsParams, body *UpdateAutoModSettingsRequest) (*UpdateAutoModSettingsResponse, error) {
|
func (m *Moderation) UpdateAutoModSettings(ctx context.Context, params *UpdateAutoModSettingsParams, body *UpdateAutoModSettingsRequest) (*UpdateAutoModSettingsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/automod/settings", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ func (m *Moderation) UpdateAutoModSettings(ctx context.Context, params *UpdateAu
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPut, endpoint.Make(m.baseUrl, "moderation/automod/settings", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateShieldModeStatusParams struct {
|
type UpdateShieldModeStatusParams struct {
|
||||||
|
@ -38,7 +38,6 @@ type UpdateShieldModeStatusResponse struct {
|
||||||
// Requires a user access token that includes the moderator:manage:shield_mode scope.
|
// Requires a user access token that includes the moderator:manage:shield_mode scope.
|
||||||
func (m *Moderation) UpdateShieldModeStatus(ctx context.Context, params *UpdateShieldModeStatusParams) (*UpdateShieldModeStatusResponse, error) {
|
func (m *Moderation) UpdateShieldModeStatus(ctx context.Context, params *UpdateShieldModeStatusParams) (*UpdateShieldModeStatusResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/shield_mode", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ func (m *Moderation) UpdateShieldModeStatus(ctx context.Context, params *UpdateS
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(m.baseUrl, "moderation/shield_mode", v), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreatePollRequest struct {
|
type CreatePollRequest struct {
|
||||||
|
@ -49,8 +50,6 @@ type CreatePollResponse struct {
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:manage:polls scope.
|
// Requires a user access token that includes the channel:manage:polls scope.
|
||||||
func (p *Polls) CreatePoll(ctx context.Context, body *CreatePollRequest) (*CreatePollResponse, error) {
|
func (p *Polls) CreatePoll(ctx context.Context, body *CreatePollRequest) (*CreatePollResponse, error) {
|
||||||
endpoint := p.baseUrl.ResolveReference(&url.URL{Path: "polls"})
|
|
||||||
|
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -61,7 +60,7 @@ func (p *Polls) CreatePoll(ctx context.Context, body *CreatePollRequest) (*Creat
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), r)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(p.baseUrl, "polls"), r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EndPollParams struct {
|
type EndPollParams struct {
|
||||||
|
@ -30,9 +30,8 @@ type EndPollParams struct {
|
||||||
// Requires a user access token that includes the channel:manage:polls scope.
|
// Requires a user access token that includes the channel:manage:polls scope.
|
||||||
func (p *Polls) EndPoll(ctx context.Context, params *EndPollParams) error {
|
func (p *Polls) EndPoll(ctx context.Context, params *EndPollParams) error {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := p.baseUrl.ResolveReference(&url.URL{Path: "polls", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(p.baseUrl, "polls", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
"go.fifitido.net/twitch/api/types"
|
"go.fifitido.net/twitch/api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,9 +50,8 @@ type GetPollsResponse struct {
|
||||||
// Requires a user access token that includes the channel:read:polls or channel:manage:polls scope.
|
// Requires a user access token that includes the channel:read:polls or channel:manage:polls scope.
|
||||||
func (p *Polls) GetPolls(ctx context.Context, params *GetPollsParams) (*GetPollsResponse, error) {
|
func (p *Polls) GetPolls(ctx context.Context, params *GetPollsParams) (*GetPollsResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := p.baseUrl.ResolveReference(&url.URL{Path: "polls", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint.Make(p.baseUrl, "polls", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CreatePredictionRequest struct {
|
type CreatePredictionRequest struct {
|
||||||
|
@ -40,16 +40,15 @@ type CreatePredictionResponse struct {
|
||||||
// The prediction runs as soon as it’s created. The broadcaster may run only one prediction at a time.
|
// The prediction runs as soon as it’s created. The broadcaster may run only one prediction at a time.
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:manage:predictions scope.
|
// Requires a user access token that includes the channel:manage:predictions scope.
|
||||||
func (c *Predictions) CreatePrediction(ctx context.Context, params *CreatePredictionRequest) (*CreatePredictionResponse, error) {
|
func (p *Predictions) CreatePrediction(ctx context.Context, params *CreatePredictionRequest) (*CreatePredictionResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "predictions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.Make(p.baseUrl, "predictions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := p.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
|
"go.fifitido.net/twitch/api/endpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EndPredictionRequest struct {
|
type EndPredictionRequest struct {
|
||||||
|
@ -43,16 +43,15 @@ type EndPredictionResponse struct {
|
||||||
// Locks, resolves, or cancels a Channel Points Prediction.
|
// Locks, resolves, or cancels a Channel Points Prediction.
|
||||||
//
|
//
|
||||||
// Requires a user access token that includes the channel:manage:predictions scope.
|
// Requires a user access token that includes the channel:manage:predictions scope.
|
||||||
func (c *Predictions) EndPrediction(ctx context.Context, params *EndPredictionRequest) (*EndPredictionResponse, error) {
|
func (p *Predictions) EndPrediction(ctx context.Context, params *EndPredictionRequest) (*EndPredictionResponse, error) {
|
||||||
v, _ := query.Values(params)
|
v, _ := query.Values(params)
|
||||||
endpoint := c.baseUrl.ResolveReference(&url.URL{Path: "predictions", RawQuery: v.Encode()})
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, endpoint.Make(p.baseUrl, "predictions", v), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := c.client.Do(req)
|
res, err := p.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue