-
Notifications
You must be signed in to change notification settings - Fork 86
/
api_getSubscriptionData.go
82 lines (74 loc) · 3.33 KB
/
api_getSubscriptionData.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
76
77
78
79
80
81
82
package notionapi
type SubscriptionDataSpaceUsers struct {
UserID string `json:"userId"`
Role string `json:"role"`
IsGuest bool `json:"isGuest"`
GuestPageIds []interface{} `json:"guestPageIds"`
}
type SubscriptionDataCredits struct {
ID string `json:"id"`
Version int `json:"version"`
UserID string `json:"user_id"`
Amount int `json:"amount"`
Activated bool `json:"activated"`
CreatedTimestamp string `json:"created_timestamp"`
Type string `json:"type"`
}
type SubscriptionDataAddress struct {
Name string `json:"name"`
BusinessName string `json:"businessName"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
ZipCode string `json:"zipCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
}
type SubscriptionData struct {
Type string `json:"type"`
SpaceUsers []SubscriptionDataSpaceUsers `json:"spaceUsers"`
Credits []SubscriptionDataCredits `json:"credits"`
TotalCredit int `json:"totalCredit"`
AvailableCredit int `json:"availableCredit"`
CreditEnabled bool `json:"creditEnabled"`
CustomerID string `json:"customerId"`
CustomerName string `json:"customerName"`
VatID string `json:"vatId"`
IsDelinquent bool `json:"isDelinquent"`
ProductID string `json:"productId"`
BillingEmail string `json:"billingEmail"`
Plan string `json:"plan"`
PlanAmount int `json:"planAmount"`
AccountBalance int `json:"accountBalance"`
MonthlyPlanAmount int `json:"monthlyPlanAmount"`
YearlyPlanAmount int `json:"yearlyPlanAmount"`
Quantity int `json:"quantity"`
Billing string `json:"billing"`
Address SubscriptionDataAddress `json:"address"`
Last4 string `json:"last4"`
Brand string `json:"brand"`
Interval string `json:"interval"`
Created int64 `json:"created"`
PeriodEnd int64 `json:"periodEnd"`
NextInvoiceTime int64 `json:"nextInvoiceTime"`
NextInvoiceAmount int `json:"nextInvoiceAmount"`
IsPaid bool `json:"isPaid"`
Members []interface{} `json:"members"`
RawJSON map[string]interface{} `json:"-"`
}
// GetSubscriptionData executes a raw API call /api/v3/getSubscriptionData
func (c *Client) GetSubscriptionData(spaceID string) (*SubscriptionData, error) {
req := &struct {
SpaceID string `json:"spaceId"`
}{
SpaceID: spaceID,
}
var rsp SubscriptionData
var err error
apiURL := "/api/v3/getSubscriptionData"
err = c.doNotionAPI(apiURL, req, &rsp, &rsp.RawJSON)
if err != nil {
return nil, err
}
return &rsp, nil
}