Changed variable names to be more specific

This commit is contained in:
tyler 2024-04-15 14:36:05 -04:00
parent 52b51727eb
commit 1736c64b31
4 changed files with 14 additions and 14 deletions

View file

@ -50,11 +50,11 @@ func (c *Client) ChatInfo(reload bool) (*ChatInfo, error) {
} }
func (c *Client) getChatInfo() (*ChatInfo, error) { func (c *Client) getChatInfo() (*ChatInfo, error) {
if c.StreamUrl == "" { if c.LiveStreamUrl == "" {
return nil, fmt.Errorf("stream url is empty") return nil, fmt.Errorf("stream url is empty")
} }
resp, err := c.getWebpage(c.StreamUrl) resp, err := c.getWebpage(c.LiveStreamUrl)
if err != nil { if err != nil {
return nil, fmt.Errorf("error getting stream webpage: %v", err) return nil, fmt.Errorf("error getting stream webpage: %v", err)
} }

View file

@ -24,7 +24,7 @@ func TestChatInfo(t *testing.T) {
t.Skipf("Set %s to run this test.", liveUrlEnvVar) t.Skipf("Set %s to run this test.", liveUrlEnvVar)
} }
client, err := NewClient(NewClientOptions{StreamUrl: url}) client, err := NewClient(NewClientOptions{LiveStreamUrl: url})
if err != nil { if err != nil {
t.Fatalf("Want NewClient err = nil, got: %v", err) t.Fatalf("Want NewClient err = nil, got: %v", err)
} }

View file

@ -23,12 +23,12 @@ const (
) )
type Client struct { type Client struct {
httpClient *http.Client httpClient *http.Client
chatInfo *ChatInfo chatInfo *ChatInfo
chatStream *ChatStream chatStream *ChatStream
chatStreamMu sync.Mutex chatStreamMu sync.Mutex
StreamKey string ApiKey string
StreamUrl string LiveStreamUrl string
} }
func (c *Client) cookies() ([]*http.Cookie, error) { func (c *Client) cookies() ([]*http.Cookie, error) {
@ -53,9 +53,9 @@ func (c *Client) PrintCookies() error {
} }
type NewClientOptions struct { type NewClientOptions struct {
Cookies []*http.Cookie `json:"cookies"` Cookies []*http.Cookie `json:"cookies"`
StreamKey string `json:"stream_key"` ApiKey string `json:"stream_key"`
StreamUrl string `json:"stream_url"` LiveStreamUrl string `json:"stream_url"`
} }
func NewClient(opts NewClientOptions) (*Client, error) { func NewClient(opts NewClientOptions) (*Client, error) {
@ -64,7 +64,7 @@ func NewClient(opts NewClientOptions) (*Client, error) {
return nil, pkgErr("error creating http client", err) return nil, pkgErr("error creating http client", err)
} }
return &Client{httpClient: cl, StreamKey: opts.StreamKey, StreamUrl: opts.StreamUrl}, nil return &Client{httpClient: cl, ApiKey: opts.ApiKey, LiveStreamUrl: opts.LiveStreamUrl}, nil
} }
func newHttpClient(cookies []*http.Cookie) (*http.Client, error) { func newHttpClient(cookies []*http.Cookie) (*http.Client, error) {

View file

@ -95,7 +95,7 @@ type LivestreamResponse struct {
func (c *Client) Request() (*LivestreamResponse, error) { func (c *Client) Request() (*LivestreamResponse, error) {
hcl := http.Client{Timeout: 30 * time.Second} hcl := http.Client{Timeout: 30 * time.Second}
resp, err := hcl.Get(c.StreamKey) resp, err := hcl.Get(c.ApiKey)
if err != nil { if err != nil {
return nil, pkgErr("http Get request returned error", err) return nil, pkgErr("http Get request returned error", err)
} }