Documentation
¶
Index ¶
- Constants
- type Action
- type Article
- type ArticleBodySchema
- type ArticleFlareTag
- type ArticleQueryParams
- type ArticleVariant
- type Client
- func (c *Client) CreateArticle(payload ArticleBodySchema, filepath interface{}) (*ArticleVariant, error)
- func (c *Client) CreateListing(payload ListingBodySchema, filepath interface{}) (*Listing, error)
- func (c *Client) CreateWebhook(payload WebhookBodySchema) (*Webhook, error)
- func (c *Client) DeleteWebhook(webhookID string) error
- func (c *Client) GetArticlesWithVideo(q ArticleQueryParams) ([]VideoArticle, error)
- func (c *Client) GetAuthenticatedUser() (*User, error)
- func (c *Client) GetComment(commentID string) (*Comment, error)
- func (c *Client) GetComments(q CommentQueryParams) ([]Comment, error)
- func (c *Client) GetFollowedTags() ([]Tag, error)
- func (c *Client) GetListingByID(listingID string) (*Listing, error)
- func (c *Client) GetOrganization(orgname string) (*Organization, error)
- func (c *Client) GetOrganizationArticles(orgname string, q OrganizationQueryParams) ([]Article, error)
- func (c *Client) GetOrganizationListings(orgname string, q OrganizationQueryParams) ([]Listing, error)
- func (c *Client) GetOrganizationUsers(orgname string, q OrganizationQueryParams) ([]User, error)
- func (c *Client) GetProfileImage(username string) (*ProfileImage, error)
- func (c *Client) GetPublishedArticleByID(articleID string) (*ArticleVariant, error)
- func (c *Client) GetPublishedArticleByPath(username, slug string) (*ArticleVariant, error)
- func (c *Client) GetPublishedArticles(q ArticleQueryParams) ([]Article, error)
- func (c *Client) GetPublishedArticlesSorted(q ArticleQueryParams) ([]Article, error)
- func (c *Client) GetPublishedListings(q ListingQueryParams) ([]Listing, error)
- func (c *Client) GetPublishedListingsByCategory(category string, q ListingQueryParams) ([]Listing, error)
- func (c *Client) GetPublishedPodcastEpisodes(q PodcastQueryParams) ([]PodcastEpisode, error)
- func (c *Client) GetUserArticles(q ArticleQueryParams) ([]Article, error)
- func (c *Client) GetUserByID(userID string) (*User, error)
- func (c *Client) GetUserByUsername(q UserQueryParams) (*User, error)
- func (c *Client) GetUserFollowers(q UserQueryParams) ([]User, error)
- func (c *Client) GetUserPublishedArticles(q ArticleQueryParams) ([]Article, error)
- func (c *Client) GetUserReadingList(q ReadingListQueryParams) ([]ReadingList, error)
- func (c *Client) GetUserUnPublishedArticles(q ArticleQueryParams) ([]Article, error)
- func (c *Client) GetWebhookByID(webhookID string) (*Webhook, error)
- func (c *Client) GetWebhooks() ([]Webhook, error)
- func (c *Client) NewRequest(ctx context.Context, method, path string, payload interface{}) (*http.Request, error)
- func (c *Client) SendHttpRequest(r *http.Request, v interface{}) error
- func (c *Client) UpdateArticle(articleID string, payload ArticleBodySchema, filepath interface{}) (*ArticleVariant, error)
- func (c *Client) UpdateListing(listingID string, payload ListingBodySchema, filepath interface{}) (*Listing, error)
- type Comment
- type CommentQueryParams
- type DevAPIError
- type Listing
- type ListingBodySchema
- type ListingCategory
- type ListingQueryParams
- type Options
- type Organization
- type OrganizationQueryParams
- type PodcastEpisode
- type PodcastQueryParams
- type ProfileImage
- type ReadingList
- type ReadingListQueryParams
- type ReadingListStatus
- type State
- type Tag
- type User
- type UserQueryParams
- type VideoArticle
- type Webhook
- type WebhookBodySchema
Constants ¶
const ( StateFresh = State("fresh") StateRising = State("rising") StateAll = State("all") )
const ( ListingCategoryCfp = ListingCategory("cfp") ListingCategoryForhire = ListingCategory("forhire") ListingCategoryCollabs = ListingCategory("collabs") ListingCategoryEducation = ListingCategory("education") ListingCategoryJobs = ListingCategory("jobs") ListingCategoryMentors = ListingCategory("mentors") ListingCategoryProducts = ListingCategory("products") ListingCategoryMentees = ListingCategory("mentees") ListingCategoryForsale = ListingCategory("forsale") ListingCategoryEvents = ListingCategory("events") ListingCategoryMisc = ListingCategory("misc") )
const ( ActionDraft = Action("draft") ActionBump = Action("bump") ActionPublish = Action("publish") ActionUnpublish = Action("unpublish") )
const (
BASE_URL = "https://dev.to/api"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
TypeOf string `json:"type_of"`
ID int32 `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
CoverImage string `json:"cover_image,omitempty"`
Published bool `json:"published"`
ReadablePublishDate string `json:"readable_publish_date"`
SocialImage string `json:"social_image"`
BodyMarkdown string `json:"body_markdown"`
BodyHTML string `json:"body_html"`
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 int32 `json:"comments_count"`
PageViewsCount int32 `json:"page_views_count"`
PositiveReactionsCount int32 `json:"positive_reactions_count"`
PublicReactionsCount int32 `json:"public_reactions_count"`
CreatedAt string `json:"created_at"`
EditedAt string `json:"edited_at,omitempty"`
CrosspostedAt string `json:"crossposted_at,omitempty"`
PublishedAt string `json:"published_at"`
LastCommentAt string `json:"last_comment_at"`
PublishedTimestamp string `json:"published_timestamp"`
User *User `json:"user"`
ReadingTimeMinutes int32 `json:"reading_time_minutes"`
Organization *Organization `json:"organization,omitempty"`
FlareTag *ArticleFlareTag `json:"flare_tag,omitempty"`
}
type ArticleBodySchema ¶
type ArticleBodySchema struct {
Article struct {
Title string `json:"title"`
BodyMarkdown string `json:"body_markdown"`
Published bool `json:"published"`
Series string `json:"series"`
MainImage string `json:"main_image"`
CanonicalURL string `json:"canonical_url"`
Description string `json:"description"`
Tags []string `json:"tags"`
OrganizationID int32 `json:"organization_id"`
} `json:"article"`
}
type ArticleFlareTag ¶
type ArticleQueryParams ¶
type ArticleQueryParams struct {
Page int32 `url:"page,omitempty"`
PerPage int32 `url:"per_page,omitempty"`
Tag string `url:"tag,omitempty"`
Tags string `url:"tags,omitempty"`
TagsExclude string `url:"tags_exclude,omitempty"`
Username string `url:"username,omitempty"`
State State `url:"state,omitempty"`
Top int32 `url:"top,omitempty"`
CollectionID int32 `url:"collection_id,omitempty"`
}
type ArticleVariant ¶
There are some inconsistencies with regards to the article schema returned when fetching articles and the schema returned when creating articles. This structure fixes that
type Client ¶
func NewTestClient ¶
func (*Client) CreateArticle ¶
func (c *Client) CreateArticle(payload ArticleBodySchema, filepath interface{}) (*ArticleVariant, error)
CreateArticle allows the client to create a new article @filepath - article body can be set on the payload as a string
or passed via the path to a markdown file
func (*Client) CreateListing ¶
func (c *Client) CreateListing(payload ListingBodySchema, filepath interface{}) (*Listing, error)
CreateListing allows the client to create a listing. Listings are classified as ads that users create on DEV
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(payload WebhookBodySchema) (*Webhook, error)
CreateWebhook allows the client to create a new webhook
func (*Client) DeleteWebhook ¶
DeleteWebhook allows the client to delete a single webhook given its id
func (*Client) GetArticlesWithVideo ¶
func (c *Client) GetArticlesWithVideo(q ArticleQueryParams) ([]VideoArticle, error)
GetArticlesWithVideo allows the client to retrieve a list of articles that are uploaded with a video
func (*Client) GetAuthenticatedUser ¶
GetAuthenticatedUser allows the client to retrieve information about the authenticated user
func (*Client) GetComment ¶
GetComment allows the client to retrieve a comment alongside its descendants
func (*Client) GetComments ¶
func (c *Client) GetComments(q CommentQueryParams) ([]Comment, error)
GetComments allows the client to retrieve all comments belonging to an article or podcast as threaded conversations
func (*Client) GetFollowedTags ¶
GetFollowedTags allows the client to retrieve a list of the tags they follow
func (*Client) GetListingByID ¶
GetListingByID allows the client to retrieve a single listing given its Id
func (*Client) GetOrganization ¶
func (c *Client) GetOrganization(orgname string) (*Organization, error)
GetOrganization allows the client retrieve a single organization by their username
func (*Client) GetOrganizationArticles ¶
func (c *Client) GetOrganizationArticles(orgname string, q OrganizationQueryParams) ([]Article, error)
GetOrganizationArticles allows the client to retrieve a list of Articles belonging to the organization
func (*Client) GetOrganizationListings ¶
func (c *Client) GetOrganizationListings(orgname string, q OrganizationQueryParams) ([]Listing, error)
GetOrganizationListings allows the client to retrieve a list of listings belonging to the organization
func (*Client) GetOrganizationUsers ¶
func (c *Client) GetOrganizationUsers(orgname string, q OrganizationQueryParams) ([]User, error)
GetOrganizationUsers allows the client to retrieve a list of users belonging to the organization
func (*Client) GetProfileImage ¶
func (c *Client) GetProfileImage(username string) (*ProfileImage, error)
GetProfileImage allows the client to retrieve a user or organization profile image information by its corresponding username
func (*Client) GetPublishedArticleByID ¶
func (c *Client) GetPublishedArticleByID(articleID string) (*ArticleVariant, error)
GetPublishedArticleByID allows the client to retrieve a single published article by the specified ID
func (*Client) GetPublishedArticleByPath ¶
func (c *Client) GetPublishedArticleByPath(username, slug string) (*ArticleVariant, error)
GetPublishedArticleByPath allows the client to retrieve a single published article given its path (slug)
func (*Client) GetPublishedArticles ¶
func (c *Client) GetPublishedArticles(q ArticleQueryParams) ([]Article, error)
GetPublishedArticles allows client to retrieve a list of articles
func (*Client) GetPublishedArticlesSorted ¶
func (c *Client) GetPublishedArticlesSorted(q ArticleQueryParams) ([]Article, error)
GetPublishedArticlesSorted allows the client to recieve a list of articles ordered by descending publish date
func (*Client) GetPublishedListings ¶
func (c *Client) GetPublishedListings(q ListingQueryParams) ([]Listing, error)
GetPublishedListings allows the client retrieve a list of listings
func (*Client) GetPublishedListingsByCategory ¶
func (c *Client) GetPublishedListingsByCategory(category string, q ListingQueryParams) ([]Listing, error)
GetPublishedListingsByCategory allows the client to retrieve a list of listings belonging to the given category
func (*Client) GetPublishedPodcastEpisodes ¶
func (c *Client) GetPublishedPodcastEpisodes(q PodcastQueryParams) ([]PodcastEpisode, error)
GetPublishedPodcastEpisodes allows the client to retrieve a list of podcast episodes
func (*Client) GetUserArticles ¶
func (c *Client) GetUserArticles(q ArticleQueryParams) ([]Article, error)
GetUserArticles allows the client to retrieve a list of articles on behalf of an authenticated user
func (*Client) GetUserByID ¶
GetUserByID allows the client to retrieve a single user with the given id
func (*Client) GetUserByUsername ¶
func (c *Client) GetUserByUsername(q UserQueryParams) (*User, error)
GetUserByUsername allows the client to retrieve a single user with the given username
func (*Client) GetUserFollowers ¶
func (c *Client) GetUserFollowers(q UserQueryParams) ([]User, error)
GetUserFollowers allows the client to retrieve a list of the followers they have.
func (*Client) GetUserPublishedArticles ¶
func (c *Client) GetUserPublishedArticles(q ArticleQueryParams) ([]Article, error)
GetUserArticles allows the client to retrieve a list of published articles on behalf of an authenticated user
func (*Client) GetUserReadingList ¶
func (c *Client) GetUserReadingList(q ReadingListQueryParams) ([]ReadingList, error)
GetUserReadingList allows the client to retrieve a list of readinglist reactions along with the related article for the authenticated user.
func (*Client) GetUserUnPublishedArticles ¶
func (c *Client) GetUserUnPublishedArticles(q ArticleQueryParams) ([]Article, error)
GetUserArticles allows the client to retrieve a list of unpublished articles on behalf of an authenticated user
func (*Client) GetWebhookByID ¶
GetWebhookByID allows the client to retrieve a single webhook given its id
func (*Client) GetWebhooks ¶
GetWebhooks allows the client to retrieve a list of webhooks they have previously registered.
func (*Client) NewRequest ¶
func (*Client) SendHttpRequest ¶
func (*Client) UpdateArticle ¶
func (c *Client) UpdateArticle(articleID string, payload ArticleBodySchema, filepath interface{}) (*ArticleVariant, error)
UpdateArticle allows the client to update an existing article This method is rate-limited (30req/30sec)
func (*Client) UpdateListing ¶
func (c *Client) UpdateListing(listingID string, payload ListingBodySchema, filepath interface{}) (*Listing, error)
type CommentQueryParams ¶
type DevAPIError ¶
type DevAPIError struct {
// contains filtered or unexported fields
}
func (*DevAPIError) Error ¶
func (d *DevAPIError) Error() string
type Listing ¶
type Listing struct {
TypeOf string `json:"type_of"`
ID int64 `json:"id"`
Title string `json:"title"`
Slug string `json:"slug"`
BodyMarkdown string `json:"body_markdown"`
TagList string `json:"tag_list"`
Tags []string `json:"tags"`
Category ListingCategory `json:"category"`
ProcessedHTML string `json:"processed_html"`
Published bool `json:"published"`
CreatedAt string `json:"created_at"`
User *User `json:"user"`
Organization *Organization `json:"organization"`
}
type ListingBodySchema ¶
type ListingBodySchema struct {
Listing struct {
Title string `json:"title"`
BodyMarkdown string `json:"body_markdown"`
Category ListingCategory `json:"category"`
Tags []string `json:"tags"`
TagList string `json:"tag_list"`
ExpiresAt string `json:"expires_at"`
ContactViaConnect bool `json:"contact_via_connect"`
Location string `json:"location"`
OrganizationID int64 `json:"organization_id,omitempty"`
Action Action `json:"action"`
} `json:"listing"`
}
type ListingCategory ¶
type ListingCategory string
type ListingQueryParams ¶
type Organization ¶
type Organization struct {
TypeOf string `json:"type_of"`
Name string `json:"name"`
Username string `json:"username"`
Summary string `json:"summary"`
TwitterUsername string `json:"twitter_username,omitempty"`
GithubUsername string `json:"github_username,omitempty"`
URL string `json:"url"`
Location string `json:"location,omitempty"`
TechStack string `json:"tech_stack,omitempty"`
TagLine string `json:"tag_line,omitempty"`
Story string `json:"story,omitempty"`
Slug string `json:"slug"`
JoinedAt string `json:"joined_at"`
ProfileImage string `json:"profile_image"`
ProfileImage90 string `json:"profile_image_90"`
}
type OrganizationQueryParams ¶
type OrganizationQueryParams struct {
Page int32 `url:"page,omitempty"`
PerPage int32 `url:"per_page,omitempty"`
Category ListingCategory `json:"category,omitempty"`
}
type PodcastEpisode ¶
type PodcastQueryParams ¶
type ProfileImage ¶
type ReadingList ¶
type ReadingList struct {
TypeOf string `json:"type_of"`
ID int32 `json:"id"`
Status ReadingListStatus `json:"status"`
Article *Article `json:"article"`
}
type ReadingListQueryParams ¶
type ReadingListStatus ¶
type ReadingListStatus string
const ( ReadingListStatusValid ReadingListStatus = "valid" ReadingListStatusInvalidValid ReadingListStatus = "invalid" ReadingListStatusConfirmed ReadingListStatus = "confirmed" ReadingListStatusArchived ReadingListStatus = "archived" )
type User ¶
type User struct {
TypeOf string `json:"type_of"`
ID int32 `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
Summary string `json:"summary,omitempty"`
TwitterUsername string `json:"twitter_username,omitempty"`
GithubUsername string `json:"github_username,omitempty"`
WebsiteURL string `json:"website_url,omitempty"`
Location string `json:"location,omitempty"`
JoinedAt string `json:"joined_at"`
ProfileImage string `json:"profile_image"`
}
type UserQueryParams ¶
type VideoArticle ¶
type VideoArticle struct {
TypeOf string `json:"type_of"`
ID int32 `json:"id"`
Path string `json:"path"`
CloudinaryVideoURL string `json:"cloudinary_video_url"`
Title string `json:"title"`
UserID int32 `json:"user_id"`
VideoDurationInMinutes string `json:"video_duration_in_minutes"`
VideoSourceURL string `json:"video_source_url"`
User *User `json:"user"`
}