forked from chenyangguang/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption.go
More file actions
46 lines (39 loc) · 956 Bytes
/
Copy pathoption.go
File metadata and controls
46 lines (39 loc) · 956 Bytes
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
package woocommerce
import (
"fmt"
"time"
)
type Option func(c *Client)
// WithVersion version config option
func WithVersion(apiVersion string) Option {
return func(c *Client) {
pathPrefix := defaultApiPathPrefix
if len(apiVersion) > 0 && apiVersionRegex.MatchString(apiVersion) {
c.pathPrefix = fmt.Sprintf("%s/%s", defaultApiPathPrefix, apiVersion)
}
c.version = apiVersion
c.pathPrefix = pathPrefix
}
}
// WithRetry Timeout config option
func WithRetry(retries int) Option {
return func(c *Client) {
c.retries = retries
}
}
// WithLog log config option
func WithLog(logger LeveledLoggerInterface) Option {
return func(c *Client) {
c.log = logger
}
}
// SetLog updates the logger used by the client.
func (c *Client) SetLog(logger LeveledLoggerInterface) {
c.log = logger
}
// WithTimeout Timeout config option
func WithTimeout(timeout time.Duration) Option {
return func(c *Client) {
c.Client.Timeout = timeout
}
}