Qiita::Sdk
Qiita Api の Api クライアント
Installation
gem 'qiita-sdk'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install qiita-sdk
Usage
インスタンスの作成
client = Qiita::Sdk::Client.new
認証が必要なアクションを行う場合
client = Qiita::Sdk::Client.new do |config|
config.access_token = 'XXXX'
end
メソッド一覧
全て戻り値は [Net::HTTPResponse] を返す
- 記事につけられた「LGTM!」一覧を取得
item_id = 'XXXX'
res = client.fetch_item_likes(item_id: item_id)
- コメントを削除
comment_id = 'XXXX'
client.delete_comment(comment_id: comment_id)
- コメントを取得
comment_id = 'XXXX'
res = client.fetch_comment(comment_id: comment_id)
- コメントを更新
comment_id = 'XXXX'
body = 'update body'
client.update_comment(comment_id: comment_id, body: body)
- 投稿に紐づけられた投稿一覧
item_id = 'XXXX'
res = client.fetch_item_comments(item_id: item_id)
- 記事に対してコメントを投稿
item_id = 'XXXX'
body = 'comment body'
client.post_comment(item_id: item_id, body: body)
- タグを取得
tag_id = 'XXXX'
res = client.fetch_tag(tag_id: tag_id)
- ユーザがフォローしているタグ一覧
user_id = 'XXXX'
res = client.(user_id: user_id)
- タグのフォローを外す
tag_id = 'XXXX'
client.delete_tag_following(tag_id: tag_id)
- タグをフォローしているかどうかを調る
tag_id = 'XXXX'
res = client.check_tag_following(tag_id: tag_id)
- タグをフォロー
tag_id = 'XXXX'
client.follow_tag(tag_id: tag_id)
- 記事をストックしているユーザ一覧を、ストックした日時の降順で返す
item_id = 'XXXX'
res = client.fetch_item_stockers(item_id: item_id)
- 全てのユーザの一覧を作成日時の降順で取得
res = client.fetch_users
- ユーザを取得
user_id = 'XXXX'
res = client.fetch_user(user_id: user_id)
- ユーザがフォローしているユーザ一覧を取得
user_id = 'XXXX'
res = client.fetch_followees(user_id: user_id)
- ユーザをフォローしているユーザ一覧を取得
user_id = 'XXXX'
res = client.fetch_followers(user_id: user_id)
- ユーザへのフォローを外します。
user_id = 'XXXX'
client.delete_following(user_id: user_id)
- ユーザをフォローしている場合に204を返す
user_id = 'XXXX'
res = client.check_following(user_id: user_id)
- ユーザをフォロー
user_id = 'XXXX'
client.follow_user(user_id: user_id)
- 認証中のユーザの記事の一覧を作成日時の降順で返す
res = client.fetch_my_items
- 記事の一覧を作成日時の降順で返す
res = client.fetch_items
- 新たに記事を作成
title, bodyは必須
デフォルト値 tweet = false tags = [] restricted = false
title = 'title'
body = 'body'
tweet = true
= ['ruby', 'rails']
restricted = false
client.post_item(title: title, body: body, tweet: tweet, tags: , restricted: restricted)
- 記事を削除
item_id = 'XXXX'
client.delete_item(item_id: item_id)
- 記事を取得
item_id = 'XXXX'
res = client.fetch_item(item_id: item_id)
- 記事を更新
item_id = 'XXXX'
title = 'update title'
body = 'update body'
restricted = false
= ['rails']
client.update_item(item_id: item_id, title: title, body: body, restricted: restricted, tags: )
- 記事をストック
item_id = 'XXXX'
client.stock_item(item_id: item_id)
- 記事をストックから取り除く
item_id = 'XXXX'
client.delete_stock(item_id: item_id)
- 記事をストックしているかどうか調べる
item_id = 'XXXX'
res = client.check_item_stock(item_id: item_id)
- タグの記事一覧
tag_id = 'XXXX'
res = client.fetch_tag_items(teg_id: tag_id)
- 指定されたユーザの記事一覧
user_id = 'XXXX'
res = client.fetch_user_items(user_id: user_id)
- 指定されたユーザがストックした記事一覧
user_id = 'XXXX'
res = client.fetch_user_stocks(user_id: user_id)
- コメントに絵文字リアクションを付ける
comment_id = 'XXXX'
name = 'XXXX'
client.attach_reaction_to_comment(comment_id: comment_id, name: name)
- 記事に絵文字リアクションを付ける
item_id = 'XXXX'
name = 'XXXX'
client.attach_reaction_to_item(item_id: item_id, name: name)
- コメントから絵文字リアクションを削除
comment_id = 'XXXX'
reaction_name = 'XXXX'
client.delete_comment_reaction(comment_id: comment_id, reaction_name: reaction_name)
- 記事から絵文字リアクションを削除
item_id = 'XXXX'
reaction_name = 'XXXX'
client.delete_item_reaction(item_id: item_id, reaction_name: reaction_name)
- コメントに付けられた絵文字リアクション一覧
comment_id = 'XXXX'
res = client.fetch_comment_reactions(comment_id: comment_id)
- 記事に付けられた絵文字リアクション一覧
item_id = 'XXXX'
res = client.fetch_item_reactions(item_id: item_id)
- アクセストークンに紐付いたユーザを返す
res = client.fetch_authenticated_user
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Qiita::Sdk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.