qiita-sdk 0.6.0 → 1.1.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: 2716dbba91a8409b7ce9d46224d0a4ece49295afdb823247051397d9c16a845e
4
- data.tar.gz: f3e95589615131bfd2f81ffeaec87b38d31a85d55493d24772d6dd6a85596b8f
3
+ metadata.gz: 311e36c1a5a0355fa1e0bda4a180bce0e2e50c752d22b50f84b95ec05ff467df
4
+ data.tar.gz: b90bef94e1d7adb2e924f094416002d6658105ff21ddf7a9a1a4a3be3f4577af
5
5
  SHA512:
6
- metadata.gz: 0e5f0c1e411c30547513a461603056a63492677a33c3e75ea6a236b6c8f1214a0f611a9752ee705b2201d91c1111298e0b90fca671d73a5a8adca9c4549e231d
7
- data.tar.gz: 69741e730d90d4d00d35c2e2162c6342ab2990b122485eec5c0a73b543b07fd3fe4a20470b60237832689acf58ba43d19ec9122991bf60b20df04880c89eacc3
6
+ metadata.gz: 11227f48d4e195cc3d1ec554ebb6b47a05562eefc85c302e323119361e28c6b7c1a26edaf149122108a4e74c8ded987b5549c7d1044be5fb2cbb7d562e6ddf53
7
+ data.tar.gz: 595910ea815db143e96003cd4433e160fbc083eb5e55a933a51f7a952a2d855a2007980fd731de28a0ca84c7157b803fd42285e927487e2bf23da747a4faa9a0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita-sdk (0.4.0)
4
+ qiita-sdk (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -167,17 +167,20 @@ module Qiita
167
167
  end
168
168
 
169
169
  # 新たに記事を作成
170
- def post_item(title:, body:, tweet: false, tags: [], restricted: false)
170
+ def post_item(title:, body:, tags: [], tweet: false, restricted: false)
171
171
  path = '/api/v2/items'
172
172
 
173
173
  params = {
174
174
  title: title,
175
175
  body: body,
176
176
  tweet: tweet,
177
- tags: tags,
178
- private: restricted
177
+ private: restricted,
179
178
  }
180
179
 
180
+ tag_params = tags.map { |tag| { name: tag } }
181
+
182
+ params.merge!({tags: tag_params}) if !tags.empty?
183
+
181
184
  post(path, params)
182
185
  end
183
186
 
@@ -196,16 +199,18 @@ module Qiita
196
199
  end
197
200
 
198
201
  # 記事を更新
199
- def update_item(item_id:, title: nil, body: nil, restricted: nil, tags: nil)
202
+ def update_item(item_id:, title: nil, body: nil, restricted: false, tags: [])
200
203
  path = "/api/v2/items/#{item_id}"
201
204
  params = {
202
- item_id: item_id,
203
205
  title: title,
204
206
  body: body,
205
207
  private: restricted,
206
- tags: tags
207
208
  }
208
209
 
210
+ tag_params = tags.map { |tag| { name: tag } }
211
+
212
+ params.merge!({tags: tag_params}) if !tags.empty?
213
+
209
214
  patch(path, params)
210
215
  end
211
216
 
@@ -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.6.0'.freeze
3
+ VERSION = '1.1.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.6.0
4
+ version: 1.1.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-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: qiita sdk for ruby
14
14
  email: