goapi

package module
v0.0.0-...-85f5b3b Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2019 License: MIT Imports: 9 Imported by: 0

README

image

Go, Dev.to!

Code quality: Go Report Card GolangCI

Docs: GoDoc

DEV.TO API, but wrapped in Golang!

Examples

You can see example usage of this here:

I made a small post about what can be done with this package on DEV.TO

Documentation

Index

Constants

View Source
const PublishedRequest string = "https://dev.to/api/articles?"

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"`
	Published              bool         `json:"published"`
	PublishedAt            time.Time    `json:"published_at"`
	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"`
	PublishedTimestamp     time.Time    `json:"published_timestamp"`
	User                   User         `json:"user"`
	Organization           Organization `json:"organization,omitempty"`
	FlareTag               FlareTag     `json:"flare_tag,omitempty"`
}

Article just an article

func CreateNewArticle

func CreateNewArticle(p Payload, AccessToken string) (response Article, err error)

CreateNewArticle used to create a new article

RATE LIMITING: There is a limit of 10 articles created each 30 seconds by the same user

func GetPublishedArticle

func GetPublishedArticle(id int32) (response Article, err error)

GetPublishedArticle used for retrieve a single published article given its id

func UpdateExistingArticle

func UpdateExistingArticle(p Payload, id int32, AccessToken string) (response Article, err error)

UpdateExistingArticle updates the article

type Articles

type Articles []struct {
	TypeOf                 string       `json:"type_of"`
	ID                     int          `json:"id"`
	Title                  string       `json:"title"`
	Description            string       `json:"description"`
	CoverImage             string       `json:"cover_image"`
	Published              bool         `json:"published"`
	PublishedAt            time.Time    `json:"published_at"`
	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"`
	PublishedTimestamp     time.Time    `json:"published_timestamp"`
	User                   User         `json:"user"`
	Organization           Organization `json:"organization,omitempty"`
	FlareTag               FlareTag     `json:"flare_tag,omitempty"`
}

Articles is a list of articles. Yeah...

func GetPublishedArticles

func GetPublishedArticles(q QueryArticle) (response Articles, err error)

GetPublishedArticles used to get a list of articles

"Articles" are all the posts that users create on DEV that typically show up in the feed They can be a blog post, a discussion question, a help thread etc. but is referred to as article within the code

Each page will contain 30 articles

Responses, according to the combination of params, are cached for 24 hours

type FlareTag

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

FlareTag struct contains information about flare tag (may be empty)

type NewArticle

type NewArticle struct {
	Title          string   `json:"title"`
	Description    string   `json:"description"`
	BodyMarkdown   string   `json:"body_markdown"`
	Published      bool     `json:"published"`
	Series         string   `json:"series"`
	MainImage      string   `json:"main_image"`
	CanonicalURL   string   `json:"canonical_url"`
	Tags           []string `json:"tags"`
	OrganizationID int32    `json:"organization_id"`
}

NewArticle struct used in Payload struct

type Organization

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

Organization struct contains information about organization (may be empty)

type Payload

type Payload struct {
	Article NewArticle `json:"article"`
}

Payload for CreateNewArticle function

type QueryArticle

type QueryArticle struct {
	Page     int32  // Pagination page
	Tag      string // Articles that contain the requested tag
	Username string // Articles belonging to a User or Organization
	State    string // which articles are fresh or rising [fresh/rising]
	Top      int32  // most popular articles in the last N days
}

QueryArticle used in GetPublishedArticles function

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"`    // 640x640
	ProfileImage90  string `json:"profile_image_90"` // 90x90
}

User struct contains information about user

Jump to

Keyboard shortcuts

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