feat: added first implementations of the high level api, reworked some stuff & more

Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
SoXX 2023-10-24 15:10:39 +02:00
parent 501dddc1c6
commit 5f1cba1b71
55 changed files with 303 additions and 124 deletions

View File

@ -2,6 +2,13 @@
An unofficial e621 SDK (Client) library to interact with **e621**, **e923** and **e6ai**. Maintained by the Anthrove Development Team.
- Caching?
- Auto pagination
- sync
- async
- connected/inelegant calls
- more docs
# Completeness
_Legend_

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"
@ -23,7 +23,7 @@ func main() {
log.Println("Getting single post: ")
// Specify the post ID for retrieval.
postID := 4353480 // Replace with the desired post's ID.
var postID model.PostID = 4353480 // Replace with the desired post's ID.
// Call the GetPost function to retrieve the specified post.
getPost := builder.NewGetPostBuilder(requestContext)

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

View File

@ -1,8 +1,8 @@
package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
_ "github.com/joho/godotenv/autoload"
"log"
"net/http"

7
go.mod
View File

@ -1,4 +1,4 @@
module git.dragse.it/anthrove/e621-to-graph
module git.dragse.it/anthrove/e621-sdk-go
go 1.21.3
@ -6,3 +6,8 @@ require (
github.com/jarcoal/httpmock v1.3.1
github.com/joho/godotenv v1.5.1
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
golang.org/x/time v0.3.0 // indirect
)

2
go.sum
View File

@ -6,3 +6,5 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

View File

@ -1 +0,0 @@
package internal

View File

@ -1 +1,4 @@
package e621_sdk_go
package main
func main() {
}

View File

@ -1,13 +1,14 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
type FavoritesBuilder interface {
SetUserID(userID int) FavoritesBuilder
SetUserID(userID model.UserID) FavoritesBuilder
SetLimit(limitFavorites int) FavoritesBuilder
Execute() ([]model.Post, error)
}
@ -24,8 +25,8 @@ type getFavorites struct {
requestContext model.RequestContext
}
func (g getFavorites) SetUserID(userID int) FavoritesBuilder {
g.query["user_id"] = strconv.Itoa(userID)
func (g getFavorites) SetUserID(userID model.UserID) FavoritesBuilder {
g.query["user_id"] = strconv.Itoa(int(userID))
return g
}
@ -35,6 +36,12 @@ func (g getFavorites) SetLimit(limitFavorites int) FavoritesBuilder {
}
func (g getFavorites) Execute() ([]model.Post, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
favorites, err := endpoints.GetFavorites(g.requestContext, g.query)
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -27,6 +28,12 @@ func (g *getNote) SetNoteID(noteID int) NoteBuilder {
}
func (g *getNote) Execute() (*model.Note, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
note, err := endpoints.GetNote(g.requestContext, strconv.Itoa(g.noteID))
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -65,6 +66,12 @@ func (g getNotes) SetLimit(limitNotes int) NotesBuilder {
}
func (g getNotes) Execute() ([]model.Note, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
notes, err := endpoints.GetNotes(g.requestContext, g.query)
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -26,6 +27,12 @@ func (g getPool) ID(poolID int) PoolBuilder {
}
func (g getPool) Execute() (model.Pool, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return model.Pool{}, err
}
}
pool, err := endpoints.GetPool(g.requestContext, strconv.Itoa(g.id))
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -77,6 +78,12 @@ func (g *getPools) SetLimit(limitUser int) PoolsBuilder {
}
func (g *getPools) Execute() ([]model.Pool, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
pools, err := endpoints.GetPools(g.requestContext, g.query)
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,13 +1,14 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
type PostBuilder interface {
SetPostID(postID int) PostBuilder
SetPostID(postID model.PostID) PostBuilder
Execute() (*model.Post, error)
}
@ -17,16 +18,22 @@ func NewGetPostBuilder(requestContext model.RequestContext) PostBuilder {
type getPost struct {
requestContext model.RequestContext
postID int
postID model.PostID
}
func (g *getPost) SetPostID(postID int) PostBuilder {
func (g *getPost) SetPostID(postID model.PostID) PostBuilder {
g.postID = postID
return g
}
func (g *getPost) Execute() (*model.Post, error) {
post, err := endpoints.GetPost(g.requestContext, strconv.Itoa(g.postID))
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
post, err := endpoints.GetPost(g.requestContext, strconv.Itoa(int(g.postID)))
if err != nil {
return nil, err

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -47,6 +48,12 @@ func (g *getPosts) SetLimit(limitUser int) PostsBuilder {
}
func (g *getPosts) Execute() ([]model.Post, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
posts, err := endpoints.GetPosts(g.requestContext, g.query)
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -26,6 +27,12 @@ func (g *getTag) SetTagID(tagID int) TagBuilder {
}
func (g *getTag) Execute() (model.Tag, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return model.Tag{}, err
}
}
tag, err := endpoints.GetTag(g.requestContext, strconv.Itoa(g.tagID))
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,8 +1,9 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
@ -68,6 +69,12 @@ func (g *getTags) SetLimit(limitUser int) TagsBuilder {
}
func (g *getTags) Execute() ([]model.Tag, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
tags, err := endpoints.GetTags(g.requestContext, g.query)
if err != nil {

View File

@ -1,13 +1,14 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
)
type UserBuilder interface {
SetUsername(username string) UserBuilder
Execute() (*model.User, error)
Execute() (model.User, error)
}
func NewGetUserBuilder(requestContext model.RequestContext) UserBuilder {
@ -24,11 +25,17 @@ func (g *getUser) SetUsername(username string) UserBuilder {
return g
}
func (g *getUser) Execute() (*model.User, error) {
func (g *getUser) Execute() (model.User, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return model.User{}, err
}
}
user, err := endpoints.GetUser(g.requestContext, g.username)
if err != nil {
return nil, err
return model.User{}, err
}
return &user, nil
return user, nil
}

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,14 +1,24 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"context"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"strconv"
)
type UsersBuilder interface {
SetPage(pageNumber int) UsersBuilder
SetLimit(limitUser int) UsersBuilder
SearchByName(userName string) UsersBuilder
SearchByAbout(about string) UsersBuilder
SearchByAvatarID(postID model.PostID) UsersBuilder
SearchByLevel(level model.UserLevel) UsersBuilder
SearchByMinLevel(level model.UserLevel) UsersBuilder
SearchByMaxLevellevel(model.UserLevel) UsersBuilder
searchByCanUpload(canUpload bool) UsersBuilder
SearchByIsApprover(isApprover bool) UsersBuilder
SearchByOrder(order model.Order) UsersBuilder
Execute() ([]model.User, error)
}
@ -21,6 +31,51 @@ type getUsers struct {
query map[string]string
}
func (g *getUsers) SearchByName(userName string) UsersBuilder {
g.query["search[name_matches]"] = userName
return g
}
func (g *getUsers) SearchByAbout(about string) UsersBuilder {
g.query["search[about_me"] = about
return g
}
func (g *getUsers) SearchByAvatarID(postID model.PostID) UsersBuilder {
g.query["search[avatar_id]"] = strconv.FormatInt(int64(postID), 10)
return g
}
func (g *getUsers) SearchByLevel(level model.UserLevel) UsersBuilder {
g.query["search[level]"] = strconv.Itoa(int(level))
return g
}
func (g *getUsers) SearchByMinLevel(level model.UserLevel) UsersBuilder {
g.query["search[min_level"] = strconv.Itoa(int(level))
return g
}
func (g *getUsers) SearchByMaxLevellevel(level model.UserLevel) UsersBuilder {
g.query["search[max_level]"] = strconv.Itoa(int(level))
return g
}
func (g *getUsers) searchByCanUpload(canUpload bool) UsersBuilder {
g.query["search[can_upload_free]"] = strconv.FormatBool(canUpload)
return g
}
func (g *getUsers) SearchByIsApprover(isApprover bool) UsersBuilder {
g.query["search[can_approve_posts]"] = strconv.FormatBool(isApprover)
return g
}
func (g *getUsers) SearchByOrder(order model.Order) UsersBuilder {
g.query["search[order]"] = string(order)
return g
}
func (g *getUsers) SetPage(pageNumber int) UsersBuilder {
g.query["page"] = strconv.Itoa(pageNumber)
return g
@ -32,6 +87,12 @@ func (g *getUsers) SetLimit(limitUser int) UsersBuilder {
}
func (g *getUsers) Execute() ([]model.User, error) {
if g.requestContext.RateLimiter != nil {
err := g.requestContext.RateLimiter.Wait(context.Background())
if err != nil {
return nil, err
}
}
users, err := endpoints.GetUsers(g.requestContext, g.query)
if err != nil {

View File

@ -1,7 +1,7 @@
package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -3,8 +3,8 @@ package endpoints
import (
"encoding/json"
"fmt"
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"log"
"net/http"
)

View File

@ -1,7 +1,7 @@
package endpoints
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -3,8 +3,8 @@ package endpoints
import (
"encoding/json"
"fmt"
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"io"
"log"
"net/http"

View File

@ -1,7 +1,7 @@
package endpoints
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -3,8 +3,8 @@ package endpoints
import (
"encoding/json"
"fmt"
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"log"
"net/http"
)

View File

@ -1,7 +1,7 @@
package endpoints
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -3,8 +3,8 @@ package endpoints
import (
"encoding/json"
"fmt"
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"log"
"net/http"
)

View File

@ -1,7 +1,7 @@
package endpoints
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -3,8 +3,8 @@ package endpoints
import (
"encoding/json"
"fmt"
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"log"
"net/http"
)

View File

@ -1,7 +1,7 @@
package endpoints
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -3,8 +3,8 @@ package endpoints
import (
"encoding/json"
"fmt"
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"log"
"net/http"
)

View File

@ -1,7 +1,7 @@
package endpoints
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"

View File

@ -1,9 +1,13 @@
package model
import "net/http"
import (
"golang.org/x/time/rate"
"net/http"
)
type RequestContext struct {
Client http.Client
RateLimiter *rate.Limiter
Host string
UserAgent string
Username string

View File

@ -6,7 +6,10 @@ type PoolOrder string
const (
Series PoolCategory = "series"
Collection PoolCategory = "collection"
Name PoolOrder = "name"
)
const (
PoolName PoolOrder = "name"
CreatedAt PoolOrder = "created_at"
UpdatedAt PoolOrder = "updated_at"
PostCount PoolOrder = "post_count"

View File

@ -1,12 +1,14 @@
package model
type PostID int64
type PostResponse struct {
Post Post `json:"post"`
Posts []Post `json:"posts"`
}
type Post struct {
ID int64 `json:"id"`
ID PostID `json:"id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
File File `json:"file"`

View File

@ -1,5 +1,28 @@
package model
type UserID int64
type UserLevel int
type Order string
const (
Anonymus UserLevel = 0
Blocked UserLevel = 10
Member UserLevel = 20
Privilaged UserLevel = 30
FormerStaff UserLevel = 34
Janitor UserLevel = 35
Moderator UserLevel = 40
Admin UserLevel = 50
)
const (
JoinDate Order = "date"
UserName Order = "name"
PostUploadCount Order = "post_upload_count"
NoteCount Order = "note_count"
PostUpdateCount Order = "post_upload_count"
)
type User struct {
WikiPageVersionCount int64 `json:"wiki_page_version_count"`
ArtistVersionCount int64 `json:"artist_version_count"`
@ -12,10 +35,10 @@ type User struct {
NeutralFeedbackCount int64 `json:"neutral_feedback_count"`
NegativeFeedbackCount int64 `json:"negative_feedback_count"`
UploadLimit int64 `json:"upload_limit"`
ID int64 `json:"id"`
ID UserID `json:"id"`
CreatedAt string `json:"created_at"`
Name string `json:"name"`
Level int64 `json:"level"`
Level UserLevel `json:"level"`
BaseUploadLimit int64 `json:"base_upload_limit"`
PostUploadCount int64 `json:"post_upload_count"`
PostUpdateCount int64 `json:"post_update_count"`
@ -24,5 +47,5 @@ type User struct {
CanApprovePosts bool `json:"can_approve_posts"`
CanUploadFree bool `json:"can_upload_free"`
LevelString string `json:"level_string"`
AvatarID interface{} `json:"avatar_id"`
AvatarID PostID `json:"avatar_id"`
}