goforem

package module
v0.0.0-...-1280ae0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

README

goforem

A go wrapper for forem api

Supported endpoints

  • articles
    • GET /articles
    • POST /articles
    • GET /articles/latest
    • GET /articles/{id}
    • PUT /articles/{id}
    • GET /articles/{username}/{slug}
    • GET /articles/me/published (it's the same as /articles/me so I did only one)
    • GET /articles/me/unpublished
    • GET /articles/me/all
  • comments
  • follows
  • followers
  • listings
  • organizations
  • podcast_episodes
  • readinglist
  • users
  • videso
  • profile_images
  • admin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	TypeOf                 string        `json:"type_of"`
	ID                     int           `json:"id"`
	Title                  string        `json:"title"`
	Description            string        `json:"description"`
	CoverImage             string        `json:"cover_image"`
	ReadablePublishDate    string        `json:"readable_publish_date"`
	SocialImage            string        `json:"social_image"`
	TagList                []string      `json:"tag_list"`
	Tags                   string        `json:"tags"`
	Slug                   string        `json:"slug"`
	Path                   string        `json:"path"`
	URL                    string        `json:"url"`
	CanonicalURL           string        `json:"canonical_url"`
	CommentsCount          int           `json:"comments_count"`
	PositiveReactionsCount int           `json:"positive_reactions_count"`
	PublicReactionsCount   int           `json:"public_reactions_count"`
	CollectionID           int           `json:"collection_id"`
	CreatedAt              string        `json:"created_at"`
	EditedAt               string        `json:"edited_at"`
	CrosspostedAt          string        `json:"crossposted_at"`
	PublishedAt            string        `json:"published_at"`
	LastCommentAt          string        `json:"last_comment_at"`
	PublishedTimestamp     string        `json:"published_timestamp"`
	ReadingTimeMinutes     int           `json:"reading_time_minutes"`
	BodyHTML               string        `json:"body_html"`
	BodyMarkdown           string        `json:"body_markdown"`
	User                   *User         `json:"user,omitempty"`
	Organization           *Organization `json:"organization,omitempty"`
	FlareTag               *FlareTag     `json:"flare_tag,omitempty"`
}

type ArticleState

type ArticleState string
const (
	StateFresh  ArticleState = "fresh"
	StateRising ArticleState = "rising"
	StateAll    ArticleState = "all"
)

type ArticleVariant

type ArticleVariant struct {
	Article
	Tags    []string `json:"tags"`
	TagList string   `json:"tag_list"`
}

type Articles

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

func (*Articles) ById

func (a *Articles) ById(ctx context.Context, id int) (ArticleVariant, error)

GET articles/{id}

func (*Articles) ByPath

func (a *Articles) ByPath(ctx context.Context, username string, slug string) (ArticleVariant, error)

GET articles/{username}/{slug}

func (*Articles) Create

func (a *Articles) Create(ctx context.Context, payload CreateArticlePayload) (ArticleVariant, error)

POST articles

func (*Articles) Latest

func (a *Articles) Latest(ctx context.Context, opts LatestArticlesOpts) ([]Article, error)

GET articles/latest

func (*Articles) Published

func (a *Articles) Published(ctx context.Context, opts PublishedArticlesOpts) ([]Article, error)

GET articles

func (*Articles) Update

func (a *Articles) Update(ctx context.Context, id int, payload UpdateArticlePayload) (ArticleVariant, error)

PUT articles/{id}

func (*Articles) UserAll

func (a *Articles) UserAll(ctx context.Context, opts UserArticlesOpts) ([]Article, error)

GET articles/me/all requires ApiKey to be set

func (*Articles) UserPublished

func (a *Articles) UserPublished(ctx context.Context, opts UserArticlesOpts) ([]Article, error)

GET articles/me/published requires ApiKey to be set

func (*Articles) UserUnpublished

func (a *Articles) UserUnpublished(ctx context.Context, opts UserArticlesOpts) ([]Article, error)

GET articles/me/unpublished requires ApiKey to be set

type Client

type Client struct {
	Articles *Articles
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseUrl string, opts ...ClientOption) (*Client, error)

type ClientOption

type ClientOption func(c *Client)

func WithAPIKey

func WithAPIKey(apiKey string) ClientOption

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

type CreateArticlePayload

type CreateArticlePayload struct {
	Article struct {
		Title          string   `json:"title,omitempty"`
		BodyMarkdown   string   `json:"body_markdown,omitempty"`
		Published      bool     `json:"published,omitempty"`
		Series         string   `json:"series,omitempty"`
		MainImage      string   `json:"main_image,omitempty"`
		CanonicalURL   string   `json:"canonical_url,omitempty"`
		Description    string   `json:"description,omitempty"`
		Tags           []string `json:"tags,omitempty"`
		OrganizationID int      `json:"organization_id,omitempty"`
	} `json:"article"`
}

type ErrorResponse

type ErrorResponse struct {
	Error  string `json:"error"`
	Status int    `json:"status"`
}

type FlareTag

type FlareTag struct {
	Name         string `json:"name"`
	BgColorHex   string `json:"bg_color_hex"`
	TextColorHex string `json:"text_color_hex"`
}

type LatestArticlesOpts

type LatestArticlesOpts struct {
	Page    int `url:"page,omitempty"`
	PerPage int `url:"per_page,omitempty"`
}

type Organization

type Organization struct {
	Name           string `json:"name"`
	Username       string `json:"username"`
	Slug           string `json:"slug"`
	ProfileImage   string `json:"profile_image"`
	ProfileImage90 string `json:"profile_image_90"`
}

type PublishedArticlesOpts

type PublishedArticlesOpts struct {
	Page         int          `url:"page,omitempty"`
	PerPage      int          `url:"per_page,omitempty"`
	Tag          string       `url:"tag,omitempty"`
	Tags         []string     `url:"tags,omitempty" del:","`
	TagsExclude  []string     `url:"tags_exclude,omitempty" del:","`
	Username     string       `url:"username,omitempty"`
	State        ArticleState `url:"state,omitempty"`
	Top          int          `url:"top,omitempty"`
	CollectionId int          `url:"collection_id,omitempty"`
}

type UpdateArticlePayload

type UpdateArticlePayload CreateArticlePayload

type User

type User struct {
	Name            string `json:"name"`
	Username        string `json:"username"`
	TwitterUsername string `json:"twitter_username"`
	GithubUsername  string `json:"github_username"`
	WebsiteURL      string `json:"website_url"`
	ProfileImage    string `json:"profile_image"`
	ProfileImage90  string `json:"profile_image_90"`
}

type UserArticlesOpts

type UserArticlesOpts LatestArticlesOpts

Jump to

Keyboard shortcuts

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