Update API
* mutations now return { result, invoice, paymentMethod } due to new backend payment optimism
This commit is contained in:
parent
17878b2f32
commit
b2a4dcbd19
30
invoice.go
Normal file
30
invoice.go
Normal file
@ -0,0 +1,30 @@
|
||||
package sn
|
||||
|
||||
import "time"
|
||||
|
||||
type Invoice struct {
|
||||
Id int `json:"id,string"`
|
||||
Hash string `json:"hash"`
|
||||
Hmac string `json:"hmac"`
|
||||
Bolt11 string `json:"bolt11"`
|
||||
SatsRequested int `json:"satsRequested"`
|
||||
SatsReceived int `json:"satsReceived"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
ConfirmedAt time.Time `json:"createdAt"`
|
||||
ExpiresAt time.Time `json:"expiresAt"`
|
||||
Nostr map[string]interface{} `json:"nostr"`
|
||||
IsHeld bool `json:"isHeld"`
|
||||
Comment string `json:"comment"`
|
||||
Lud18Data map[string]interface{} `json:"lud18Data"`
|
||||
ConfirmedPreimage string `json:"confirmedPreimage"`
|
||||
ActionState string `json:"actionState"`
|
||||
ActionType string `json:"actionType"`
|
||||
}
|
||||
|
||||
type PaymentMethod string
|
||||
|
||||
const (
|
||||
PaymentMethodFeeCredits PaymentMethod = "FEE_CREDIT"
|
||||
PaymentMethodOptimistic PaymentMethod = "OPTIMISTIC"
|
||||
PaymentMethodPessimistic PaymentMethod = "PESSIMISTIC"
|
||||
)
|
24
items.go
24
items.go
@ -50,24 +50,30 @@ type ItemsResponse struct {
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type ItemPaidAction struct {
|
||||
Result Item `json:"result"`
|
||||
Invoice Invoice `json:"invoice"`
|
||||
PaymentMethod PaymentMethod `json:"paymentMethod"`
|
||||
}
|
||||
|
||||
type UpsertDiscussionResponse struct {
|
||||
Errors []GqlError `json:"errors"`
|
||||
Data struct {
|
||||
UpsertDiscussion Item `json:"upsertDiscussion"`
|
||||
UpsertDiscussion ItemPaidAction `json:"upsertDiscussion"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type UpsertLinkResponse struct {
|
||||
Errors []GqlError `json:"errors"`
|
||||
Data struct {
|
||||
UpsertLink Item `json:"upsertLink"`
|
||||
UpsertLink ItemPaidAction `json:"upsertLink"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type CreateCommentsResponse struct {
|
||||
Errors []GqlError `json:"errors"`
|
||||
Data struct {
|
||||
CreateComment Comment `json:"createComment"`
|
||||
CreateComment ItemPaidAction `json:"createComment"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
@ -189,7 +195,7 @@ func (c *Client) PostDiscussion(title string, text string, sub string) (int, err
|
||||
Query: `
|
||||
mutation upsertDiscussion($title: String!, $text: String, $sub: String) {
|
||||
upsertDiscussion(title: $title, text: $text, sub: $sub) {
|
||||
id
|
||||
result { id }
|
||||
}
|
||||
}`,
|
||||
Variables: map[string]interface{}{
|
||||
@ -217,7 +223,7 @@ func (c *Client) PostDiscussion(title string, text string, sub string) (int, err
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return respBody.Data.UpsertDiscussion.Id, nil
|
||||
return respBody.Data.UpsertDiscussion.Result.Id, nil
|
||||
}
|
||||
|
||||
func (c *Client) PostLink(url string, title string, text string, sub string) (int, error) {
|
||||
@ -225,7 +231,7 @@ func (c *Client) PostLink(url string, title string, text string, sub string) (in
|
||||
Query: `
|
||||
mutation upsertLink($url: String!, $title: String!, $text: String, $sub: String!) {
|
||||
upsertLink(url: $url, title: $title, text: $text, sub: $sub) {
|
||||
id
|
||||
result { id }
|
||||
}
|
||||
}`,
|
||||
Variables: map[string]interface{}{
|
||||
@ -254,7 +260,7 @@ func (c *Client) PostLink(url string, title string, text string, sub string) (in
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return respBody.Data.UpsertLink.Id, nil
|
||||
return respBody.Data.UpsertLink.Result.Id, nil
|
||||
}
|
||||
|
||||
func (c *Client) CreateComment(parentId int, text string) (int, error) {
|
||||
@ -262,7 +268,7 @@ func (c *Client) CreateComment(parentId int, text string) (int, error) {
|
||||
Query: `
|
||||
mutation upsertComment($parentId: ID!, $text: String!) {
|
||||
upsertComment(parentId: $parentId, text: $text) {
|
||||
id
|
||||
result { id }
|
||||
}
|
||||
}`,
|
||||
Variables: map[string]interface{}{
|
||||
@ -289,7 +295,7 @@ func (c *Client) CreateComment(parentId int, text string) (int, error) {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
return respBody.Data.CreateComment.Id, nil
|
||||
return respBody.Data.CreateComment.Result.Id, nil
|
||||
}
|
||||
|
||||
func (c *Client) Dupes(url string) (*[]Dupe, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user