-
Notifications
You must be signed in to change notification settings - Fork 18
/
service.go
69 lines (56 loc) · 1.63 KB
/
service.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
package lokalise
import (
"context"
)
type BaseService struct {
*restClient
PageOptions
ctx context.Context
}
func (s *BaseService) Ctx() context.Context {
if s.ctx != nil {
return s.ctx
}
return context.Background()
}
func (s *BaseService) SetContext(c context.Context) {
s.ctx = c
}
func (s *BaseService) PageOpts() PageOptions {
return s.PageOptions
}
func (s *BaseService) SetPageOptions(opts PageOptions) {
if opts.Limit != 0 {
s.Limit = opts.Limit
}
if opts.Page != 0 {
s.Page = opts.Page
}
if opts.Pagination != "" {
s.Pagination = opts.Pagination
}
if opts.Cursor != "" {
s.Cursor = opts.Cursor
}
}
// ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
// Additional subtypes
// _____________________________________________________________________________________________________________________
type WithCreationTime struct {
CreatedAt string `json:"created_at"`
CreatedAtTs int64 `json:"created_at_timestamp"`
}
type WithCreationUser struct {
CreatedBy int64 `json:"created_by"`
CreatedByEmail string `json:"created_by_email"`
}
// could be optional for some creation structs, i.e. NewProject
type WithTeamID struct {
TeamID int64 `json:"team_id,omitempty"`
}
type WithProjectID struct {
ProjectID string `json:"project_id,omitempty"`
}
type WithUserID struct {
UserID int64 `json:"user_id,omitempty"`
}