module Qiita::Sdk::ApiActions
Public Instance Methods
attach_reaction_to_comment(comment_id:, name:)
click to toggle source
コメントに絵文字リアクションを付ける
# File lib/qiita/sdk/api_actions.rb, line 270 def attach_reaction_to_comment(comment_id:, name:) path = "/api/v2/comments/#{comment_id}/reactions" params = { name: name } post(path, params) end
attach_reaction_to_item(item_id:, name:)
click to toggle source
記事に絵文字リアクションを付ける
# File lib/qiita/sdk/api_actions.rb, line 280 def attach_reaction_to_item(item_id:, name:) path = "/api/v2/items/#{item_id}/reactions" params = { name: name } post(path, params) end
check_following(user_id:)
click to toggle source
ユーザをフォローしている場合に204を返す
# File lib/qiita/sdk/api_actions.rb, line 132 def check_following(user_id:) path = "/api/v2/users/#{user_id}/following" get(path) end
check_item_stock(item_id:)
click to toggle source
記事をストックしているかどうか調べる
# File lib/qiita/sdk/api_actions.rb, line 232 def check_item_stock(item_id:) path = "/api/v2/items/#{item_id}/stock" get(path) end
check_tag_following(tag_id:)
click to toggle source
タグをフォローしているかどうかを調る
# File lib/qiita/sdk/api_actions.rb, line 76 def check_tag_following(tag_id:) path = "/api/v2/tags/#{tag_id}/following" get(path) end
delete_comment(comment_id:)
click to toggle source
コメントを削除
# File lib/qiita/sdk/api_actions.rb, line 12 def delete_comment(comment_id:) path = "/api/v2/comments/#{comment_id}" delete(path) end
delete_comment_reaction(comment_id:, reaction_name:)
click to toggle source
コメントから絵文字リアクションを削除
# File lib/qiita/sdk/api_actions.rb, line 290 def delete_comment_reaction(comment_id:, reaction_name:) path = "/api/v2/comments/#{comment_id}/reactions/#{reaction_name}" delete(path) end
delete_following(user_id:)
click to toggle source
ユーザへのフォローを外します。
# File lib/qiita/sdk/api_actions.rb, line 125 def delete_following(user_id:) path = "/api/v2/users/#{user_id}/following" delete(path) end
delete_item(item_id:)
click to toggle source
記事を削除
# File lib/qiita/sdk/api_actions.rb, line 188 def delete_item(item_id:) path = "/api/v2/items/#{item_id}" delete(path) end
delete_item_reaction(item_id:, reaction_name:)
click to toggle source
記事から絵文字リアクションを削除
# File lib/qiita/sdk/api_actions.rb, line 297 def delete_item_reaction(item_id:, reaction_name:) path = "/api/v2/items/#{item_id}/reactions/#{reaction_name}" delete(path) end
delete_stock(item_id:)
click to toggle source
記事をストックから取り除く
# File lib/qiita/sdk/api_actions.rb, line 225 def delete_stock(item_id:) path = "/api/v2/items/#{item_id}/stock" delete(path) end
delete_tag_following(tag_id:)
click to toggle source
タグのフォローを外す
# File lib/qiita/sdk/api_actions.rb, line 69 def delete_tag_following(tag_id:) path = "/api/v2/tags/#{tag_id}/following" delete(path) end
fetch_authenticated_user()
click to toggle source
アクセストークンに紐付いたユーザを返す
# File lib/qiita/sdk/api_actions.rb, line 318 def fetch_authenticated_user path = '/api/v2/authenticated_user' get(path) end
fetch_comment(comment_id:)
click to toggle source
コメントを取得
# File lib/qiita/sdk/api_actions.rb, line 19 def fetch_comment(comment_id:) path = "/api/v2/comments/#{comment_id}" get(path) end
fetch_comment_reactions(comment_id:)
click to toggle source
コメントに付けられた絵文字リアクション一覧
# File lib/qiita/sdk/api_actions.rb, line 304 def fetch_comment_reactions(comment_id:) path = "/api/v2/comments/#{comment_id}/reactions" get(path) end
fetch_followees(user_id:)
click to toggle source
ユーザがフォローしているユーザ一覧を取得
# File lib/qiita/sdk/api_actions.rb, line 111 def fetch_followees(user_id:) path = "/api/v2/users/#{user_id}/followees" get(path) end
fetch_followers(user_id:)
click to toggle source
ユーザをフォローしているユーザ一覧を取得
# File lib/qiita/sdk/api_actions.rb, line 118 def fetch_followers(user_id:) path = "/api/v2/users/#{user_id}/followers" get(path) end
fetch_item(item_id:)
click to toggle source
記事を取得
# File lib/qiita/sdk/api_actions.rb, line 195 def fetch_item(item_id:) path = "/api/v2/items/#{item_id}" get(path) end
fetch_item_comments(item_id:)
click to toggle source
投稿に付けられたコメント一覧
# File lib/qiita/sdk/api_actions.rb, line 37 def fetch_item_comments(item_id:) path = "/api/v2/items/#{item_id}/comments" get(path) end
fetch_item_likes(item_id:)
click to toggle source
記事につけられた「LGTM!」一覧
# File lib/qiita/sdk/api_actions.rb, line 5 def fetch_item_likes(item_id:) path = "/api/v2/items/#{item_id}/likes" get(path) end
fetch_item_reactions(item_id:)
click to toggle source
記事に付けられた絵文字リアクション一覧
# File lib/qiita/sdk/api_actions.rb, line 311 def fetch_item_reactions(item_id:) path = "/api/v2/items/#{item_id}/reactions" get(path) end
fetch_item_stockers(item_id:)
click to toggle source
記事をストックしているユーザ一覧を、ストックした日時の降順で返す
# File lib/qiita/sdk/api_actions.rb, line 90 def fetch_item_stockers(item_id:) path = "/api/v2/items/#{item_id}/stockers" get(path) end
fetch_items(per_page: 100, page: 1)
click to toggle source
記事の一覧を作成日時の降順で返す
# File lib/qiita/sdk/api_actions.rb, line 158 def fetch_items(per_page: 100, page: 1) path = '/api/v2/items' params = { per_page: per_page, page: page } get(path, params) end
fetch_my_items(per_page: 100, page: 1)
click to toggle source
認証中のユーザの記事の一覧を作成日時の降順で返す
# File lib/qiita/sdk/api_actions.rb, line 146 def fetch_my_items(per_page: 100, page: 1) path = '/api/v2/authenticated_user/items' params = { per_page: per_page, page: page } get(path, params) end
fetch_tag(tag_id:)
click to toggle source
タグを取得
# File lib/qiita/sdk/api_actions.rb, line 55 def fetch_tag(tag_id:) path = "/api/v2/tags/#{tag_id}" get(path) end
fetch_tag_items(tag_id:)
click to toggle source
タグの記事一覧
# File lib/qiita/sdk/api_actions.rb, line 239 def fetch_tag_items(tag_id:) path = "/api/v2/tags/#{tag_id}/items" get(path) end
fetch_user(user_id:)
click to toggle source
ユーザを取得
# File lib/qiita/sdk/api_actions.rb, line 104 def fetch_user(user_id:) path = "/api/v2/users/#{user_id}" get(path) end
fetch_user_items(user_id:, per_page: 100, page: 1)
click to toggle source
指定されたユーザの記事一覧
# File lib/qiita/sdk/api_actions.rb, line 246 def fetch_user_items(user_id:, per_page: 100, page: 1) path = "/api/v2/users/#{user_id}/items" params = { per_page: per_page, page: page } get(path, params) end
fetch_user_stocks(user_id:, per_page: 100, per: 1)
click to toggle source
指定されたユーザがストックした記事一覧
# File lib/qiita/sdk/api_actions.rb, line 258 def fetch_user_stocks(user_id:, per_page: 100, per: 1) path = "/api/v2/users/#{user_id}/stocks" params = { per_page: per_page, page: page } get(path, params) end
fetch_users()
click to toggle source
全てのユーザの一覧を作成日時の降順で取得
# File lib/qiita/sdk/api_actions.rb, line 97 def fetch_users path = '/api/v2/users' get(path) end
follow_tag(tag_id:)
click to toggle source
タグをフォロー
# File lib/qiita/sdk/api_actions.rb, line 83 def follow_tag(tag_id:) path = "/api/v2/tags/#{tag_id}/following" put(path, {}) end
follow_user(user_id:)
click to toggle source
ユーザをフォロー
# File lib/qiita/sdk/api_actions.rb, line 139 def follow_user(user_id:) path = "/api/v2/users/#{user_id}/following" put(path, {}) end
post_comment(item_id:, body:)
click to toggle source
記事に対してコメントを投稿
# File lib/qiita/sdk/api_actions.rb, line 44 def post_comment(item_id:, body:) path = "/api/v2/items/#{item_id}/comments" params = { body: body } post(path, params) end
post_item(title:, body:, tags: [], tweet: false, restricted: false)
click to toggle source
新たに記事を作成
# File lib/qiita/sdk/api_actions.rb, line 170 def post_item(title:, body:, tags: [], tweet: false, restricted: false) path = '/api/v2/items' params = { title: title, body: body, tweet: tweet, private: restricted, } raise 'タグは最低一つ設定してください' if tags.empty? tag_params = tags.map { |tag| { name: tag } } params.merge!({tags: tag_params}) post(path, params) end
stock_item(item_id:)
click to toggle source
記事をストック
# File lib/qiita/sdk/api_actions.rb, line 218 def stock_item(item_id:) path = "/api/v2/items/#{item_id}/stock" put(path, {}) end
update_comment(comment_id:, body:)
click to toggle source
コメントを更新
# File lib/qiita/sdk/api_actions.rb, line 26 def update_comment(comment_id:, body:) path = "/api/v2/comments/#{comment_id}" params = { body: body } patch(path, params) end
update_item(item_id:, title: nil, body: nil, restricted: false, tags: [])
click to toggle source
記事を更新
# File lib/qiita/sdk/api_actions.rb, line 202 def update_item(item_id:, title: nil, body: nil, restricted: false, tags: []) path = "/api/v2/items/#{item_id}" params = { title: title, body: body, private: restricted, } tag_params = tags.map { |tag| { name: tag } } params.merge!({tags: tag_params}) if !tags.empty? patch(path, params) end