custom ofers
This commit is contained in:
parent
a945038b16
commit
1f5c3041bd
22 changed files with 1254 additions and 78 deletions
|
|
@ -60,6 +60,7 @@ type Client struct {
|
|||
AddAppUserInvoice func(req AddAppUserInvoiceRequest) (*NewInvoiceResponse, error)
|
||||
AddPeer func(req AddPeerRequest) error
|
||||
AddProduct func(req AddProductRequest) (*Product, error)
|
||||
AddUserOffer func(req OfferConfig) (*OfferId, error)
|
||||
AuthApp func(req AuthAppRequest) (*AuthApp, error)
|
||||
AuthorizeDebit func(req DebitAuthorizationRequest) (*DebitAuthorization, error)
|
||||
BanDebit func(req DebitOperation) error
|
||||
|
|
@ -68,6 +69,7 @@ type Client struct {
|
|||
CloseChannel func(req CloseChannelRequest) (*CloseChannelResponse, error)
|
||||
CreateOneTimeInviteLink func(req CreateOneTimeInviteLinkRequest) (*CreateOneTimeInviteLinkResponse, error)
|
||||
DecodeInvoice func(req DecodeInvoiceRequest) (*DecodeInvoiceResponse, error)
|
||||
DeleteUserOffer func(req OfferId) error
|
||||
EditDebit func(req DebitAuthorizationRequest) error
|
||||
EncryptionExchange func(req EncryptionExchangeRequest) error
|
||||
EnrollAdminToken func(req EnrollAdminTokenRequest) error
|
||||
|
|
@ -92,6 +94,8 @@ type Client struct {
|
|||
GetSeed func() (*LndSeed, error)
|
||||
GetUsageMetrics func() (*UsageMetrics, error)
|
||||
GetUserInfo func() (*UserInfo, error)
|
||||
GetUserOffer func(req OfferId) (*OfferConfig, error)
|
||||
GetUserOffers func() (*UserOffers, error)
|
||||
GetUserOperations func(req GetUserOperationsRequest) (*GetUserOperationsResponse, error)
|
||||
HandleLnurlAddress func(routeParams HandleLnurlAddress_RouteParams) (*LnurlPayInfoResponse, error)
|
||||
HandleLnurlPay func(query HandleLnurlPay_Query) (*HandleLnurlPayResponse, error)
|
||||
|
|
@ -118,6 +122,7 @@ type Client struct {
|
|||
SetMockInvoiceAsPaid func(req SetMockInvoiceAsPaidRequest) error
|
||||
UpdateCallbackUrl func(req CallbackUrl) (*CallbackUrl, error)
|
||||
UpdateChannelPolicy func(req UpdateChannelPolicyRequest) error
|
||||
UpdateUserOffer func(req OfferConfig) error
|
||||
UseInviteLink func(req UseInviteLinkRequest) error
|
||||
UserHealth func() error
|
||||
}
|
||||
|
|
@ -293,6 +298,35 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
AddUserOffer: func(req OfferConfig) (*OfferId, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/offer/add"
|
||||
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 := OfferId{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
},
|
||||
AuthApp: func(req AuthAppRequest) (*AuthApp, error) {
|
||||
auth, err := params.RetrieveAdminAuth()
|
||||
if err != nil {
|
||||
|
|
@ -492,6 +526,30 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
DeleteUserOffer: func(req OfferId) error {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
finalRoute := "/api/user/offer/delete"
|
||||
body, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result := ResultError{}
|
||||
err = json.Unmarshal(resBody, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Status == "ERROR" {
|
||||
return fmt.Errorf(result.Reason)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
EditDebit: func(req DebitAuthorizationRequest) error {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
|
|
@ -1023,6 +1081,50 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetUserOffer: func(req OfferId) (*OfferConfig, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/offer/get"
|
||||
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
||||
result := ResultError{}
|
||||
err = json.Unmarshal(resBody, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Status == "ERROR" {
|
||||
return nil, fmt.Errorf(result.Reason)
|
||||
}
|
||||
res := OfferConfig{}
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
finalRoute := "/api/user/offers/get"
|
||||
resBody, err := doGetRequest(params.BaseURL+finalRoute, auth)
|
||||
result := ResultError{}
|
||||
err = json.Unmarshal(resBody, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Status == "ERROR" {
|
||||
return nil, fmt.Errorf(result.Reason)
|
||||
}
|
||||
res := UserOffers{}
|
||||
err = json.Unmarshal(resBody, &res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &res, nil
|
||||
},
|
||||
GetUserOperations: func(req GetUserOperationsRequest) (*GetUserOperationsResponse, error) {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
|
|
@ -1717,6 +1819,30 @@ func NewClient(params ClientParams) *Client {
|
|||
}
|
||||
return nil
|
||||
},
|
||||
UpdateUserOffer: func(req OfferConfig) error {
|
||||
auth, err := params.RetrieveUserAuth()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
finalRoute := "/api/user/offer/update"
|
||||
body, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result := ResultError{}
|
||||
err = json.Unmarshal(resBody, &result)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.Status == "ERROR" {
|
||||
return fmt.Errorf(result.Reason)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
UseInviteLink: func(req UseInviteLinkRequest) error {
|
||||
auth, err := params.RetrieveGuestWithPubAuth()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -64,6 +64,12 @@ const (
|
|||
WEEK IntervalType = "WEEK"
|
||||
)
|
||||
|
||||
type OfferDataType string
|
||||
|
||||
const (
|
||||
DATA_STRING OfferDataType = "DATA_STRING"
|
||||
)
|
||||
|
||||
type OperationType string
|
||||
|
||||
const (
|
||||
|
|
@ -94,6 +100,8 @@ type AddAppRequest struct {
|
|||
type AddAppUserInvoiceRequest struct {
|
||||
Http_callback_url string `json:"http_callback_url"`
|
||||
Invoice_req *NewInvoiceRequest `json:"invoice_req"`
|
||||
Offer_string string `json:"offer_string"`
|
||||
Payer_data *PayerData `json:"payer_data"`
|
||||
Payer_identifier string `json:"payer_identifier"`
|
||||
Receiver_identifier string `json:"receiver_identifier"`
|
||||
}
|
||||
|
|
@ -386,6 +394,17 @@ type NewInvoiceRequest struct {
|
|||
type NewInvoiceResponse struct {
|
||||
Invoice string `json:"invoice"`
|
||||
}
|
||||
type OfferConfig struct {
|
||||
Callback_url string `json:"callback_url"`
|
||||
Expected_data map[string]OfferDataType `json:"expected_data"`
|
||||
Label string `json:"label"`
|
||||
Noffer string `json:"noffer"`
|
||||
Offer_id string `json:"offer_id"`
|
||||
Price_sats int64 `json:"price_sats"`
|
||||
}
|
||||
type OfferId struct {
|
||||
Offer_id string `json:"offer_id"`
|
||||
}
|
||||
type OpenChannel struct {
|
||||
Active bool `json:"active"`
|
||||
Capacity int64 `json:"capacity"`
|
||||
|
|
@ -436,6 +455,9 @@ type PayInvoiceResponse struct {
|
|||
Preimage string `json:"preimage"`
|
||||
Service_fee int64 `json:"service_fee"`
|
||||
}
|
||||
type PayerData struct {
|
||||
Data map[string]string `json:"data"`
|
||||
}
|
||||
type PaymentState struct {
|
||||
Amount int64 `json:"amount"`
|
||||
Network_fee int64 `json:"network_fee"`
|
||||
|
|
@ -531,6 +553,9 @@ type UserInfo struct {
|
|||
Userid string `json:"userId"`
|
||||
User_identifier string `json:"user_identifier"`
|
||||
}
|
||||
type UserOffers struct {
|
||||
Offers []OfferConfig `json:"offers"`
|
||||
}
|
||||
type UserOperation struct {
|
||||
Amount int64 `json:"amount"`
|
||||
Confirmed bool `json:"confirmed"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue