api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const StoriesBaseURL = "/s"
View Source
const TagsBaseURL = "/tags"

Variables

This section is empty.

Functions

func NewStdLogger

func NewStdLogger(l Logger) retryablehttp.Logger

Types

type Client

type Client struct {
	Stories StoriesService
	Tags    TagsService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cc *ClientConfig) *Client

func (*Client) Do

func (c *Client) Do(
	ctx context.Context,
	req *http.Request,
	content interface{},
) error

func (*Client) NewRequest

func (c *Client) NewRequest(
	ctx context.Context,
	method string,
	location string,
	body interface{},
) (*http.Request, error)

type ClientConfig

type ClientConfig struct {
	Endpoint    string
	Credentials map[string]string
	HTTPClient  *http.Client
	Logger      Logger
}

func NewDefaultClientConfig

func NewDefaultClientConfig(
	endpoint string,
	proxy string,
	credentials map[string]string,
	logger Logger,
) ClientConfig

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

type RequestError

type RequestError struct {
	Err error
}

func (*RequestError) Error

func (re *RequestError) Error() string

type StdLogger

type StdLogger struct {
	L Logger
}

func (*StdLogger) Printf

func (l *StdLogger) Printf(message string, v ...interface{})

type StoriesService

type StoriesService interface {
	Show(
		ctx context.Context,
		id string,
	) (*StoryModel, error)
	List(
		ctx context.Context,
		tag string,
	) (*[]StoryModel, error)
}

type StoryModel

type StoryModel struct {
	ShortID          string    `json:"short_id"`
	ShortIDURL       string    `json:"short_id_url"`
	CreatedAt        string    `json:"created_at"`
	Title            string    `json:"title"`
	URL              string    `json:"url"`
	Score            int       `json:"score"`
	Flags            int       `json:"flags"`
	CommentCount     int       `json:"comment_count"`
	Description      string    `json:"description"`
	DescriptionPlain string    `json:"description_plain"`
	CommentsURL      string    `json:"comments_url"`
	CategoryID       int       `json:"category_id"`
	SubmitterUser    UserModel `json:"submitter_user"`
	Tags             []string  `json:"tags"`
	Comments         []struct {
		ShortID        string    `json:"short_id"`
		ShortIDURL     string    `json:"short_id_url"`
		CreatedAt      string    `json:"created_at"`
		UpdatedAt      string    `json:"updated_at"`
		IsDeleted      bool      `json:"is_deleted"`
		IsModerated    bool      `json:"is_moderated"`
		Score          int       `json:"score"`
		Flags          int       `json:"flags"`
		ParentComment  string    `json:"parent_comment"`
		Comment        string    `json:"comment"`
		CommentPlain   string    `json:"comment_plain"`
		CommentsURL    string    `json:"comments_url"`
		URL            string    `json:"url"`
		IndentLevel    int       `json:"indent_level"`
		CommentingUser UserModel `json:"commenting_user"`
	} `json:"comments"`
}

type StoryServiceHandler

type StoryServiceHandler struct {
	// contains filtered or unexported fields
}

func (*StoryServiceHandler) List

func (a *StoryServiceHandler) List(
	ctx context.Context,
	tag string,
) (*[]StoryModel, error)

List

func (*StoryServiceHandler) Show

func (a *StoryServiceHandler) Show(
	ctx context.Context,
	id string,
) (*StoryModel, error)

Show

type TagModel

type TagModel struct {
	ID               int     `json:"id"`
	Tag              string  `json:"tag"`
	Description      string  `json:"description"`
	Privileged       bool    `json:"privileged"`
	IsMedia          bool    `json:"is_media"`
	Active           bool    `json:"active"`
	HotnessMod       float32 `json:"hotness_mod"`
	PermitByNewUsers bool    `json:"permit_by_new_users"`
	CategoryID       int     `json:"category_id"`
}

type TagServiceHandler

type TagServiceHandler struct {
	// contains filtered or unexported fields
}

func (*TagServiceHandler) List

func (a *TagServiceHandler) List(
	ctx context.Context,
) (*[]TagModel, error)

List

type TagsService

type TagsService interface {
	List(
		ctx context.Context,
	) (*[]TagModel, error)
}

type UserModel

type UserModel struct {
	Username        string `json:"username"`
	CreatedAt       string `json:"created_at"`
	IsAdmin         bool   `json:"is_admin"`
	About           string `json:"about"`
	IsModerator     bool   `json:"is_moderator"`
	Karma           int    `json:"karma"`
	AvatarURL       string `json:"avatar_url"`
	InvitedByUser   string `json:"invited_by_user"`
	GithubUsername  string `json:"github_username"`
	TwitterUsername string `json:"twitter_username"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳