qiita

package
v0.0.0-...-878056c Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

The package 'qiita' provides a client using Qiita API v2.

You can also use http.Client compatible client object like oauth2. Here are simple examples.

import (
  "github.com/uetchy/go-qiita/qiita"
  "golang.org/x/oauth2"
  "fmt"
)

func main() {
  // Create OAuth2 client
  ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "personal access token"})
  tc := oauth2.NewClient(oauth2.NoContext, ts)

  // Create Qiita client using OAuth2 adapter
  client := qiita.NewClient(tc)

  // Fetch articles and print them
  items, _, _ := client.Items.List(&qiita.ItemsListOptions{Query: "Alfred"})
  fmt.Println(items)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachedTag

type AttachedTag struct {
	Name     string   `json:"name"`
	Versions []string `json:"versions"`
}

type AuthenticatedUserService

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

func (*AuthenticatedUserService) Items

List the authenticated user's items in newest order

func (*AuthenticatedUserService) Show

func (s *AuthenticatedUserService) Show() (*User, error)

Get a user associated to the current access token.

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	Items             *ItemsService
	Users             *UsersService
	AuthenticatedUser *AuthenticatedUserService
	Tags              *TagsService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

Return new client instance

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do http request

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

Return new http request

type Item

type Item struct {
	RenderedBody string        `json:"rendered_body"`
	Body         string        `json:"body"`
	CoEditing    bool          `json:"coediting"`
	CreatedAt    time.Time     `json:"created_at"`
	Id           string        `json:"id"`
	Private      bool          `json:"private"`
	Tags         []AttachedTag `json:"tags"`
	Title        string        `json:"title"`
	UpdatedAt    time.Time     `json:"updated_at"`
	URL          string        `json:"url"`
	User         User          `json:"user"`
}

type ItemsListOptions

type ItemsListOptions struct {
	Query string `url:"query,omitempty"`
	ListOptions
}

type ItemsService

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

func (*ItemsService) List

func (s *ItemsService) List(opt *ItemsListOptions) ([]Item, *http.Response, error)

type ListOptions

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

type Response

type Response struct {
	*http.Response

	NextPage  int
	PrevPage  int
	FirstPage int
	LastPage  int
}

type Tag

type Tag struct {
	FollowersCount int    `json:"followers_count"`
	IconURL        string `json:"icon_url"`
	Id             string `json:"id"`
	ItemsCount     int    `json:"items_count"`
}

type TagsService

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

func (*TagsService) List

func (s *TagsService) List(opt *ListOptions) ([]Tag, *http.Response, error)

type User

type User struct {
	Name              string `json:"name"`
	Description       string `json:"description"`
	FacebookId        string `json:"facebook_id"`
	FolloweesCount    int    `json:"followees_count"`
	FollowersCount    int    `json:"followers_count"`
	GithubLoginName   string `json:"github_login_name"`
	Id                string `json:"id"`
	ItemsCount        int    `json:"items_count"`
	LinkedinId        string `json:"linkedin_id"`
	Location          string `json:"location"`
	Organization      string `json:"organization"`
	PermanentId       int    `json:"permanent_id"`
	ProfileImageURL   string `json:"profile_image_url"`
	TwitterScreenName string `json:"twitter_screen_name"`
	WebsiteURL        string `json:"website_url"`
}

type UsersService

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

func (*UsersService) Stocks

func (s *UsersService) Stocks(userId string, opt *ListOptions) ([]Item, *http.Response, error)

List a user's stocked items in recently-stocked order.

Jump to

Keyboard shortcuts

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