-
Notifications
You must be signed in to change notification settings - Fork 5
/
platformclientfactory.go
36 lines (30 loc) · 1.2 KB
/
platformclientfactory.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
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package factory
import (
"strings"
"github.com/AccelByte/accelbyte-go-sdk/platform-sdk/pkg/platformclient"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/utils"
)
var platformClientInstance *platformclient.JusticePlatformService
func NewPlatformClient(configRepository repository.ConfigRepository) *platformclient.JusticePlatformService {
if platformClientInstance == nil {
baseURL := configRepository.GetJusticeBaseUrl()
xAmazonTraceID := utils.AmazonTraceIDGen()
userAgent := utils.UserAgentGen()
if len(baseURL) > 0 {
baseURLSplit := strings.Split(baseURL, "://")
httpClientConfig := &platformclient.TransportConfig{
Host: baseURLSplit[1],
BasePath: "",
Schemes: []string{baseURLSplit[0]},
}
platformClientInstance = platformclient.NewHTTPClientWithConfig(nil, httpClientConfig, userAgent, xAmazonTraceID)
} else {
platformClientInstance = platformclient.NewHTTPClient(nil)
}
}
return platformClientInstance
}