paged single metrics
This commit is contained in:
parent
db3c27c7f2
commit
eadc956c4c
12 changed files with 213 additions and 91 deletions
|
|
@ -93,7 +93,8 @@ type Client struct {
|
|||
GetNPubLinkingState func(req GetNPubLinking) (*NPubLinking, error)
|
||||
GetPaymentState func(req GetPaymentStateRequest) (*PaymentState, error)
|
||||
GetSeed func() (*LndSeed, error)
|
||||
GetUsageMetrics func(req UsageMetricReq) (*UsageMetrics, error)
|
||||
GetSingleUsageMetrics func(req SingleUsageMetricReq) (*UsageMetricTlv, error)
|
||||
GetUsageMetrics func(req LatestUsageMetricReq) (*UsageMetrics, error)
|
||||
GetUserInfo func() (*UserInfo, error)
|
||||
GetUserOffer func(req OfferId) (*OfferConfig, error)
|
||||
GetUserOfferInvoices func(req GetUserOfferInvoicesReq) (*OfferInvoices, error)
|
||||
|
|
@ -1057,7 +1058,36 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetUsageMetrics: func(req UsageMetricReq) (*UsageMetrics, error) {
|
||||
GetSingleUsageMetrics: func(req SingleUsageMetricReq) (*UsageMetricTlv, error) {
|
||||
auth, err := params.RetrieveMetricsAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/reports/usage/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 := UsageMetricTlv{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetUsageMetrics: func(req LatestUsageMetricReq) (*UsageMetrics, error) {
|
||||
auth, err := params.RetrieveMetricsAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -322,6 +322,9 @@ type HttpCreds struct {
|
|||
Token string `json:"token"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
type LatestUsageMetricReq struct {
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
type LinkNPubThroughTokenRequest struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
|
@ -393,9 +396,6 @@ type LnurlWithdrawInfoResponse struct {
|
|||
Tag string `json:"tag"`
|
||||
}
|
||||
type MetricsFile struct {
|
||||
App_id string `json:"app_id"`
|
||||
Metrics_name string `json:"metrics_name"`
|
||||
Page int64 `json:"page"`
|
||||
}
|
||||
type MigrationUpdate struct {
|
||||
Closure *ClosureMigration `json:"closure"`
|
||||
|
|
@ -554,6 +554,11 @@ 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"`
|
||||
}
|
||||
type UpdateChannelPolicyRequest struct {
|
||||
Policy *ChannelPolicy `json:"policy"`
|
||||
Update *UpdateChannelPolicyRequest_update `json:"update"`
|
||||
|
|
@ -571,10 +576,6 @@ type UsageMetric struct {
|
|||
Success bool `json:"success"`
|
||||
Validate_in_nano int64 `json:"validate_in_nano"`
|
||||
}
|
||||
type UsageMetricReq struct {
|
||||
Limit int64 `json:"limit"`
|
||||
Metrics_file *MetricsFile `json:"metrics_file"`
|
||||
}
|
||||
type UsageMetricTlv struct {
|
||||
Available_chunks []int64 `json:"available_chunks"`
|
||||
Base_64_tlvs []string `json:"base_64_tlvs"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue