You've already forked email-api-client
We Had To Use Dark Magic To Make This Work
This commit is contained in:
39
client/client.go
Executable file
39
client/client.go
Executable file
@@ -0,0 +1,39 @@
|
||||
package client
|
||||
|
||||
type Client struct {
|
||||
config *Configuration
|
||||
token *Token
|
||||
}
|
||||
|
||||
var c = struct {
|
||||
client *Client
|
||||
initialized bool
|
||||
}{}
|
||||
|
||||
type accessTokenRequest struct {
|
||||
GrantType string `json:"grant_type"`
|
||||
ClientId string `json:"client_id"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
}
|
||||
|
||||
func NewClient(config *Configuration) *Client {
|
||||
|
||||
if c.initialized {
|
||||
return c.client
|
||||
}
|
||||
|
||||
client := &Client{
|
||||
config: config,
|
||||
}
|
||||
|
||||
token, err := getToken(client.config)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
client.token = token
|
||||
|
||||
c.client = client
|
||||
|
||||
return c.client
|
||||
}
|
||||
Reference in New Issue
Block a user