-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
59 lines (49 loc) · 1023 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package gofantasy
import (
"net/http"
"time"
)
type IClient interface {
// WithOptions allows providing additional client options such as WithHTTPDebugging. These are not commonly needed.
WithOptions(opts ...ClientOption) IClient
Yahoo() IYahooClient
//ESPN() IEspnClient
}
type client struct {
requestor *requestor
cache ICache
}
var defaultHTTPClient = &http.Client{
Timeout: time.Second * 10,
Transport: &http.Transport{
TLSHandshakeTimeout: 10 * time.Second,
},
}
func NewClient(opts ...ClientOption) IClient {
r := &requestor{
httpClient: defaultHTTPClient,
}
c := &client{
requestor: r,
}
c.WithOptions(opts...)
return c
}
func (c *client) WithOptions(opts ...ClientOption) IClient {
for _, opt := range opts {
opt(c)
}
return c
}
func (c *client) Yahoo() IYahooClient {
return &yahooClient{
baseUrl: YahooBaseURL,
baseClient: c,
yahooOAuth2: &yahooOAuth2{},
}
}
//func (c *client) ESPN() IEspnClient {
// return &espnClient{
// baseUrl: YahooBaseURL,
// }
//}