list offer ops
This commit is contained in:
parent
babce0d4da
commit
299f5d86b6
13 changed files with 307 additions and 7 deletions
|
|
@ -95,6 +95,7 @@ type Client struct {
|
|||
GetUsageMetrics func() (*UsageMetrics, error)
|
||||
GetUserInfo func() (*UserInfo, error)
|
||||
GetUserOffer func(req OfferId) (*OfferConfig, error)
|
||||
GetUserOfferInvoices func(req GetUserOfferInvoicesReq) (*OfferInvoices, error)
|
||||
GetUserOffers func() (*UserOffers, error)
|
||||
GetUserOperations func(req GetUserOperationsRequest) (*GetUserOperationsResponse, error)
|
||||
HandleLnurlAddress func(routeParams HandleLnurlAddress_RouteParams) (*LnurlPayInfoResponse, error)
|
||||
|
|
@ -1110,6 +1111,35 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetUserOfferInvoices: func(req GetUserOfferInvoicesReq) (*OfferInvoices, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/offer/get/invoices"
|
||||
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 := OfferInvoices{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetUserOffers: func() (*UserOffers, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -274,6 +274,10 @@ type GetPaymentStateRequest struct {
|
|||
type GetProductBuyLinkResponse struct {
|
||||
Link string `json:"link"`
|
||||
}
|
||||
type GetUserOfferInvoicesReq struct {
|
||||
Include_unpaid bool `json:"include_unpaid"`
|
||||
Offer_id string `json:"offer_id"`
|
||||
}
|
||||
type GetUserOperationsRequest struct {
|
||||
Latestincominginvoice int64 `json:"latestIncomingInvoice"`
|
||||
Latestincomingtx int64 `json:"latestIncomingTx"`
|
||||
|
|
@ -406,6 +410,16 @@ type OfferConfig struct {
|
|||
type OfferId struct {
|
||||
Offer_id string `json:"offer_id"`
|
||||
}
|
||||
type OfferInvoice struct {
|
||||
Amount int64 `json:"amount"`
|
||||
Data map[string]string `json:"data"`
|
||||
Invoice string `json:"invoice"`
|
||||
Offer_id string `json:"offer_id"`
|
||||
Paid_at_unix int64 `json:"paid_at_unix"`
|
||||
}
|
||||
type OfferInvoices struct {
|
||||
Invoices []OfferInvoice `json:"invoices"`
|
||||
}
|
||||
type OpenChannel struct {
|
||||
Active bool `json:"active"`
|
||||
Capacity int64 `json:"capacity"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue