go-twitch/api/api.go

45 lines
1020 B
Go

package api
import (
"net/http"
"net/url"
"go.fifitido.net/twitch/api/ads"
"go.fifitido.net/twitch/api/analytics"
"go.fifitido.net/twitch/api/bits"
"go.fifitido.net/twitch/api/channelpoints"
"go.fifitido.net/twitch/api/channels"
"go.fifitido.net/twitch/api/eventsub"
)
const HelixBaseUrl = "https://api.twitch.tv/helix"
type API struct {
client *http.Client
baseUrl *url.URL
Ads *ads.Ads
Analytics *analytics.Analytics
Bits *bits.Bits
Channels *channels.Channels
ChannelPoints *channelpoints.ChannelPoints
EventSub *eventsub.EventSub
}
func New() *API {
client := &http.Client{}
baseUrl, _ := url.Parse(HelixBaseUrl)
return &API{
client: client,
baseUrl: baseUrl,
Ads: ads.New(client, baseUrl),
Analytics: analytics.New(client, baseUrl),
Bits: bits.New(client, baseUrl),
Channels: channels.New(client, baseUrl),
ChannelPoints: channelpoints.New(client, baseUrl),
EventSub: eventsub.New(client, baseUrl),
}
}