fanbox

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleBody

type ArticleBody struct {
	Blocks []struct {
		Type    string `json:"type"`
		Text    string `json:"text,omitempty"`
		ImageID string `json:"imageId,omitempty"`
	} `json:"blocks"`
	ImageMap map[string]PostImage `json:"imageMap"`
}

func (*ArticleBody) ToPostImages

func (body *ArticleBody) ToPostImages(log logrus.FieldLogger) []PostImage

type Client

type Client struct {
	// Token from cookie key FANBOXSESSID
	Token string
	// contains filtered or unexported fields
}

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

HTTPClient returns a non-nil http client pointer.

If the field `httpClient` is not nil, this will return that field. Otherwise, this function will initialize a new http client and store it to `httpClient` field. Then return the client.

The return http client will populate headers (user agent, referrer, etc) and cookies (authentication token) automatically.

func (*Client) ListCreatorPost

func (c *Client) ListCreatorPost(log logrus.FieldLogger, creatorid string) ([]Post, error)

ListCreatorPost fetch all posts from the given creator ID

func (*Client) ListImages added in v1.1.0

func (c *Client) ListImages(ctx context.Context, log logrus.FieldLogger, post *Post) ([]PostImage, error)

ListImages lists the images found in this post

type FileBody

type FileBody struct{}

func (*FileBody) ToPostImages

func (body *FileBody) ToPostImages(log logrus.FieldLogger) []PostImage

type ImageBody

type ImageBody struct {
	Text   string      `json:"text"`
	Images []PostImage `json:"images"`
}

func (*ImageBody) ToPostImages

func (body *ImageBody) ToPostImages(log logrus.FieldLogger) []PostImage

type ListCreatorPostResponse

type ListCreatorPostResponse struct {
	Body struct {
		Items []struct {
			ID                string    `json:"id"`
			Title             string    `json:"title"`
			CoverImageURL     string    `json:"coverImageUrl"`
			FeeRequired       int       `json:"feeRequired"`
			PublishedDatetime time.Time `json:"publishedDatetime"`
			UpdatedDatetime   time.Time `json:"updatedDatetime"`
			IsRestricted      bool      `json:"isRestricted"`
			CreatorID         string    `json:"creatorId"`
			HasAdultContent   bool      `json:"hasAdultContent"`
		} `json:"items"`
		NextURL string `json:"nextUrl,omitempty"`
	} `json:"body"`
}

type Post

type Post struct {
	ID                string
	Title             string
	CreatorID         string
	PublishedDatetime time.Time
	UpdatedDatetime   time.Time

	// If true, user has no permission to view this post
	IsRestricted bool
}

type PostBody

type PostBody interface {
	ToPostImages(log logrus.FieldLogger) []PostImage
}

type PostImage

type PostImage struct {
	ID           string `json:"id"` // Adding JSON tags here to reuse them in unmarshal
	Extension    string `json:"extension"`
	Width        int    `json:"width"`
	Height       int    `json:"height"`
	OriginalURL  string `json:"originalUrl"`
	ThumbnailURL string `json:"thumbnailUrl"`
}

type PostInfoResponse added in v1.1.0

type PostInfoResponse struct {
	Body struct {
		ID                string           `json:"id"`
		Title             string           `json:"title"`
		CoverImageURL     string           `json:"coverImageUrl"`
		FeeRequired       int              `json:"feeRequired"`
		PublishedDatetime time.Time        `json:"publishedDatetime"`
		UpdatedDatetime   time.Time        `json:"updatedDatetime"`
		Type              string           `json:"type"`
		Body              *json.RawMessage `json:"body"`
		Excerpt           string           `json:"excerpt"`
		IsRestricted      bool             `json:"isRestricted"`
		CreatorID         string           `json:"creatorId"`
		HasAdultContent   bool             `json:"hasAdultContent"`
	} `json:"body"`
}

type TextBody

type TextBody struct {
	Text string `json:"text"`
}

func (*TextBody) ToPostImages

func (body *TextBody) ToPostImages(log logrus.FieldLogger) []PostImage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL