-
Notifications
You must be signed in to change notification settings - Fork 61
/
client.go
56 lines (50 loc) · 1.46 KB
/
client.go
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
47
48
49
50
51
52
53
54
55
56
package recommendation
import (
"github.com/algolia/algoliasearch-client-go/v3/algolia/call"
"github.com/algolia/algoliasearch-client-go/v3/algolia/compression"
"github.com/algolia/algoliasearch-client-go/v3/algolia/region"
"github.com/algolia/algoliasearch-client-go/v3/algolia/transport"
)
// Deprecated: use personalization.Client instead
// Client provides methods to interact with the Algolia Recommendation API.
type Client struct {
transport *transport.Transport
}
// Deprecated: use personalization.NewClient() instead
// NewClient instantiates a new client able to interact with the Algolia
// Recommendation API.
func NewClient(appID, apiKey string, region region.Region) *Client {
return NewClientWithConfig(
Configuration{
AppID: appID,
APIKey: apiKey,
Region: region,
},
)
}
// Deprecated: use personalization.NewClientWithConfig() instead
// NewClientWithConfig instantiates a new client able to interact with the
// Recommendation API.
func NewClientWithConfig(config Configuration) *Client {
var hosts []*transport.StatefulHost
if config.Hosts == nil {
hosts = defaultHosts(config.Region)
} else {
for _, h := range config.Hosts {
hosts = append(hosts, transport.NewStatefulHost(h, call.IsReadWrite))
}
}
return &Client{
transport: transport.New(
hosts,
config.Requester,
config.AppID,
config.APIKey,
config.ReadTimeout,
config.WriteTimeout,
config.Headers,
config.ExtraUserAgent,
compression.None,
),
}
}