Use Credentials struct for NewClient

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2021-01-24 22:51:27 -05:00
parent 78dc97a8d5
commit 6d615771cb
6 changed files with 34 additions and 52 deletions
+1 -12
View File
@@ -7,20 +7,9 @@ import (
"os"
)
// Opt is a configuration option to initialize a client.
// Opt is used to further configure a client upon initialization.
type Opt func(*Client) error
// WithCredentials sets the credentials used to authenticate with the Reddit API.
func WithCredentials(id, secret, username, password string) Opt {
return func(c *Client) error {
c.ID = id
c.Secret = secret
c.Username = username
c.Password = password
return nil
}
}
// WithHTTPClient sets the HTTP client which will be used to make requests.
func WithHTTPClient(httpClient *http.Client) Opt {
return func(c *Client) error {