-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_config.go
75 lines (63 loc) · 1.79 KB
/
api_config.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
package filen
import (
"fmt"
"net/http"
"time"
"github.com/ybkimm/go-filen/internal/httpx"
)
type Config struct {
Maintenance bool `json:"maintenance"`
ReadOnly bool `json:"readOnly"`
Announcements []ConfigAnnouncement `json:"announcements"`
Pricing struct {
LifetimeEnabled bool `json:"lifetimeEnabled"`
SaleEnabled bool `json:"saleEnabled"`
Plans []ConfigPlans `json:"plans"`
} `json:"pricing"`
}
type ConfigAnnouncement struct {
UUID string `json:"uuid"`
Title string `json:"title"`
Message string `json:"message"`
Active bool `json:"active"`
Timestamp int `json:"timestamp"`
}
type ConfigPlans struct {
TermType int `json:"termType"`
ID int `json:"id"`
Name string `json:"name"`
Cost int `json:"cost"`
Sale int `json:"sale"`
Storage int `json:"storage"`
Popular bool `json:"popular"`
Term string `json:"term"`
}
type ConfigPlanTermType int
const (
ConfigPlanTermTypeStarter ConfigPlanTermType = 1
ConfigPlanTermTypeMonthly ConfigPlanTermType = 2
ConfigPlanTermTypeAnnually ConfigPlanTermType = 3
ConfigPlanTermTypeLifetime ConfigPlanTermType = 4
)
type ConfigPlanTerm string
const (
ConfigPlanTermMonthly ConfigPlanTerm = "monthly"
ConfigPlanTermAnnually ConfigPlanTerm = "annually"
ConfigPlanTermLifetime ConfigPlanTerm = "lifetime"
)
func (c *APIClient) GetConfig() (*Config, error) {
var config Config
// ConfigEndpoint is a CDN endpoint. Since it's a CDN endpoint,
// it does not affected by the endpoints list.
_, err := httpx.DoJsonRequest(
c.httpClient,
http.MethodGet,
fmt.Sprintf("%s?noCache=%d", ConfigEndpoint, time.Now().UnixNano()),
nil,
&config,
)
if err != nil {
return nil, err
}
return &config, nil
}