bundle metrics
This commit is contained in:
parent
d25450e022
commit
531947a497
21 changed files with 573 additions and 252 deletions
|
|
@ -77,6 +77,7 @@ type Client struct {
|
|||
GetAppUser func(req GetAppUserRequest) (*AppUser, error)
|
||||
GetAppUserLNURLInfo func(req GetAppUserLNURLInfoRequest) (*LnurlPayInfoResponse, error)
|
||||
GetAppsMetrics func(req AppsMetricsRequest) (*AppsMetrics, error)
|
||||
GetBundleMetrics func(req LatestBundleMetricReq) (*BundleMetrics, error)
|
||||
GetDebitAuthorizations func() (*DebitAuthorizations, error)
|
||||
GetErrorStats func() (*ErrorStats, error)
|
||||
GetHttpCreds func() (*HttpCreds, error)
|
||||
|
|
@ -740,6 +741,35 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetBundleMetrics: func(req LatestBundleMetricReq) (*BundleMetrics, error) {
|
||||
auth, err := params.RetrieveMetricsAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/reports/bundle"
|
||||
body, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := ResultError{}
|
||||
err = json.Unmarshal(resBody, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Status == "ERROR" {
|
||||
return nil, fmt.Errorf(result.Reason)
|
||||
}
|
||||
res := BundleMetrics{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetDebitAuthorizations: func() (*DebitAuthorizations, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -174,6 +174,17 @@ type BannedAppUser struct {
|
|||
Nostr_pub string `json:"nostr_pub"`
|
||||
User_identifier string `json:"user_identifier"`
|
||||
}
|
||||
type BundleData struct {
|
||||
Available_chunks []int64 `json:"available_chunks"`
|
||||
Base_64_data []string `json:"base_64_data"`
|
||||
Current_chunk int64 `json:"current_chunk"`
|
||||
}
|
||||
type BundleMetric struct {
|
||||
App_bundles map[string]BundleData `json:"app_bundles"`
|
||||
}
|
||||
type BundleMetrics struct {
|
||||
Apps map[string]BundleMetric `json:"apps"`
|
||||
}
|
||||
type CallbackUrl struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
|
@ -323,6 +334,9 @@ type HttpCreds struct {
|
|||
Token string `json:"token"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
type LatestBundleMetricReq struct {
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
type LatestUsageMetricReq struct {
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue