qiita

package module
v0.0.0-...-ab44ef7 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2014 License: MIT Imports: 6 Imported by: 0

README

Qiita

Go wrapper for Qiita API v1.

Installation

go get -u github.com/Warashi/qiita-go

and

import "github.com/Warashi/qiita-go"

Usage

Get user's items
c := qiita.NewClient()
UserName := "saveji"
params := map[string]interface{}{}
items,err := c.UserItems(UserName,params)
Get tag's items
c := qiita.NewClient()
tag := "Go"
params := map[string]interface{}{}
items,err := c.TagItems(tag,params)
Get a specified item with comments and raw markdown content
c := qiita.NewClient()
uuid = "1234567890abcdefg"
item,err := c.Item(uuid)

Authenticated requests

Login with "username & password" or "token"
c := qiita.NewClient()
err := c.Login("UserName","Password")

or

c := qiita.NewClientWithToken("Token")
Get my items
params := map[string]interface{}{}
items,err := c.MyItems(params)
Post/Update/Delete an item

post

params := map[string]interface{}{
			"title": "Hello",
			"tags": []map[string]interface{}{{
				"name": "Tag",
                "versions": []string{"1.1","1.2"}
			}},
			"body":    "markdown text",
			"private": false,
}
item,err := c.PostItem(param)

update

params := map[string]interface{}{
			"title": "modified",
}
item,err := c.UpdateItem("uuid",param)

delete

err := c.DeleteItem("uuid")

Running Test

if you want to run go test, you must fill constants in const_test.go.

Documentation

Overview

Package qiita は Qiita API のラッパーです.

References:

https://qiita.com/docs

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URLName string `json:"url_name"`
	Token   string
}

func NewClient

func NewClient() *Client

func NewClientWithToken

func NewClientWithToken(Token string) *Client

func (*Client) DeleteItem

func (c *Client) DeleteItem(uuid string) error

func (*Client) Item

func (c *Client) Item(uuid string) (ret *Item, err error)

func (*Client) Items

func (c *Client) Items(params map[string]interface{}) (ret []Item, err error)

func (*Client) Login

func (c *Client) Login(username, password string) error
Example
c := NewClient()
_ = c.Login("username", "password")

func (*Client) Me

func (c *Client) Me(params map[string]interface{}) (ret *User, err error)

func (*Client) MyItems

func (c *Client) MyItems(params map[string]interface{}) (ret []Item, err error)

func (*Client) MyStocks

func (c *Client) MyStocks(params map[string]interface{}) (ret []Item, err error)

func (*Client) PostItem

func (c *Client) PostItem(params map[string]interface{}) (ret *Item, err error)
Example
c := NewClientWithToken("token")
param := map[string]interface{}{
	"title": "Title",
	"tags": []map[string]interface{}{
		{"name": "Tag1", "versions": []string{"1.1", "1.2"}},
		{"name": "Tag2", "versions": []string{"1.3", "1.4"}},
	},
	"body":    "body",
	"private": false,
	"gist":    true,
	"tweet":   true,
}
_, _ = c.PostItem(param)

func (*Client) RateLimit

func (c *Client) RateLimit() (ret *RateLimit, err error)
Example
c := NewClient()
ret, _ := c.RateLimit()
fmt.Println(ret.Remaining)

func (*Client) SearchItems

func (c *Client) SearchItems(query string, params map[string]interface{}) (ret []Item, err error)

func (*Client) StockItem

func (c *Client) StockItem(uuid string) error

func (*Client) TagItems

func (c *Client) TagItems(tag string, params map[string]interface{}) (ret []Item, err error)

func (*Client) Tags

func (c *Client) Tags(params map[string]interface{}) (ret []Tag, err error)

func (*Client) UnStockItem

func (c *Client) UnStockItem(uuid string) error

func (*Client) UpdateItem

func (c *Client) UpdateItem(uuid string, params map[string]interface{}) (ret *Item, err error)

func (*Client) User

func (c *Client) User(UserName string, params map[string]interface{}) (ret *User, err error)

func (*Client) UserFollowingTags

func (c *Client) UserFollowingTags(UserName string, params map[string]interface{}) (ret []Tag, err error)

func (*Client) UserFollowingUsers

func (c *Client) UserFollowingUsers(UserName string, params map[string]interface{}) (ret []User, err error)

func (*Client) UserItems

func (c *Client) UserItems(UserName string, params map[string]interface{}) (ret []Item, err error)

func (*Client) UserStocks

func (c *Client) UserStocks(UserName string, params map[string]interface{}) (ret []Item, err error)

type Item

type Item struct {
	ID        int64  `json:"id"`
	UpdatedAt string `json:"updated_at"`
	Tags      []struct {
		Name     string   `json:"name"`
		URLName  string   `json:"url_name"`
		IconURL  string   `json:"icon_url"`
		Versions []string `json:"versions"`
	} `json:"tags"`
	StockUsers   []string `json:"stock_users"`
	CommentCount int64    `json:"comment_count"`
	URL          string   `json:"url"`
	GistURL      string   `json:"gist_url"`
	Tweet        bool     `json:"tweet"`
	Title        string   `json:"title"`
	StockCount   int64    `json:"stock_count"`
	Comments     []struct {
		ID   int64  `json:"id"`
		Uuid string `json:"uuid"`
		User struct {
			Name            string `json:"name"`
			URLName         string `json:"url_name"`
			ProfileImageURL string `json:"profile_image_url"`
		} `json:"user"`
		Body string `json:"body"`
	} `json:"comments"`
	Uuid string `json:"uuid"`
	User struct {
		Name            string `json:"name"`
		URLName         string `json:"url_name"`
		ProfileImageURL string `json:"profile_image_url"`
	} `json:"user"`
	UpdatedAtInWords string `json:"updated_at_in_words"`
	Private          bool   `json:"private"`
	Stocked          bool   `json:"stocked"`
	Body             string `json:"body"`
	CreatedAt        string `json:"created_at"`
	CreatedAtInWords string `json:"created_at_in_words"`
}

type RateLimit

type RateLimit struct {
	Remaining int
	Limit     int
}

type Tag

type Tag struct {
	Name          string `json:"name"`
	URLName       string `json:"url_name"`
	IconURL       string `json:"icon_url"`
	ItemCount     int64  `json:"item_count"`
	FollowerCount int64  `json:"follower_count"`
	Following     bool   `json:"following"`
}

type User

type User struct {
	Description string `json:"description"`
	Facebook    string `json:"facebook"`
	Teams       []struct {
		Name    string `json:"name"`
		URLName string `json:"url_name"`
	} `json:"teams"`
	Name            string `json:"name"`
	ProfileImageURL string `json:"profile_image_url"`
	URL             string `json:"url"`
	Organization    string `json:"organization"`
	Location        string `json:"location"`
	Github          string `json:"github"`
	Linkedin        string `json:"linkedin"`
	FollowingUsers  int64  `json:"following_users"`
	Items           int64  `json:"items"`
	URLName         string `json:"url_name"`
	WebsiteURL      string `json:"website_url"`
	Twitter         string `json:"twitter"`
	Followers       int64  `json:"followers"`
}

Jump to

Keyboard shortcuts

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