-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
74 lines (62 loc) · 1.54 KB
/
types.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
package shimo_openapi
import (
"sync"
"time"
)
// Client provides a way to interact with Shimo.im using such credentials
type Client struct {
clientId string
clientSecret string
username string
password string
scope string
asyncSign chan sign
l sync.RWMutex
cache map[string]*Cache
credential struct {
accessToken string
accessTokenExpiresAt time.Time
refreshToken string
}
}
type oAuthResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
// Opts provide options for getting sheet data
type Opts struct {
SheetName string `json:"sheet_name"`
EndRow int `json:"end_row"`
EndCol string `json:"end_col"`
// the suffix in the header to be removed
HeaderSuffix string `json:"header_suffix"`
CacheTTL time.Duration `json:"cache_ttl"`
}
type WriteOpts struct {
Range string `json:"range"`
Resource *WriteResource `json:"resource"`
}
type WriteResource struct {
Values [][]interface{} `json:"values"`
}
type sign struct {
Opts
FileID string
}
// Cache cache request data
type Cache struct {
Opts
expire time.Time
result []byte
}
// Because the map data is unordered,
// you need to customize the order in which the fields are stored
type WriteObj interface {
Values() []interface{}
}
func NewWriteOpts(sheetName string, v WriteObj) (*WriteOpts) {
w := &WriteOpts{ Range: sheetName, Resource: &WriteResource{} }
w.Resource.Values = make([][]interface{}, 0)
w.Resource.Values = append(w.Resource.Values, v.Values())
return w
}