single bundle metrics

This commit is contained in:
boufni95 2025-02-06 16:15:17 +00:00
parent cebb8559c1
commit c0f137d996
15 changed files with 226 additions and 34 deletions

View file

@ -94,7 +94,8 @@ type Client struct {
GetNPubLinkingState func(req GetNPubLinking) (*NPubLinking, error)
GetPaymentState func(req GetPaymentStateRequest) (*PaymentState, error)
GetSeed func() (*LndSeed, error)
GetSingleUsageMetrics func(req SingleUsageMetricReq) (*UsageMetricTlv, error)
GetSingleBundleMetrics func(req SingleMetricReq) (*BundleData, error)
GetSingleUsageMetrics func(req SingleMetricReq) (*UsageMetricTlv, error)
GetUsageMetrics func(req LatestUsageMetricReq) (*UsageMetrics, error)
GetUserInfo func() (*UserInfo, error)
GetUserOffer func(req OfferId) (*OfferConfig, error)
@ -1090,7 +1091,36 @@ func NewClient(params ClientParams) *Client {
}
return &res, nil
},
GetSingleUsageMetrics: func(req SingleUsageMetricReq) (*UsageMetricTlv, error) {
GetSingleBundleMetrics: func(req SingleMetricReq) (*BundleData, error) {
auth, err := params.RetrieveMetricsAuth()
if err != nil {
return nil, err
}
finalRoute := "/api/reports/bundle/single"
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 := BundleData{}
err = json.Unmarshal(resBody, &res)
if err != nil {
return nil, err
}
return &res, nil
},
GetSingleUsageMetrics: func(req SingleMetricReq) (*UsageMetricTlv, error) {
auth, err := params.RetrieveMetricsAuth()
if err != nil {
return nil, err

View file

@ -78,6 +78,13 @@ const (
INVOICE_OP OperationType = "INVOICE_OP"
)
type SingleMetricType string
const (
BUNDLE_METRIC SingleMetricType = "BUNDLE_METRIC"
USAGE_METRIC SingleMetricType = "USAGE_METRIC"
)
type UserOperationType string
const (
@ -569,11 +576,12 @@ type SetMockInvoiceAsPaidRequest struct {
Amount int64 `json:"amount"`
Invoice string `json:"invoice"`
}
type SingleUsageMetricReq struct {
App_id string `json:"app_id"`
Metrics_name string `json:"metrics_name"`
Page int64 `json:"page"`
Request_id int64 `json:"request_id"`
type SingleMetricReq struct {
App_id string `json:"app_id"`
Metric_type SingleMetricType `json:"metric_type"`
Metrics_name string `json:"metrics_name"`
Page int64 `json:"page"`
Request_id int64 `json:"request_id"`
}
type UpdateChannelPolicyRequest struct {
Policy *ChannelPolicy `json:"policy"`