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:
parent
501dddc1c6
commit
5f1cba1b71
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
An unofficial e621 SDK (Client) library to interact with **e621**, **e923** and **e6ai**. Maintained by the Anthrove Development Team.
|
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
|
# Completeness
|
||||||
|
|
||||||
_Legend_
|
_Legend_
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -23,7 +23,7 @@ func main() {
|
|||||||
log.Println("Getting single post: ")
|
log.Println("Getting single post: ")
|
||||||
|
|
||||||
// Specify the post ID for retrieval.
|
// 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.
|
// Call the GetPost function to retrieve the specified post.
|
||||||
getPost := builder.NewGetPostBuilder(requestContext)
|
getPost := builder.NewGetPostBuilder(requestContext)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/builder"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/builder"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
7
go.mod
7
go.mod
@ -1,4 +1,4 @@
|
|||||||
module git.dragse.it/anthrove/e621-to-graph
|
module git.dragse.it/anthrove/e621-sdk-go
|
||||||
|
|
||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
||||||
@ -6,3 +6,8 @@ require (
|
|||||||
github.com/jarcoal/httpmock v1.3.1
|
github.com/jarcoal/httpmock v1.3.1
|
||||||
github.com/joho/godotenv v1.5.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
2
go.sum
@ -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/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 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g=
|
||||||
github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM=
|
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=
|
||||||
|
@ -1 +0,0 @@
|
|||||||
package internal
|
|
@ -1,13 +1,14 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FavoritesBuilder interface {
|
type FavoritesBuilder interface {
|
||||||
SetUserID(userID int) FavoritesBuilder
|
SetUserID(userID model.UserID) FavoritesBuilder
|
||||||
SetLimit(limitFavorites int) FavoritesBuilder
|
SetLimit(limitFavorites int) FavoritesBuilder
|
||||||
Execute() ([]model.Post, error)
|
Execute() ([]model.Post, error)
|
||||||
}
|
}
|
||||||
@ -24,8 +25,8 @@ type getFavorites struct {
|
|||||||
requestContext model.RequestContext
|
requestContext model.RequestContext
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g getFavorites) SetUserID(userID int) FavoritesBuilder {
|
func (g getFavorites) SetUserID(userID model.UserID) FavoritesBuilder {
|
||||||
g.query["user_id"] = strconv.Itoa(userID)
|
g.query["user_id"] = strconv.Itoa(int(userID))
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +36,12 @@ func (g getFavorites) SetLimit(limitFavorites int) FavoritesBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g getFavorites) Execute() ([]model.Post, error) {
|
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)
|
favorites, err := endpoints.GetFavorites(g.requestContext, g.query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,6 +28,12 @@ func (g *getNote) SetNoteID(noteID int) NoteBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *getNote) Execute() (*model.Note, error) {
|
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))
|
note, err := endpoints.GetNote(g.requestContext, strconv.Itoa(g.noteID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -65,6 +66,12 @@ func (g getNotes) SetLimit(limitNotes int) NotesBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g getNotes) Execute() ([]model.Note, error) {
|
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)
|
notes, err := endpoints.GetNotes(g.requestContext, g.query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,6 +27,12 @@ func (g getPool) ID(poolID int) PoolBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g getPool) Execute() (model.Pool, error) {
|
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))
|
pool, err := endpoints.GetPool(g.requestContext, strconv.Itoa(g.id))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,6 +78,12 @@ func (g *getPools) SetLimit(limitUser int) PoolsBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *getPools) Execute() ([]model.Pool, error) {
|
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)
|
pools, err := endpoints.GetPools(g.requestContext, g.query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PostBuilder interface {
|
type PostBuilder interface {
|
||||||
SetPostID(postID int) PostBuilder
|
SetPostID(postID model.PostID) PostBuilder
|
||||||
Execute() (*model.Post, error)
|
Execute() (*model.Post, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,16 +18,22 @@ func NewGetPostBuilder(requestContext model.RequestContext) PostBuilder {
|
|||||||
|
|
||||||
type getPost struct {
|
type getPost struct {
|
||||||
requestContext model.RequestContext
|
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
|
g.postID = postID
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *getPost) Execute() (*model.Post, error) {
|
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 {
|
if err != nil {
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,6 +48,12 @@ func (g *getPosts) SetLimit(limitUser int) PostsBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *getPosts) Execute() ([]model.Post, error) {
|
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)
|
posts, err := endpoints.GetPosts(g.requestContext, g.query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -26,6 +27,12 @@ func (g *getTag) SetTagID(tagID int) TagBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *getTag) Execute() (model.Tag, error) {
|
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))
|
tag, err := endpoints.GetTag(g.requestContext, strconv.Itoa(g.tagID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,6 +69,12 @@ func (g *getTags) SetLimit(limitUser int) TagsBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *getTags) Execute() ([]model.Tag, error) {
|
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)
|
tags, err := endpoints.GetTags(g.requestContext, g.query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserBuilder interface {
|
type UserBuilder interface {
|
||||||
SetUsername(username string) UserBuilder
|
SetUsername(username string) UserBuilder
|
||||||
Execute() (*model.User, error)
|
Execute() (model.User, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGetUserBuilder(requestContext model.RequestContext) UserBuilder {
|
func NewGetUserBuilder(requestContext model.RequestContext) UserBuilder {
|
||||||
@ -24,11 +25,17 @@ func (g *getUser) SetUsername(username string) UserBuilder {
|
|||||||
return g
|
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)
|
user, err := endpoints.GetUser(g.requestContext, g.username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return nil, err
|
return model.User{}, err
|
||||||
}
|
}
|
||||||
return &user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
|
"context"
|
||||||
"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"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UsersBuilder interface {
|
type UsersBuilder interface {
|
||||||
SetPage(pageNumber int) UsersBuilder
|
SetPage(pageNumber int) UsersBuilder
|
||||||
SetLimit(limitUser 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)
|
Execute() ([]model.User, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +31,51 @@ type getUsers struct {
|
|||||||
query map[string]string
|
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 {
|
func (g *getUsers) SetPage(pageNumber int) UsersBuilder {
|
||||||
g.query["page"] = strconv.Itoa(pageNumber)
|
g.query["page"] = strconv.Itoa(pageNumber)
|
||||||
return g
|
return g
|
||||||
@ -32,6 +87,12 @@ func (g *getUsers) SetLimit(limitUser int) UsersBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *getUsers) Execute() ([]model.User, error) {
|
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)
|
users, err := endpoints.GetUsers(g.requestContext, g.query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package builder
|
package builder
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,8 +3,8 @@ package endpoints
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,8 +3,8 @@ package endpoints
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,8 +3,8 @@ package endpoints
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,8 +3,8 @@ package endpoints
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,8 +3,8 @@ package endpoints
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -3,8 +3,8 @@ package endpoints
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/internal/utils"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
|
||||||
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
|
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package endpoints
|
package endpoints
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/jarcoal/httpmock"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"golang.org/x/time/rate"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
type RequestContext struct {
|
type RequestContext struct {
|
||||||
Client http.Client
|
Client http.Client
|
||||||
Host string
|
RateLimiter *rate.Limiter
|
||||||
UserAgent string
|
Host string
|
||||||
Username string
|
UserAgent string
|
||||||
APIKey string
|
Username string
|
||||||
|
APIKey string
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,13 @@ type PoolOrder string
|
|||||||
const (
|
const (
|
||||||
Series PoolCategory = "series"
|
Series PoolCategory = "series"
|
||||||
Collection PoolCategory = "collection"
|
Collection PoolCategory = "collection"
|
||||||
Name PoolOrder = "name"
|
)
|
||||||
CreatedAt PoolOrder = "created_at"
|
|
||||||
UpdatedAt PoolOrder = "updated_at"
|
const (
|
||||||
PostCount PoolOrder = "post_count"
|
PoolName PoolOrder = "name"
|
||||||
|
CreatedAt PoolOrder = "created_at"
|
||||||
|
UpdatedAt PoolOrder = "updated_at"
|
||||||
|
PostCount PoolOrder = "post_count"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
type PostID int64
|
||||||
|
|
||||||
type PostResponse struct {
|
type PostResponse struct {
|
||||||
Post Post `json:"post"`
|
Post Post `json:"post"`
|
||||||
Posts []Post `json:"posts"`
|
Posts []Post `json:"posts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Post struct {
|
type Post struct {
|
||||||
ID int64 `json:"id"`
|
ID PostID `json:"id"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
UpdatedAt string `json:"updated_at"`
|
UpdatedAt string `json:"updated_at"`
|
||||||
File File `json:"file"`
|
File File `json:"file"`
|
||||||
|
@ -1,28 +1,51 @@
|
|||||||
package model
|
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 {
|
type User struct {
|
||||||
WikiPageVersionCount int64 `json:"wiki_page_version_count"`
|
WikiPageVersionCount int64 `json:"wiki_page_version_count"`
|
||||||
ArtistVersionCount int64 `json:"artist_version_count"`
|
ArtistVersionCount int64 `json:"artist_version_count"`
|
||||||
PoolVersionCount int64 `json:"pool_version_count"`
|
PoolVersionCount int64 `json:"pool_version_count"`
|
||||||
ForumPostCount int64 `json:"forum_post_count"`
|
ForumPostCount int64 `json:"forum_post_count"`
|
||||||
CommentCount int64 `json:"comment_count"`
|
CommentCount int64 `json:"comment_count"`
|
||||||
FlagCount int64 `json:"flag_count"`
|
FlagCount int64 `json:"flag_count"`
|
||||||
FavoriteCount int64 `json:"favorite_count"`
|
FavoriteCount int64 `json:"favorite_count"`
|
||||||
PositiveFeedbackCount int64 `json:"positive_feedback_count"`
|
PositiveFeedbackCount int64 `json:"positive_feedback_count"`
|
||||||
NeutralFeedbackCount int64 `json:"neutral_feedback_count"`
|
NeutralFeedbackCount int64 `json:"neutral_feedback_count"`
|
||||||
NegativeFeedbackCount int64 `json:"negative_feedback_count"`
|
NegativeFeedbackCount int64 `json:"negative_feedback_count"`
|
||||||
UploadLimit int64 `json:"upload_limit"`
|
UploadLimit int64 `json:"upload_limit"`
|
||||||
ID int64 `json:"id"`
|
ID UserID `json:"id"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt string `json:"created_at"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Level int64 `json:"level"`
|
Level UserLevel `json:"level"`
|
||||||
BaseUploadLimit int64 `json:"base_upload_limit"`
|
BaseUploadLimit int64 `json:"base_upload_limit"`
|
||||||
PostUploadCount int64 `json:"post_upload_count"`
|
PostUploadCount int64 `json:"post_upload_count"`
|
||||||
PostUpdateCount int64 `json:"post_update_count"`
|
PostUpdateCount int64 `json:"post_update_count"`
|
||||||
NoteUpdateCount int64 `json:"note_update_count"`
|
NoteUpdateCount int64 `json:"note_update_count"`
|
||||||
IsBanned bool `json:"is_banned"`
|
IsBanned bool `json:"is_banned"`
|
||||||
CanApprovePosts bool `json:"can_approve_posts"`
|
CanApprovePosts bool `json:"can_approve_posts"`
|
||||||
CanUploadFree bool `json:"can_upload_free"`
|
CanUploadFree bool `json:"can_upload_free"`
|
||||||
LevelString string `json:"level_string"`
|
LevelString string `json:"level_string"`
|
||||||
AvatarID interface{} `json:"avatar_id"`
|
AvatarID PostID `json:"avatar_id"`
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user