New builds a new Client with the provided API key and secret. It can be configured further by passing any number of ClientOption parameters.
(key, secret string, opts ...ClientOption)
| 37 | // New builds a new Client with the provided API key and secret. It can be |
| 38 | // configured further by passing any number of ClientOption parameters. |
| 39 | func New(key, secret string, opts ...ClientOption) (*Client, error) { |
| 40 | if key == "" || secret == "" { |
| 41 | return nil, errMissingCredentials |
| 42 | } |
| 43 | c := &Client{ |
| 44 | key: key, |
| 45 | timeout: time.Second * 6, |
| 46 | authenticator: authenticator{secret: secret}, |
| 47 | } |
| 48 | for _, opt := range opts { |
| 49 | opt(c) |
| 50 | } |
| 51 | if c.requester == nil { |
| 52 | c.requester = newRequester(c.timeout) |
| 53 | } |
| 54 | c.urlBuilder = newAPIURLBuilder(c.addr, c.region, c.version) |
| 55 | return c, nil |
| 56 | } |
| 57 | |
| 58 | func newRequester(timeout time.Duration) Requester { |
| 59 | tr := http.DefaultTransport.(*http.Transport).Clone() |