qiita-sdk 0.4.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qiita/sdk.rb +0 -1
- data/lib/qiita/sdk/api_actions.rb +29 -12
- data/lib/qiita/sdk/client.rb +4 -4
- data/lib/qiita/sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a8e717d8a5625e9ceb54b0d8a4ae0738bcb82160ac48f9acc7ddf56023e7924
|
4
|
+
data.tar.gz: cedbe781d59d204a4ace45dff9a799241dcbb3fccfcdc28ff1d6d62915af9f72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b69c00066eecd0c805397c30536ed63024c406a04c1f014590b609cc2ff4a38b944185f3d52ea3ec52225ab6119861c7eb3d6519c0f91ceff7cb521e2283b5c7
|
7
|
+
data.tar.gz: da41d57d8b54a42c5d7133cf57a91ed963f4b93915a89c7415e72296e955b0da6ac76155313c4864fa84f7d4bd694ee7fea3edf97cdb7b1e47d764b1a26c8d5d
|
data/Gemfile.lock
CHANGED
data/lib/qiita/sdk.rb
CHANGED
@@ -143,10 +143,15 @@ module Qiita
|
|
143
143
|
end
|
144
144
|
|
145
145
|
# 認証中のユーザの記事の一覧を作成日時の降順で返す
|
146
|
-
def fetch_my_items
|
146
|
+
def fetch_my_items(per_page: 100, page: 1)
|
147
147
|
path = '/api/v2/authenticated_user/items'
|
148
148
|
|
149
|
-
|
149
|
+
params = {
|
150
|
+
per_page: per_page,
|
151
|
+
page: page
|
152
|
+
}
|
153
|
+
|
154
|
+
get(path, params)
|
150
155
|
end
|
151
156
|
|
152
157
|
# 記事の一覧を作成日時の降順で返す
|
@@ -162,15 +167,15 @@ module Qiita
|
|
162
167
|
end
|
163
168
|
|
164
169
|
# 新たに記事を作成
|
165
|
-
def post_item(title:, body:,
|
170
|
+
def post_item(title:, body:, tags: [], tweet: false, restricted: false)
|
166
171
|
path = '/api/v2/items'
|
167
172
|
|
168
173
|
params = {
|
169
174
|
title: title,
|
170
175
|
body: body,
|
171
176
|
tweet: tweet,
|
172
|
-
|
173
|
-
|
177
|
+
private: restricted,
|
178
|
+
tags: tags.map { |tag| {name: tag} }
|
174
179
|
}
|
175
180
|
|
176
181
|
post(path, params)
|
@@ -191,16 +196,18 @@ module Qiita
|
|
191
196
|
end
|
192
197
|
|
193
198
|
# 記事を更新
|
194
|
-
def update_item(item_id:, title: nil, body: nil, restricted:
|
199
|
+
def update_item(item_id:, title: nil, body: nil, restricted: false, tags: [])
|
195
200
|
path = "/api/v2/items/#{item_id}"
|
196
201
|
params = {
|
197
|
-
item_id: item_id,
|
198
202
|
title: title,
|
199
203
|
body: body,
|
200
204
|
private: restricted,
|
201
|
-
tags: tags
|
202
205
|
}
|
203
206
|
|
207
|
+
tag_params = tags.map { |tag| { name: tag } }
|
208
|
+
|
209
|
+
params.merge!({tags: tag_params}) if tags.present?
|
210
|
+
|
204
211
|
patch(path, params)
|
205
212
|
end
|
206
213
|
|
@@ -233,17 +240,27 @@ module Qiita
|
|
233
240
|
end
|
234
241
|
|
235
242
|
# 指定されたユーザの記事一覧
|
236
|
-
def fetch_user_items(user_id:)
|
243
|
+
def fetch_user_items(user_id:, per_page: 100, page: 1)
|
237
244
|
path = "/api/v2/users/#{user_id}/items"
|
238
245
|
|
239
|
-
|
246
|
+
params = {
|
247
|
+
per_page: per_page,
|
248
|
+
page: page
|
249
|
+
}
|
250
|
+
|
251
|
+
get(path, params)
|
240
252
|
end
|
241
253
|
|
242
254
|
# 指定されたユーザがストックした記事一覧
|
243
|
-
def fetch_user_stocks(user_id:)
|
255
|
+
def fetch_user_stocks(user_id:, per_page: 100, per: 1)
|
244
256
|
path = "/api/v2/users/#{user_id}/stocks"
|
245
257
|
|
246
|
-
|
258
|
+
params = {
|
259
|
+
per_page: per_page,
|
260
|
+
page: page
|
261
|
+
}
|
262
|
+
|
263
|
+
get(path, params)
|
247
264
|
end
|
248
265
|
|
249
266
|
# コメントに絵文字リアクションを付ける
|
data/lib/qiita/sdk/client.rb
CHANGED
@@ -32,25 +32,25 @@ module Qiita
|
|
32
32
|
headers
|
33
33
|
end
|
34
34
|
|
35
|
-
def get(path, params)
|
35
|
+
def get(path, params = {})
|
36
36
|
url = endpoint + path
|
37
37
|
httpclient = HTTPClient.new
|
38
38
|
httpclient.get(url, params, headers)
|
39
39
|
end
|
40
40
|
|
41
|
-
def patch(path, params)
|
41
|
+
def patch(path, params = {})
|
42
42
|
url = endpoint + path
|
43
43
|
httpclient = HTTPClient.new
|
44
44
|
httpclient.patch(url, params.to_json, headers)
|
45
45
|
end
|
46
46
|
|
47
|
-
def put(path, params)
|
47
|
+
def put(path, params = {})
|
48
48
|
url = endpoint + path
|
49
49
|
httpclient = HTTPClient.new
|
50
50
|
httpclient.put(url, params)
|
51
51
|
end
|
52
52
|
|
53
|
-
def post(path, params)
|
53
|
+
def post(path, params = {})
|
54
54
|
url = endpoint + path
|
55
55
|
httpclient = HTTPClient.new
|
56
56
|
httpclient.post(url, params.to_json, headers)
|
data/lib/qiita/sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sibakeny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: qiita sdk for ruby
|
14
14
|
email:
|