NewClient returns a new Client given an API key and options.
(opts ...func(c *Client) error)
| 107 | |
| 108 | // NewClient returns a new Client given an API key and options. |
| 109 | func NewClient(opts ...func(c *Client) error) (*Client, error) { |
| 110 | c := &Client{ |
| 111 | client: http.DefaultClient, |
| 112 | BasePath: basePath, |
| 113 | } |
| 114 | c.common.client = c |
| 115 | for _, opt := range opts { |
| 116 | if err := opt(c); err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | c.DNS = (*DNSService)(&c.common) |
| 122 | c.Run = (*RunService)(&c.common) |
| 123 | |
| 124 | return c, nil |
| 125 | } |
| 126 | |
| 127 | func (c *Client) DoRequest(req *http.Request, v interface{}) error { |
| 128 | if err := c.do(req, &v); err != nil { |
no outgoing calls