api

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CategoriesBaseURL = "/categories"
View Source
const PostsBaseURL = "/posts"
View Source
const TopicsBaseURL = "/t"

Variables

This section is empty.

Functions

func NewStdLogger

func NewStdLogger(l Logger) retryablehttp.Logger

Types

type CategoriesService

type CategoriesService interface {
	List(
		ctx context.Context,
	) (*LatestCategoriesResponse, error)
}

type CategoryModel

type CategoryModel struct {
	ID                           int             `json:"id"`
	Name                         string          `json:"name"`
	Color                        string          `json:"color"`
	TextColor                    string          `json:"text_color"`
	Slug                         string          `json:"slug"`
	TopicCount                   int             `json:"topic_count"`
	PostCount                    int             `json:"post_count"`
	Position                     int             `json:"position"`
	Description                  string          `json:"description"`
	DescriptionText              string          `json:"description_text"`
	DescriptionExcerpt           string          `json:"description_excerpt"`
	TopicUrl                     string          `json:"topic_url"`
	ReadRestricted               bool            `json:"read_restricted"`
	Permission                   int             `json:"permission"`
	NotificationLevel            int             `json:"notification_level"`
	CanEdit                      bool            `json:"can_edit"`
	TopicTemplate                string          `json:"topic_template"`
	HasChildren                  bool            `json:"has_children"`
	SortOrder                    string          `json:"sort_order"`
	SortAscending                bool            `json:"sort_ascending"`
	ShowSubcategoryList          bool            `json:"show_subcategory_list"`
	NumFeaturedTopics            int             `json:"num_featured_topics"`
	DefaultView                  string          `json:"default_view"`
	SubcategoryListStyle         string          `json:"subcategory_list_style"`
	DefaultTopPeriod             string          `json:"default_top_period"`
	DefaultListFilter            string          `json:"default_list_filter"`
	MinimumRequiredTags          int             `json:"minimum_required_tags"`
	NavigateToFirstPostAfterRead bool            `json:"navigate_to_first_post_after_read"`
	TopicsDay                    int             `json:"topics_day"`
	TopicsWeek                   int             `json:"topics_week"`
	TopicsMonth                  int             `json:"topics_month"`
	TopicsYear                   int             `json:"topics_year"`
	TopicsAllTime                int             `json:"topics_all_time"`
	IsUncategorized              bool            `json:"is_uncategorized"`
	SubcategoryIDs               []int           `json:"subcategory_ids"`
	SubcategoryList              []CategoryModel `json:"subcategory_list"`
	UploadedLogoDark             string          `json:"uploaded_logo_dark"`
	UploadedBackground           string          `json:"uploaded_background"`
}

type CategoryServiceHandler

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

func (*CategoryServiceHandler) List

List

type Client

type Client struct {
	Posts      PostsService
	Topics     TopicsService
	Categories CategoriesService
	// 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 CreatePostModel

type CreatePostModel struct {
	Title             string `json:"title,omitempty"`
	Raw               string `json:"raw"`
	TopicID           int    `json:"topic_id,omitempty"`
	ReplyToPostNumber int    `json:"reply_to_post_number,omitempty"`
	Category          int    `json:"category,omitempty"`
	TargetRecipients  string `json:"targe_recipients,omitempty"`
	Archetype         string `json:"archetype,omitempty"`
	CreatedAt         string `json:"created_at,omitempty"`
	EmbedURL          string `json:"embed_url,omitempty"`
	ExternalID        string `json:"external_id,omitempty"`
}

type ErrorBody

type ErrorBody struct {
	Errors []string `json:"errors"`
}

type LatestCategoriesResponse

type LatestCategoriesResponse struct {
	CategoryList struct {
		CanCreateCategory bool `json:"can_create_category"`
		CanCreateTopic    bool `json:"can_create_topic"`

		Categories []CategoryModel `json:"categories"`
	} `json:"category_list"`
}

type LatestTopicsResponse

type LatestTopicsResponse struct {
	Users []struct {
		ID             int    `json:"id"`
		Username       string `json:"username"`
		Name           string `json:"name"`
		AvatarTemplate string `json:"avatar_template"`
	}

	TopicList struct {
		CanCreateTopic bool   `json:"can_create_topic"`
		Draft          string `json:"draft"`
		DraftKey       string `json:"draft_key"`
		DraftSequence  int    `json:"draft_sequence"`
		PerPage        int    `json:"per_page"`

		Topics []TopicModel `json:"topics"`
	} `json:"topic_list"`
}

type ListPostsResponse

type ListPostsResponse struct {
	LatestPosts []PostModel `json:"latest_posts,omitempty"`
}

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 PostModel

type PostModel struct {
	ID                int     `json:"id"`
	Name              string  `json:"name"`
	Username          string  `json:"username"`
	AvatarTemplate    string  `json:"avater_template"`
	CreatedAt         string  `json:"created_at"`
	Cooked            string  `json:"cooked"`
	PostNumber        int     `json:"post_number"`
	PostType          int     `json:"post_type"`
	UpdatedAt         string  `json:"updated_at"`
	ReplyCount        int     `json:"reply_count"`
	IncomingLinkCount int     `json:"incoming_link_count"`
	Reads             int     `json:"reads"`
	ReadersCount      int     `json:"readers_count"`
	Score             float32 `json:"score"`
	Yours             bool    `json:"yours"`
	TopicID           int     `json:"topic_id"`
	TopicSlug         string  `json:"topic_slug"`
	TopicTitle        string  `json:"topic_title"`
	TopicHTMLTitle    string  `json:"topic_html_title"`
	CategoryID        int     `json:"category_id"`
	DisplayUsername   string  `json:"display_username"`
	PrimaryGroupName  string  `json:"primary_group_name"`
	FlairName         string  `json:"flair_name"`
	FlairURL          string  `json:"flair_url"`
	FlairBGColor      string  `json:"flair_bg_color"`
	FlairColor        string  `json:"flair_color"`
	Version           int     `json:"version"`
	CanEdit           bool    `json:"can_edit"`
	CanDelete         bool    `json:"can_delete"`
	CanRecover        bool    `json:"can_recover"`
	CanWiki           bool    `json:"can_wiki"`
	UserTitle         string  `json:"user_title"`
	Raw               string  `json:"raw"`
	ActionsSummary    []struct {
		ID     int  `json:"id"`
		CanAct bool `json:"can_act"`
	} `json:"actions_summary"`
	Moderator                   bool   `json:"moderator"`
	Admin                       bool   `json:"admin"`
	Staff                       bool   `json:"staff"`
	UserID                      int    `json:"user_id"`
	Hidden                      bool   `json:"hidden"`
	TrustLevel                  int    `json:"trust_level"`
	DeletedAt                   string `json:"deleted_at"`
	UserDeleted                 bool   `json:"user_deleted"`
	EditReason                  string `json:"edit_reason"`
	CanViewEditHistory          bool   `json:"can_view_edit_history"`
	Wiki                        bool   `json:"wiki"`
	ReviewableID                string `json:"reviewable_id"`
	ReviewableScoreCount        int    `json:"reviewable_score_count"`
	ReviewableScorePendingCount int    `json:"reviewable_score_pending_count"`
}

type PostServiceHandler

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

func (*PostServiceHandler) Create

Create

func (*PostServiceHandler) List

List

func (*PostServiceHandler) Show

func (a *PostServiceHandler) Show(
	ctx context.Context,
	id string,
) (PostModel, error)

Show

type PostsService

type PostsService interface {
	Create(
		ctx context.Context,
		w *CreatePostModel,
	) (PostModel, error)
	Show(
		ctx context.Context,
		id string,
	) (PostModel, error)
	List(
		ctx context.Context,
	) (*ListPostsResponse, error)
}

type RequestError

type RequestError struct {
	Err error
}

func (*RequestError) Error

func (re *RequestError) Error() string

type ShowPostResponse

type ShowPostResponse struct {
	Post PostModel `json:"post,omitempty"`
}

type SingleTopicResponse

type SingleTopicResponse struct {
	PostStream struct {
		Posts  []PostModel `json:"posts"`
		Stream []int       `json:"stream"`
	} `json:"post_stream"`

	TopicModel
}

type StdLogger

type StdLogger struct {
	L Logger
}

func (*StdLogger) Printf

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

type TopicModel

type TopicModel struct {
	ID                 int    `json:"id"`
	Title              string `json:"title"`
	FancyTitle         string `json:"fancy_title"`
	Slug               string `json:"slug"`
	PostsCount         int    `json:"posts_count"`
	ReplyCount         int    `json:"reply_count"`
	HighestPostNumber  int    `json:"highest_post_number"`
	ImageURL           string `json:"image_url"`
	CreatedAt          string `json:"created_at"`
	LastPostedAt       string `json:"last_posted_at"`
	Bumped             bool   `json:"bumped"`
	BumpedAt           string `json:"bumped_at"`
	Archetype          string `json:"archetype"`
	Unseen             bool   `json:"unseen"`
	LastReadPostNumber int    `json:"last_read_post_number"`
	UnreadPosts        int    `json:"unread_posts"`
	Pinned             bool   `json:"pinned"`
	Unpinned           string `json:"unpinned"`
	Visible            bool   `json:"visible"`
	Closed             bool   `json:"closed"`
	Archived           bool   `json:"archived"`
	NotificationLevel  int    `json:"notification_level"`
	Bookmarked         bool   `json:"bookmarked"`
	Liked              bool   `json:"liked"`
	Views              int    `json:"views"`
	LikeCount          int    `json:"like_count"`
	HasSummary         bool   `json:"has_summary"`
	LastPosterUsername string `json:"last_poster_username"`
	CategoryID         int    `json:"category_id"`
	OpLikeCount        int    `json:"op_like_count"`
	PinnedGlobally     bool   `json:"pinned_globally"`
	FeaturedLink       string `json:"featured_link"`
	Posters            []struct {
		Extras         string `json:"extras"`
		Description    string `json:"description"`
		UserID         int    `json:"user_id"`
		PrimaryGroupID string `json:"primary_group_id"`
	} `json:"posters"`
}

type TopicServiceHandler

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

func (*TopicServiceHandler) ListLatest

func (a *TopicServiceHandler) ListLatest(
	ctx context.Context,
	categorySlug string,
	categoryID int,
) (*LatestTopicsResponse, error)

List

func (*TopicServiceHandler) Show

Show

func (*TopicServiceHandler) ShowPosts added in v1.0.2

func (a *TopicServiceHandler) ShowPosts(
	ctx context.Context,
	id string,
	postIDs []int,
) (*SingleTopicResponse, error)

ShowPosts

type TopicsService

type TopicsService interface {
	Show(
		ctx context.Context,
		id string,
	) (*SingleTopicResponse, error)
	ShowPosts(
		ctx context.Context,
		id string,
		postIDs []int,
	) (*SingleTopicResponse, error)
	ListLatest(
		ctx context.Context,
		categorySlug string,
		categoryID int,
	) (*LatestTopicsResponse, error)
}

Jump to

Keyboard shortcuts

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