Compare commits
No commits in common. "develop" and "v0.5.2" have entirely different histories.
17
client.go
17
client.go
@ -13,7 +13,6 @@ type Client struct {
|
|||||||
BaseUrl string
|
BaseUrl string
|
||||||
ApiUrl string
|
ApiUrl string
|
||||||
ApiKey string
|
ApiKey string
|
||||||
MediaUrl string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(options ...func(*Client)) *Client {
|
func NewClient(options ...func(*Client)) *Client {
|
||||||
@ -23,22 +22,12 @@ func NewClient(options ...func(*Client)) *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set defaults
|
// set defaults
|
||||||
var ok bool
|
|
||||||
if c.BaseUrl == "" {
|
if c.BaseUrl == "" {
|
||||||
c.BaseUrl, ok = os.LookupEnv("SN_BASE_URL")
|
|
||||||
if !ok {
|
|
||||||
c.BaseUrl = "https://stacker.news"
|
c.BaseUrl = "https://stacker.news"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if c.ApiKey == "" {
|
if c.ApiKey == "" {
|
||||||
c.ApiKey = os.Getenv("SN_API_KEY")
|
c.ApiKey = os.Getenv("SN_API_KEY")
|
||||||
}
|
}
|
||||||
if c.MediaUrl == "" {
|
|
||||||
c.MediaUrl, ok = os.LookupEnv("SN_MEDIA_URL")
|
|
||||||
if !ok {
|
|
||||||
c.MediaUrl = "https://m.stacker.news"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.ApiUrl = fmt.Sprintf("%s/api/graphql", c.BaseUrl)
|
c.ApiUrl = fmt.Sprintf("%s/api/graphql", c.BaseUrl)
|
||||||
|
|
||||||
return c
|
return c
|
||||||
@ -56,12 +45,6 @@ func WithBaseUrl(baseUrl string) func(*Client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithMediaUrl(mediaUrl string) func(*Client) {
|
|
||||||
return func(c *Client) {
|
|
||||||
c.MediaUrl = mediaUrl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type GqlBody struct {
|
type GqlBody struct {
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
Variables map[string]interface{} `json:"variables,omitempty"`
|
Variables map[string]interface{} `json:"variables,omitempty"`
|
||||||
|
2
go.mod
2
go.mod
@ -1,5 +1,3 @@
|
|||||||
module github.com/ekzyis/snappy
|
module github.com/ekzyis/snappy
|
||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require gopkg.in/guregu/null.v4 v4.0.0 // indirect
|
|
||||||
|
2
go.sum
2
go.sum
@ -1,2 +0,0 @@
|
|||||||
gopkg.in/guregu/null.v4 v4.0.0 h1:1Wm3S1WEA2I26Kq+6vcW+w0gcDo44YKYD7YIEJNHDjg=
|
|
||||||
gopkg.in/guregu/null.v4 v4.0.0/go.mod h1:YoQhUrADuG3i9WqesrCmpNRwm1ypAgSHYqoOcTu/JrI=
|
|
125
items.go
125
items.go
@ -4,8 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/guregu/null.v4"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
@ -13,10 +11,8 @@ type Item struct {
|
|||||||
ParentId int `json:"parentId"`
|
ParentId int `json:"parentId"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Url string `json:"url"`
|
Url string `json:"url"`
|
||||||
Text string `json:"text"`
|
|
||||||
Sats int `json:"sats"`
|
Sats int `json:"sats"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
DeletedAt null.Time `json:"deletedAt"`
|
|
||||||
Comments []Comment `json:"comments"`
|
Comments []Comment `json:"comments"`
|
||||||
NComments int `json:"ncomments"`
|
NComments int `json:"ncomments"`
|
||||||
User User `json:"user"`
|
User User `json:"user"`
|
||||||
@ -121,17 +117,42 @@ func (c *Client) Item(id int) (*Item, error) {
|
|||||||
item(id: $id) {
|
item(id: $id) {
|
||||||
id
|
id
|
||||||
parentId
|
parentId
|
||||||
title
|
|
||||||
url
|
|
||||||
text
|
|
||||||
sats
|
|
||||||
createdAt
|
createdAt
|
||||||
deletedAt
|
deletedAt
|
||||||
ncomments
|
title
|
||||||
|
url
|
||||||
user {
|
user {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
otsHash
|
||||||
|
position
|
||||||
|
sats
|
||||||
|
boost
|
||||||
|
bounty
|
||||||
|
bountyPaidTo
|
||||||
|
path
|
||||||
|
upvotes
|
||||||
|
meSats
|
||||||
|
meDontLikeSats
|
||||||
|
meBookmark
|
||||||
|
meSubscription
|
||||||
|
outlawed
|
||||||
|
freebie
|
||||||
|
ncomments
|
||||||
|
commentSats
|
||||||
|
lastCommentAt
|
||||||
|
maxBid
|
||||||
|
isJob
|
||||||
|
company
|
||||||
|
location
|
||||||
|
remote
|
||||||
|
subName
|
||||||
|
pollCost
|
||||||
|
status
|
||||||
|
uploadId
|
||||||
|
mine
|
||||||
|
position
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
@ -172,17 +193,42 @@ func (c *Client) Items(query *ItemsQuery) (*ItemsCursor, error) {
|
|||||||
items {
|
items {
|
||||||
id
|
id
|
||||||
parentId
|
parentId
|
||||||
title
|
|
||||||
url
|
|
||||||
text
|
|
||||||
sats
|
|
||||||
createdAt
|
createdAt
|
||||||
deletedAt
|
deletedAt
|
||||||
ncomments
|
title
|
||||||
|
url
|
||||||
user {
|
user {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
|
otsHash
|
||||||
|
position
|
||||||
|
sats
|
||||||
|
boost
|
||||||
|
bounty
|
||||||
|
bountyPaidTo
|
||||||
|
path
|
||||||
|
upvotes
|
||||||
|
meSats
|
||||||
|
meDontLikeSats
|
||||||
|
meBookmark
|
||||||
|
meSubscription
|
||||||
|
outlawed
|
||||||
|
freebie
|
||||||
|
ncomments
|
||||||
|
commentSats
|
||||||
|
lastCommentAt
|
||||||
|
maxBid
|
||||||
|
isJob
|
||||||
|
company
|
||||||
|
location
|
||||||
|
remote
|
||||||
|
subName
|
||||||
|
pollCost
|
||||||
|
status
|
||||||
|
uploadId
|
||||||
|
mine
|
||||||
|
position
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
@ -226,17 +272,7 @@ func (c *Client) PostDiscussion(title string, text string, sub string) (int, err
|
|||||||
Query: `
|
Query: `
|
||||||
mutation upsertDiscussion($title: String!, $text: String, $sub: String) {
|
mutation upsertDiscussion($title: String!, $text: String, $sub: String) {
|
||||||
upsertDiscussion(title: $title, text: $text, sub: $sub) {
|
upsertDiscussion(title: $title, text: $text, sub: $sub) {
|
||||||
result {
|
result { id }
|
||||||
id
|
|
||||||
}
|
|
||||||
invoice {
|
|
||||||
id
|
|
||||||
hash
|
|
||||||
bolt11
|
|
||||||
satsRequested
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
paymentMethod
|
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
@ -264,11 +300,6 @@ func (c *Client) PostDiscussion(title string, text string, sub string) (int, err
|
|||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
inv := respBody.Data.UpsertDiscussion.Invoice
|
|
||||||
if inv.Id != 0 {
|
|
||||||
return -1, fmt.Errorf("mutation requires %d sats as payment", inv.SatsRequested)
|
|
||||||
}
|
|
||||||
|
|
||||||
return respBody.Data.UpsertDiscussion.Result.Id, nil
|
return respBody.Data.UpsertDiscussion.Result.Id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,17 +308,7 @@ func (c *Client) PostLink(url string, title string, text string, sub string) (in
|
|||||||
Query: `
|
Query: `
|
||||||
mutation upsertLink($url: String!, $title: String!, $text: String, $sub: String!) {
|
mutation upsertLink($url: String!, $title: String!, $text: String, $sub: String!) {
|
||||||
upsertLink(url: $url, title: $title, text: $text, sub: $sub) {
|
upsertLink(url: $url, title: $title, text: $text, sub: $sub) {
|
||||||
result {
|
result { id }
|
||||||
id
|
|
||||||
}
|
|
||||||
invoice {
|
|
||||||
id
|
|
||||||
hash
|
|
||||||
bolt11
|
|
||||||
satsRequested
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
paymentMethod
|
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
@ -316,11 +337,6 @@ func (c *Client) PostLink(url string, title string, text string, sub string) (in
|
|||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
inv := respBody.Data.UpsertLink.Invoice
|
|
||||||
if inv.Id != 0 {
|
|
||||||
return -1, fmt.Errorf("mutation requires %d sats as payment", inv.SatsRequested)
|
|
||||||
}
|
|
||||||
|
|
||||||
return respBody.Data.UpsertLink.Result.Id, nil
|
return respBody.Data.UpsertLink.Result.Id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,17 +345,7 @@ func (c *Client) CreateComment(parentId int, text string) (int, error) {
|
|||||||
Query: `
|
Query: `
|
||||||
mutation upsertComment($parentId: ID!, $text: String!) {
|
mutation upsertComment($parentId: ID!, $text: String!) {
|
||||||
upsertComment(parentId: $parentId, text: $text) {
|
upsertComment(parentId: $parentId, text: $text) {
|
||||||
result {
|
result { id }
|
||||||
id
|
|
||||||
}
|
|
||||||
invoice {
|
|
||||||
id
|
|
||||||
hash
|
|
||||||
bolt11
|
|
||||||
satsRequested
|
|
||||||
expiresAt
|
|
||||||
}
|
|
||||||
paymentMethod
|
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
Variables: map[string]interface{}{
|
Variables: map[string]interface{}{
|
||||||
@ -366,11 +372,6 @@ func (c *Client) CreateComment(parentId int, text string) (int, error) {
|
|||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
inv := respBody.Data.UpsertComment.Invoice
|
|
||||||
if inv.Id != 0 {
|
|
||||||
return -1, fmt.Errorf("mutation requires %d sats as payment", inv.SatsRequested)
|
|
||||||
}
|
|
||||||
|
|
||||||
return respBody.Data.UpsertComment.Result.Id, nil
|
return respBody.Data.UpsertComment.Result.Id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
125
notifications.go
125
notifications.go
@ -1,125 +0,0 @@
|
|||||||
package sn
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Notification struct {
|
|
||||||
Id int `json:"id,string"`
|
|
||||||
Type string `json:"__typename"`
|
|
||||||
Item Item `json:"item"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NotificationsCursor struct {
|
|
||||||
LastChecked time.Time `json:"lastChecked"`
|
|
||||||
Cursor string `json:"cursor"`
|
|
||||||
Notifications []Notification `json:"notifications"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NotificationsResponse struct {
|
|
||||||
Errors []GqlError `json:"errors"`
|
|
||||||
Data struct {
|
|
||||||
Notifications NotificationsCursor `json:"notifications"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) Notifications() (*NotificationsCursor, error) {
|
|
||||||
body := GqlBody{
|
|
||||||
Query: `
|
|
||||||
fragment ItemFields on Item {
|
|
||||||
id
|
|
||||||
user {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
parentId
|
|
||||||
createdAt
|
|
||||||
deletedAt
|
|
||||||
title
|
|
||||||
text
|
|
||||||
}
|
|
||||||
query notifications {
|
|
||||||
notifications {
|
|
||||||
lastChecked
|
|
||||||
cursor
|
|
||||||
notifications {
|
|
||||||
__typename
|
|
||||||
... on Reply {
|
|
||||||
id
|
|
||||||
item {
|
|
||||||
...ItemFields
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on Mention {
|
|
||||||
id
|
|
||||||
item {
|
|
||||||
...ItemFields
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
Variables: map[string]interface{}{},
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := c.callApi(body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
var respBody NotificationsResponse
|
|
||||||
err = json.NewDecoder(resp.Body).Decode(&respBody)
|
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("error decoding notifications: %w", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.checkForErrors(respBody.Errors)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &respBody.Data.Notifications, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) Mentions() ([]Notification, error) {
|
|
||||||
return c.filterNotifications(
|
|
||||||
func(n Notification) bool {
|
|
||||||
return n.Type == "Mention"
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) Replies() ([]Notification, error) {
|
|
||||||
return c.filterNotifications(
|
|
||||||
func(n Notification) bool {
|
|
||||||
return n.Type == "Reply"
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) filterNotifications(f func(Notification) bool) ([]Notification, error) {
|
|
||||||
var (
|
|
||||||
n *NotificationsCursor
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
if n, err = c.Notifications(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter(n.Notifications, f), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func filter[T any](s []T, f func(T) bool) []T {
|
|
||||||
var r []T
|
|
||||||
for _, v := range s {
|
|
||||||
if f(v) {
|
|
||||||
r = append(r, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r
|
|
||||||
}
|
|
131
upload.go
131
upload.go
@ -1,131 +0,0 @@
|
|||||||
package sn
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"image"
|
|
||||||
"image/png"
|
|
||||||
"io"
|
|
||||||
"mime/multipart"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GetSignedPOST struct {
|
|
||||||
Url string `json:"url"`
|
|
||||||
Fields map[string]string `json:"fields"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetSignedPOSTResponse struct {
|
|
||||||
Errors []GqlError `json:"errors"`
|
|
||||||
Data struct {
|
|
||||||
GetSignedPOST GetSignedPOST `json:"getSignedPOST"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UploadImage(img *image.RGBA) (string, error) {
|
|
||||||
var (
|
|
||||||
b = img.Bounds()
|
|
||||||
width = b.Dx()
|
|
||||||
height = b.Dy()
|
|
||||||
type_ = "image/png"
|
|
||||||
size int
|
|
||||||
)
|
|
||||||
|
|
||||||
var imgBuf bytes.Buffer
|
|
||||||
if err := png.Encode(&imgBuf, img); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
size = imgBuf.Len()
|
|
||||||
|
|
||||||
// get signed URL for S3 upload
|
|
||||||
body := GqlBody{
|
|
||||||
Query: `
|
|
||||||
mutation getSignedPOST($type: String!, $size: Int!, $width: Int!, $height: Int!, $avatar: Boolean) {
|
|
||||||
getSignedPOST(type: $type, size: $size, width: $width, height: $height, avatar: $avatar) {
|
|
||||||
url
|
|
||||||
fields
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
Variables: map[string]interface{}{
|
|
||||||
"type": type_,
|
|
||||||
"size": size,
|
|
||||||
"width": width,
|
|
||||||
"height": height,
|
|
||||||
"avatar": false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := c.callApi(body)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
var respBody GetSignedPOSTResponse
|
|
||||||
err = json.NewDecoder(resp.Body).Decode(&respBody)
|
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("error decoding getSignedPOST: %w", err)
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.checkForErrors(respBody.Errors)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
s3Url := respBody.Data.GetSignedPOST.Url
|
|
||||||
fields := respBody.Data.GetSignedPOST.Fields
|
|
||||||
|
|
||||||
// create multipart form
|
|
||||||
var (
|
|
||||||
buf bytes.Buffer
|
|
||||||
w = multipart.NewWriter(&buf)
|
|
||||||
fw io.Writer
|
|
||||||
)
|
|
||||||
|
|
||||||
for k, v := range fields {
|
|
||||||
if fw, err = w.CreateFormField(k); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
fw.Write([]byte(v))
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v := range map[string]string{
|
|
||||||
"Content-Type": type_,
|
|
||||||
"Cache-Control": "max-age=31536000",
|
|
||||||
"acl": "public-read",
|
|
||||||
} {
|
|
||||||
if fw, err = w.CreateFormField(k); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
fw.Write([]byte(v))
|
|
||||||
}
|
|
||||||
|
|
||||||
if fw, err = w.CreateFormFile("file", "image.png"); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
fw.Write(imgBuf.Bytes())
|
|
||||||
|
|
||||||
if err = w.Close(); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
// upload to S3
|
|
||||||
var req *http.Request
|
|
||||||
if req, err = http.NewRequest("POST", s3Url, &buf); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", w.FormDataContentType())
|
|
||||||
|
|
||||||
client := http.DefaultClient
|
|
||||||
if resp, err = client.Do(req); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
imgId := respBody.Data.GetSignedPOST.Fields["key"]
|
|
||||||
imgUrl := fmt.Sprintf("%s/%s", c.MediaUrl, imgId)
|
|
||||||
|
|
||||||
return imgUrl, nil
|
|
||||||
}
|
|
51
user.go
51
user.go
@ -1,57 +1,6 @@
|
|||||||
package sn
|
package sn
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Id int `json:"id,string"`
|
Id int `json:"id,string"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Privates UserPrivates `json:"privates"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserPrivates struct {
|
|
||||||
Sats int `json:"sats"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MeResponse struct {
|
|
||||||
Errors []GqlError `json:"errors"`
|
|
||||||
Data struct {
|
|
||||||
Me User `json:"me"`
|
|
||||||
} `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) Me() (*User, error) {
|
|
||||||
body := GqlBody{
|
|
||||||
Query: `
|
|
||||||
query me {
|
|
||||||
me {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
privates {
|
|
||||||
sats
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := c.callApi(body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
var respBody MeResponse
|
|
||||||
err = json.NewDecoder(resp.Body).Decode(&respBody)
|
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("error decoding me: %w", err)
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.checkForErrors(respBody.Errors)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &respBody.Data.Me, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user