-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypings.go
126 lines (109 loc) · 3.43 KB
/
typings.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package platform
//goland:noinspection GoSnakeCaseUsage
import (
http "github.com/bogdanfinn/fhttp"
tls_client "github.com/bogdanfinn/tls-client"
"os"
)
type UserClient struct {
client tls_client.HttpClient
accessToken string
sessionKey string
lastResponse *http.Response
}
// NewUserPlatformClient called NewHttpClient with log.
func NewUserPlatformClient(accessToken string) *UserClient {
return &UserClient{
client: NewHttpClient(nil),
accessToken: accessToken,
}
}
func (u *UserClient) WithCustomHttpClient(client tls_client.HttpClient) *UserClient {
u.client = client
return u
}
func (u *UserClient) SessionKey() string {
return u.sessionKey
}
func (u *UserClient) AccessToken() string {
return u.accessToken
}
func (u *UserClient) LastResponse() *http.Response {
return u.lastResponse
}
//goland:noinspection GoUnhandledErrorResult,SpellCheckingInspection
func NewHttpClient(logger tls_client.Logger) tls_client.HttpClient {
tls_client_logger := tls_client.NewNoopLogger()
if logger != nil {
tls_client_logger = logger
}
client, _ := tls_client.NewHttpClient(tls_client_logger, []tls_client.HttpClientOption{
tls_client.WithCookieJar(tls_client.NewCookieJar()),
tls_client.WithClientProfile(tls_client.Okhttp4Android13),
tls_client.WithInsecureSkipVerify(), // for debug and proxies.
}...)
proxyUrl := os.Getenv("https_proxy")
if proxyUrl != "" {
client.SetProxy(proxyUrl)
}
return client
}
type GetAccessTokenRequest struct {
ClientID string `json:"client_id"`
GrantType string `json:"grant_type"`
Code string `json:"code"`
RedirectURI string `json:"redirect_uri"`
}
type GetAccessTokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
IDToken string `json:"id_token"`
Scope string `json:"scope"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
}
type Org struct {
Object string `json:"object"`
ID string `json:"id"`
Created int `json:"created"`
Title string `json:"title"`
Name string `json:"name"`
Description interface{} `json:"description"`
Personal bool `json:"personal"`
IsDefault bool `json:"is_default"`
Role string `json:"role"`
Groups []interface{} `json:"groups"`
}
type Orgs struct {
Object string `json:"object"`
Data []Org `json:"data"`
}
type Session struct {
SensitiveID string `json:"sensitive_id"`
Object string `json:"object"`
Name interface{} `json:"name"`
Created int `json:"created"`
LastUse int `json:"last_use"`
Publishable bool `json:"publishable"`
}
type User struct {
Object string `json:"object"`
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
Picture string `json:"picture"`
Created int `json:"created"`
Groups []interface{} `json:"groups"`
Session Session `json:"session"`
Orgs Orgs `json:"orgs"`
IntercomHash string `json:"intercom_hash"`
Amr []interface{} `json:"amr"`
}
type Key struct {
SensitiveID string `json:"sensitive_id"`
Object string `json:"object"`
Name string `json:"name"`
Created int `json:"created"`
LastUse int `json:"last_use"`
Publishable bool `json:"publishable"`
}