-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmite.go
67 lines (56 loc) · 1.55 KB
/
mite.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
package mite
import (
"path"
)
// -------------------------------------------------------------
// ~ Const
// -------------------------------------------------------------
const (
// MiteURL is the current mite url
MiteURL = "mite.yo.lk"
// TimeFormat is the time format used by mite
TimeFormat = "2006-01-02"
)
// filter options
const (
ParamProjectID = "project_id"
ParamCustomerID = "customer_id"
ParamGroupBy = "group_by"
ParamFrom = "from"
ParamTo = "to"
)
// -------------------------------------------------------------
// ~ Types
// -------------------------------------------------------------
// ServiceHourlyRates mite object
type ServiceHourlyRates struct {
ServiceID uint64 `json:"service_id"`
HourlyRate uint64 `json:"hourly_rate"`
}
// Mite is the interface used for the api
type Mite struct {
// l *zap.SugaredLogger
Prefix string
Username string
APIKey string
AppName string
}
// -------------------------------------------------------------
// ~ Functions
// -------------------------------------------------------------
// NewMiteAPI creates a new mite api struct
func NewMiteAPI(username, team, apiKey, appName string) *Mite {
return &Mite{
Prefix: team,
Username: username,
APIKey: apiKey,
AppName: appName,
}
}
// GetMitePath returns a mite path for the for the current workspace
func (m *Mite) GetMitePath() string {
return "https://" + m.Prefix + "." + MiteURL
}
func (m *Mite) mitePathWithParam(suffix string) string {
return "https://" + path.Join((m.Prefix+"."+MiteURL), suffix)
}