-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseatsioclient.go
81 lines (72 loc) · 2.41 KB
/
seatsioclient.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package seatsio
import (
"errors"
"github.com/imroc/req/v3"
"github.com/seatsio/seatsio-go/v9/charts"
"github.com/seatsio/seatsio-go/v9/eventlog"
"github.com/seatsio/seatsio-go/v9/events"
"github.com/seatsio/seatsio-go/v9/holdtokens"
"github.com/seatsio/seatsio-go/v9/reports"
"github.com/seatsio/seatsio-go/v9/seasons"
"github.com/seatsio/seatsio-go/v9/shared"
"github.com/seatsio/seatsio-go/v9/workspaces"
)
type seatsioClientNS struct {
apiClient *req.Client
}
var ClientSupport seatsioClientNS
const baseUrlStart = "https://api-"
const baseUrlEnd = ".seatsio.net"
const (
EU string = baseUrlStart + "eu" + baseUrlEnd
NA string = baseUrlStart + "na" + baseUrlEnd
SA string = baseUrlStart + "sa" + baseUrlEnd
OC string = baseUrlStart + "oc" + baseUrlEnd
)
type SeatsioClient struct {
baseUrl string
secretKey string
workspaceKey string
Workspaces *workspaces.Workspaces
Charts *charts.Charts
Events *events.Events
HoldTokens *holdtokens.HoldTokens
ChartReports *reports.ChartReports
EventReports *reports.EventReports
UsageReports *reports.UsageReports
Channels *events.Channels
Seasons *seasons.Seasons
EventLog *eventlog.EventLog
}
func NewSeatsioClient(baseUrl string, secretKey string, additionalHeaders ...shared.AdditionalHeader) *SeatsioClient {
apiClient := shared.ApiClient(secretKey, baseUrl, additionalHeaders...)
client := &SeatsioClient{
baseUrl: baseUrl,
secretKey: secretKey,
Workspaces: &workspaces.Workspaces{Client: apiClient},
Charts: &charts.Charts{
Client: apiClient,
Archive: &charts.Archive{Client: apiClient},
},
Events: &events.Events{Client: apiClient},
HoldTokens: &holdtokens.HoldTokens{Client: apiClient},
ChartReports: &reports.ChartReports{Client: apiClient},
EventReports: &reports.EventReports{Client: apiClient},
UsageReports: &reports.UsageReports{Client: apiClient},
Channels: &events.Channels{Client: apiClient},
Seasons: &seasons.Seasons{Client: apiClient},
EventLog: &eventlog.EventLog{Client: apiClient},
}
ClientSupport.apiClient = apiClient
return client
}
func (c *SeatsioClient) SetMaxRetries(count int) error {
if count < 0 {
return errors.New("retry count must not be negative")
}
ClientSupport.apiClient.SetCommonRetryCount(count)
return nil
}
func (seatsioClientNS) WorkspaceKey(key string) shared.AdditionalHeader {
return shared.WithAdditionalHeader("X-Workspace-Key", key)
}