// NewClient returns a new Giphy API client.
// If no *http.Client were provided then http.DefaultClient is used.
490515
func NewClient(httpClients ...*http.Client) *Client {
	var httpClient *http.Client

	if len(httpClients) > 0 && httpClients[0] != nil {
		httpClient = httpClients[0]
	} else {
		cloned := *http.DefaultClient
		httpClient = &cloned
	}

	c := &Client{
		APIKey: Env("GIPHY_API_KEY", PublicBetaKey),
		Rating: Env("GIPHY_RATING", "g"),
		Limit:  EnvInt("GIPHY_LIMIT", 10),
		BaseURL: &url.URL{
			Scheme: Env("GIPHY_BASE_URL_SCHEME", "https"),
			Host:   Env("GIPHY_BASE_URL_HOST", "api.giphy.com"),
		},
		BasePath:   Env("GIPHY_BASE_PATH", "/v1"),
		UserAgent:  Env("GIPHY_USER_AGENT", "giphy.go"),
		httpClient: httpClient,
	}

	return c
}
737937
func newClient(ifi *net.Interface, p net.PacketConn, addrs []net.Addr) (*Client, error) {
	ip, err := firstIPv4Addr(addrs)
	if err != nil {
		return nil, err
	}

	return &Client{
		ifi: ifi,
		ip:  ip,
		p:   p,
	}, nil
}
835790
func NewClient(url string) *Client {
	return &Client{
		URL:    url,
		client: http.DefaultClient,
	}
}
710920
func (a Authenticator) NewClient(token *oauth2.Token) Client {
	client := a.config.Client(a.context, token)
	return Client{
		http:    client,
		baseURL: baseAddress,
	}
}
754748
func NewClient(config Config) Client {
	if config.AuthKey == "" {
		panic("failed to create Transloadit client: missing AuthKey")
	}

	if config.AuthSecret == "" {
		panic("failed to create Transloadit client: missing AuthSecret")
	}

	client := Client{
		config:     config,
		httpClient: &http.Client{},
	}

	return client
}
1092339
func NewClient(accountID, applicationKey string, httpClient *http.Client) (*Client, error) {
	if httpClient == nil {
		httpClient = http.DefaultClient
	}

	c := &Client{
		accountID:      accountID,
		applicationKey: applicationKey,
		hc:             httpClient,
	}

	if err := c.login(nil); err != nil {
		return nil, err
	}

	c.hc.Transport = &transport{t: c.hc.Transport, c: c}
	return c, nil
}
779954
func NewClient(opts ClientOpts) *Client {
	if opts.HTTPClient == nil {
		opts.HTTPClient = &http.Client{}
	}

	return &Client{
		token:      opts.Token,
		baseURL:    opts.BaseURL,
		httpClient: opts.HTTPClient,
		userAgent:  opts.UserAgent,
	}
}
297696
func NewClient(endpoint string) (*Client, error) {
	client, err := NewVersionedClient(endpoint, "")
	if err != nil {
		return nil, err
	}
	client.SkipServerVersionCheck = true
	return client, nil
}
580173
func NewClient(endpoint string) (*Client, error) {
	u, err := parseEndpoint(endpoint)
	if err != nil {
		return nil, err
	}

	return &Client{
		HTTPClient:  &http.Client{Timeout: time.Duration(5 * time.Second)},
		endpoint:    endpoint,
		endpointURL: u,
	}, nil
}
967847
func NewClient(opts ClientOptions) (*Client, error) {
	err := opts.ensure()
	if err != nil {
		return nil, err
	}

	return &Client{
		logger: log.Get(PkgName),
		opts:   opts,
	}, nil
}
776807
func NewClient(auth Auth) (*Client, error) {
	c := &Client{
		auth: auth,
	}
	return c, nil
}
1373932
func NewClient(apiDef *raml.APIDefinition, kind string, unmarshallResponse bool) Client {
	services := map[string]*service{}
	for uri, res := range apiDef.Resources {
		rd := resource.New(apiDef, &res, commons.NormalizeURITitle(apiDef.Title), false)
		services[uri] = newService(uri, &rd, unmarshallResponse)
	}
	switch kind {
	case "":
		kind = clientNameRequests
	case clientNameRequests, clientNameAiohttp, clientNameGeventRequests:
	default:
		log.Fatalf("invalid client kind:%v", kind)
	}

	c := Client{
		Name:               commons.NormalizeURI(apiDef.Title),
		APIDef:             apiDef,
		BaseURI:            apiDef.BaseURI,
		Services:           services,
		Kind:               kind,
		UnmarshallResponse: unmarshallResponse,
	}
	if strings.Index(c.BaseURI, "{version}") > 0 {
		c.BaseURI = strings.Replace(c.BaseURI, "{version}", apiDef.Version, -1)
	}
	c.initTemplates()
	c.Securities = getClientSecurityDefs(apiDef.SecuritySchemes, c.Template)

	return c
}
252117
func NewClient(host string, client *http.Client) access.AccessClient {
	return access.NewAccessPRPCClient(&prpc.Client{
		Host: host,
		C:    client,
	})
}
597682
func NewClient(endpoint *Endpoint, user, password string) (*Client, error) {
	return NewClientWithParameters(endpoint, user, password, DefaultParameters)
}
878669
func NewClient(cert tls.Certificate) (*http.Client, error) {
	config := &tls.Config{
		Certificates: []tls.Certificate{cert},
	}
	config.BuildNameToCertificate()
	transport := &http.Transport{TLSClientConfig: config}

	if err := http2.ConfigureTransport(transport); err != nil {
		return nil, err
	}

	return &http.Client{Transport: transport}, nil
}
114388
func NewClient(w io.Writer, r io.Reader) *Client {
	return &Client{
		r: NewReader(r),
		w: NewWriter(w),
	}
}
6023
func NewClient(name string, b func(...client.Option) client.Client) Option {
	return func(o *Options) {
		o.Clients[name] = b
	}
}