qiita-sdk 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 780338808d3cf7b8d12073b34dcf52eb5636db8fca64ab564a38b7ec6eb3ebce
4
- data.tar.gz: 8171b3502aed7e42ee1201bfcffe9be28325ac8fc64c04f3cae711c1a201037d
3
+ metadata.gz: 853ebd08ba2c451c79f2185537278a546546de80f43671150396623e4727a8bd
4
+ data.tar.gz: 10a2a5b62a150b746c2c7d6360ab0d5e3f66a63bbbb368ff2aaa305adf4a1981
5
5
  SHA512:
6
- metadata.gz: cc2238a489e205915fa38a2953e4e39db89d295a06fcb3b0404215c173ef79692dfa15504b597c227071d185bfaccab1486cc8b3ffc69ded1c50707018829748
7
- data.tar.gz: b4d114f19fb603199f1994ae24e50fb89cb14bf37cda71ee37022afeb1558b518c1b772381ecad569ab711134fc9ded6aacfc88529586cdf6ce4a214ded05dbe
6
+ metadata.gz: 7157947d2bcc029467464309accfc5f05108d3d7d7894bc9354a7a5ec48658965bcd9941a74ad90bc44dd4364137f5b015ef488a60360d8b076fb3975b531d76
7
+ data.tar.gz: 82d14103b644e58f4f93a3f13d8823ad53ee4cbf75d26968f94b5b4a02230d61270e1e78ddb4db2275c898af7ec87031e93b8e966fa3dc1d94cb2fed39baca2f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita-sdk (0.4.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
@@ -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.present?
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.present?
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.5.0'.freeze
3
+ VERSION = '1.0.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.5.0
4
+ version: 1.0.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: