qiita-sdk 0.4.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68ac447b23b637861492987978cee7e89172f092982c5945b5b17b1a7dc67303
4
- data.tar.gz: 85f5ffb2241b5366589ede70111ebf261dfc9801bc2b963d1773b4e372bfc45d
3
+ metadata.gz: 1a8e717d8a5625e9ceb54b0d8a4ae0738bcb82160ac48f9acc7ddf56023e7924
4
+ data.tar.gz: cedbe781d59d204a4ace45dff9a799241dcbb3fccfcdc28ff1d6d62915af9f72
5
5
  SHA512:
6
- metadata.gz: ffe37be6ada0bcdff6d23842504f8b5bf474ac1308204f9bee77d2b0c12c8da3674f1956cc77e7b2772dd2f98ab71096c37b33a9dc2fef2573423f43ed1f22d4
7
- data.tar.gz: 193b990a6b2fb72a5f75103b8912e0947b05004ed0ec068dd0200b7843f9320a0f896d3be189f9ed2a31c96b1c16e1fd84aad39baee0227c23bf27b1c69d003c
6
+ metadata.gz: b69c00066eecd0c805397c30536ed63024c406a04c1f014590b609cc2ff4a38b944185f3d52ea3ec52225ab6119861c7eb3d6519c0f91ceff7cb521e2283b5c7
7
+ data.tar.gz: da41d57d8b54a42c5d7133cf57a91ed963f4b93915a89c7415e72296e955b0da6ac76155313c4864fa84f7d4bd694ee7fea3edf97cdb7b1e47d764b1a26c8d5d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita-sdk (0.3.0)
4
+ qiita-sdk (0.8.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,7 +2,6 @@ require 'qiita/sdk/version'
2
2
  require 'qiita/sdk/api_actions'
3
3
  require 'qiita/sdk/client'
4
4
  require 'qiita/sdk/httpclient'
5
- require 'pry'
6
5
 
7
6
 
8
7
  module Qiita
@@ -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
- get(path)
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:, tweet: false, tags: [], restricted: false)
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
- tags: tags,
173
- private: restricted
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: nil, tags: nil)
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
- get(path)
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
- get(path)
258
+ params = {
259
+ per_page: per_page,
260
+ page: page
261
+ }
262
+
263
+ get(path, params)
247
264
  end
248
265
 
249
266
  # コメントに絵文字リアクションを付ける
@@ -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)
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Sdk
3
- VERSION = '0.4.0'.freeze
3
+ VERSION = '0.9.0'.freeze
4
4
  end
5
5
  end
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.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-05 00:00:00.000000000 Z
11
+ date: 2020-09-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: qiita sdk for ruby
14
14
  email: