Module: Qiita::Sdk::ApiActions

Included in:
Client
Defined in:
lib/qiita/sdk/api_actions.rb

Instance Method Summary collapse

Instance Method Details

#attach_reaction_to_comment(comment_id:, name:) ⇒ Object

コメントに絵文字リアクションを付ける



262
263
264
265
266
267
268
269
# File 'lib/qiita/sdk/api_actions.rb', line 262

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:) ⇒ Object

記事に絵文字リアクションを付ける



272
273
274
275
276
277
278
279
# File 'lib/qiita/sdk/api_actions.rb', line 272

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:) ⇒ Object

ユーザをフォローしている場合に204を返す



132
133
134
135
136
# 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:) ⇒ Object

記事をストックしているかどうか調べる



224
225
226
227
228
# File 'lib/qiita/sdk/api_actions.rb', line 224

def check_item_stock(item_id:)
  path = "/api/v2/items/#{item_id}/stock"

  get(path)
end

#check_tag_following(tag_id:) ⇒ Object

タグをフォローしているかどうかを調る



76
77
78
79
80
# 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:) ⇒ Object

コメントを削除



12
13
14
15
16
# 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:) ⇒ Object

コメントから絵文字リアクションを削除



282
283
284
285
286
# File 'lib/qiita/sdk/api_actions.rb', line 282

def delete_comment_reaction(comment_id:, reaction_name:)
  path = "/api/v2/comments/#{comment_id}/reactions/#{reaction_name}"

  delete(path)
end

#delete_following(user_id:) ⇒ Object

ユーザへのフォローを外します。



125
126
127
128
129
# 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:) ⇒ Object

記事を削除



184
185
186
187
188
# File 'lib/qiita/sdk/api_actions.rb', line 184

def delete_item(item_id:)
  path = "/api/v2/items/#{item_id}"

  delete(path)
end

#delete_item_reaction(item_id:, reaction_name:) ⇒ Object

記事から絵文字リアクションを削除



289
290
291
292
293
# File 'lib/qiita/sdk/api_actions.rb', line 289

def delete_item_reaction(item_id:, reaction_name:)
  path = "/api/v2/items/#{item_id}/reactions/#{reaction_name}"

  delete(path)
end

#delete_stock(item_id:) ⇒ Object

記事をストックから取り除く



217
218
219
220
221
# File 'lib/qiita/sdk/api_actions.rb', line 217

def delete_stock(item_id:)
  path = "/api/v2/items/#{item_id}/stock"

  delete(path)
end

#delete_tag_following(tag_id:) ⇒ Object

タグのフォローを外す



69
70
71
72
73
# 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_userObject

アクセストークンに紐付いたユーザを返す



310
311
312
313
314
# File 'lib/qiita/sdk/api_actions.rb', line 310

def fetch_authenticated_user
  path = '/api/v2/authenticated_user'

  get(path)
end

#fetch_comment(comment_id:) ⇒ Object

コメントを取得



19
20
21
22
23
# 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:) ⇒ Object

コメントに付けられた絵文字リアクション一覧



296
297
298
299
300
# File 'lib/qiita/sdk/api_actions.rb', line 296

def fetch_comment_reactions(comment_id:)
  path = "/api/v2/comments/#{comment_id}/reactions"

  get(path)
end

#fetch_followees(user_id:) ⇒ Object

ユーザがフォローしているユーザ一覧を取得



111
112
113
114
115
# 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:) ⇒ Object

ユーザをフォローしているユーザ一覧を取得



118
119
120
121
122
# 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_following_tags(user_id:) ⇒ Object

ユーザがフォローしているタグ一覧



62
63
64
65
66
# File 'lib/qiita/sdk/api_actions.rb', line 62

def fetch_following_tags(user_id:)
  path = "/api/v2/users/#{user_id}/following_tags"

  get(path)
end

#fetch_item(item_id:) ⇒ Object

記事を取得



191
192
193
194
195
# File 'lib/qiita/sdk/api_actions.rb', line 191

def fetch_item(item_id:)
  path = "/api/v2/items/#{item_id}"

  get(path)
end

#fetch_item_comments(item_id:) ⇒ Object

投稿に付けられたコメント一覧



37
38
39
40
41
# 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:) ⇒ Object

記事につけられた「LGTM!」一覧



5
6
7
8
9
# 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:) ⇒ Object

記事に付けられた絵文字リアクション一覧



303
304
305
306
307
# File 'lib/qiita/sdk/api_actions.rb', line 303

def fetch_item_reactions(item_id:)
  path = "/api/v2/items/#{item_id}/reactions"

  get(path)
end

#fetch_item_stockers(item_id:) ⇒ Object

記事をストックしているユーザ一覧を、ストックした日時の降順で返す



90
91
92
93
94
# 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) ⇒ Object

記事の一覧を作成日時の降順で返す



158
159
160
161
162
163
164
165
166
167
# 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) ⇒ Object

認証中のユーザの記事の一覧を作成日時の降順で返す



146
147
148
149
150
151
152
153
154
155
# 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:) ⇒ Object

タグを取得



55
56
57
58
59
# 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:) ⇒ Object

タグの記事一覧



231
232
233
234
235
# File 'lib/qiita/sdk/api_actions.rb', line 231

def fetch_tag_items(tag_id:)
  path = "/api/v2/tags/#{tag_id}/items"

  get(path)
end

#fetch_user(user_id:) ⇒ Object

ユーザを取得



104
105
106
107
108
# 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) ⇒ Object

指定されたユーザの記事一覧



238
239
240
241
242
243
244
245
246
247
# File 'lib/qiita/sdk/api_actions.rb', line 238

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) ⇒ Object

指定されたユーザがストックした記事一覧



250
251
252
253
254
255
256
257
258
259
# File 'lib/qiita/sdk/api_actions.rb', line 250

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_usersObject

全てのユーザの一覧を作成日時の降順で取得



97
98
99
100
101
# File 'lib/qiita/sdk/api_actions.rb', line 97

def fetch_users
  path = '/api/v2/users'

  get(path)
end

#follow_tag(tag_id:) ⇒ Object

タグをフォロー



83
84
85
86
87
# 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:) ⇒ Object

ユーザをフォロー



139
140
141
142
143
# 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:) ⇒ Object

記事に対してコメントを投稿



44
45
46
47
48
49
50
51
52
# 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:, tweet: false, restricted: false) ⇒ Object

新たに記事を作成



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/qiita/sdk/api_actions.rb', line 170

def post_item(title:, body:, tweet: false, restricted: false)
  path = '/api/v2/items'

  params = {
    title: title,
    body: body,
    tweet: tweet,
    private: restricted
  }

  post(path, params)
end

#stock_item(item_id:) ⇒ Object

記事をストック



210
211
212
213
214
# File 'lib/qiita/sdk/api_actions.rb', line 210

def stock_item(item_id:)
  path = "/api/v2/items/#{item_id}/stock"

  put(path, {})
end

#update_comment(comment_id:, body:) ⇒ Object

コメントを更新



26
27
28
29
30
31
32
33
34
# 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) ⇒ Object

記事を更新



198
199
200
201
202
203
204
205
206
207
# File 'lib/qiita/sdk/api_actions.rb', line 198

def update_item(item_id:, title: nil, body: nil, restricted: false)
  path = "/api/v2/items/#{item_id}"
  params = {
    title: title,
    body: body,
    private: restricted,
  }

  patch(path, params)
end