qiita-sdk 0.1.0 → 0.1.1

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: ef3399319b6663a45463b626c00587b01e17a82d6dcc659cda6e20ab88b09a86
4
- data.tar.gz: 102404f6146bdc3e1da5d34aa9888d8a6f1be4eec348c63a56528d0ecb74ec6c
3
+ metadata.gz: b720e463407c691d1fc4316968eb83bfb10ad842e74fd6cec3f2d1a3a2ec0c6d
4
+ data.tar.gz: effae48c571e4cdc3b112f03b1362effd7d8f535c3c8222626acaa08f382bd29
5
5
  SHA512:
6
- metadata.gz: 637a211f86a0afa7148f5c9411dd088c6bfd425c9495a66310f683959bf1870ee2c8a4cb5d8b07967a1ba982d990210f1ac5430700b3839b259c1dd06acd33f6
7
- data.tar.gz: b4cccf3edaa50a4e6794d027776ff963da8d63a4e45c7f54e44f10f8e98f6489bd1f1e4a341c486e141bbb90019b81d461d65737b2a52a444f4db7079f92021a
6
+ metadata.gz: 5f775f6ee09dc34cd50c377e7948958f4334647091a97a79928e8eeec1cc0004e38ce5bee07e33da6c7ba14801932c31414b9502f9ec828d6cdc1d3f8ffc1a55
7
+ data.tar.gz: 17241491a0797797e44cdb4520d048999ed147bfdc18dc609a73055729cc4ecd2bb818119b2b4f9ed65b6ba0b53859fc1825931423bf67676d0ed2a25875f013
@@ -0,0 +1,14 @@
1
+ Style/AsciiComments:
2
+ Enabled: false
3
+
4
+ Style/FrozenStringLiteralComment:
5
+ Enabled: false
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Metrics/BlockLength:
11
+ Enabled: false
12
+
13
+ Metrics/ModuleLength:
14
+ Enabled: false
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in qiita-sdk.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
6
+ gem 'rake', '~> 12.0'
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'rubocop'
9
+ gem 'webmock'
@@ -6,8 +6,21 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ addressable (2.7.0)
10
+ public_suffix (>= 2.0.2, < 5.0)
11
+ ast (2.4.1)
12
+ crack (0.4.3)
13
+ safe_yaml (~> 1.0.0)
9
14
  diff-lcs (1.4.4)
15
+ hashdiff (1.0.1)
16
+ parallel (1.19.2)
17
+ parser (2.7.1.4)
18
+ ast (~> 2.4.1)
19
+ public_suffix (4.0.5)
20
+ rainbow (3.0.0)
10
21
  rake (12.3.3)
22
+ regexp_parser (1.7.1)
23
+ rexml (3.2.4)
11
24
  rspec (3.9.0)
12
25
  rspec-core (~> 3.9.0)
13
26
  rspec-expectations (~> 3.9.0)
@@ -21,6 +34,24 @@ GEM
21
34
  diff-lcs (>= 1.2.0, < 2.0)
22
35
  rspec-support (~> 3.9.0)
23
36
  rspec-support (3.9.3)
37
+ rubocop (0.89.1)
38
+ parallel (~> 1.10)
39
+ parser (>= 2.7.1.1)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 1.7)
42
+ rexml
43
+ rubocop-ast (>= 0.3.0, < 1.0)
44
+ ruby-progressbar (~> 1.7)
45
+ unicode-display_width (>= 1.4.0, < 2.0)
46
+ rubocop-ast (0.3.0)
47
+ parser (>= 2.7.1.4)
48
+ ruby-progressbar (1.10.1)
49
+ safe_yaml (1.0.5)
50
+ unicode-display_width (1.7.0)
51
+ webmock (3.8.3)
52
+ addressable (>= 2.3.6)
53
+ crack (>= 0.3.2)
54
+ hashdiff (>= 0.4.0, < 2.0.0)
24
55
 
25
56
  PLATFORMS
26
57
  ruby
@@ -29,6 +60,8 @@ DEPENDENCIES
29
60
  qiita-sdk!
30
61
  rake (~> 12.0)
31
62
  rspec (~> 3.0)
63
+ rubocop
64
+ webmock
32
65
 
33
66
  BUNDLED WITH
34
67
  2.1.4
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "qiita/sdk"
3
+ require 'bundler/setup'
4
+ require 'qiita/sdk'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "qiita/sdk"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,12 +1,10 @@
1
- require "qiita/sdk/version"
1
+ require 'qiita/sdk/version'
2
+ require 'qiita/sdk/api_actions'
2
3
  require 'qiita/sdk/client'
3
4
  require 'qiita/sdk/httpclient'
4
5
 
5
6
  module Qiita
6
7
  module Sdk
7
8
  class Error < StandardError; end
8
- def self.greet
9
- p "hello"
10
- end
11
9
  end
12
10
  end
@@ -0,0 +1,300 @@
1
+ module Qiita
2
+ module Sdk
3
+ module ApiActions
4
+ # 記事につけられた「LGTM!」一覧
5
+ def fetch_item_likes(item_id:)
6
+ path = "/api/v2/items/#{item_id}/likes"
7
+
8
+ get(path)
9
+ end
10
+
11
+ # コメントを削除
12
+ def delete_comment(comment_id:)
13
+ path = "/api/v2/comments/#{comment_id}"
14
+
15
+ delete(path)
16
+ end
17
+
18
+ # コメントを取得
19
+ def fetch_comment(comment_id:)
20
+ path = "/api/v2/comments/#{comment_id}"
21
+
22
+ get(path)
23
+ end
24
+
25
+ # コメントを更新
26
+ def update_comment(comment_id:, body:)
27
+ path = "/api/v2/comments/#{comment_id}"
28
+
29
+ params = {
30
+ body: body
31
+ }
32
+
33
+ patch(path, params)
34
+ end
35
+
36
+ # 投稿に付けられたコメント一覧
37
+ def fetch_item_comments(item_id:)
38
+ path = "/api/v2/items/#{item_id}/comments"
39
+
40
+ get(path)
41
+ end
42
+
43
+ # 記事に対してコメントを投稿
44
+ def post_comment(item_id:, body:)
45
+ path = "/api/v2/items/#{item_id}/comments"
46
+
47
+ params = {
48
+ body: body
49
+ }
50
+
51
+ post(path, params)
52
+ end
53
+
54
+ # タグを取得
55
+ def fetch_tag(tag_id:)
56
+ path = "/api/v2/tags/#{tag_id}"
57
+
58
+ get(path)
59
+ end
60
+
61
+ # ユーザがフォローしているタグ一覧
62
+ def fetch_following_tags(user_id:)
63
+ path = "/api/v2/users/#{user_id}/following_tags"
64
+
65
+ get(path)
66
+ end
67
+
68
+ # タグのフォローを外す
69
+ def delete_tag_following(tag_id:)
70
+ path = "/api/v2/tags/#{tag_id}/following"
71
+
72
+ delete(path)
73
+ end
74
+
75
+ # タグをフォローしているかどうかを調る
76
+ def check_tag_following(tag_id:)
77
+ path = "/api/v2/tags/#{tag_id}/following"
78
+
79
+ get(path)
80
+ end
81
+
82
+ # タグをフォロー
83
+ def follow_tag(tag_id:)
84
+ path = "/api/v2/tags/#{tag_id}/following"
85
+
86
+ put(path, {})
87
+ end
88
+
89
+ # 記事をストックしているユーザ一覧を、ストックした日時の降順で返す
90
+ def fetch_item_stockers(item_id:)
91
+ path = "/api/v2/items/#{item_id}/stockers"
92
+
93
+ get(path)
94
+ end
95
+
96
+ # 全てのユーザの一覧を作成日時の降順で取得
97
+ def fetch_users
98
+ path = '/api/v2/users'
99
+
100
+ get(path)
101
+ end
102
+
103
+ # ユーザを取得
104
+ def fetch_user(user_id:)
105
+ path = "/api/v2/users/#{user_id}"
106
+
107
+ get(path)
108
+ end
109
+
110
+ # ユーザがフォローしているユーザ一覧を取得
111
+ def fetch_followees(user_id:)
112
+ path = "/api/v2/users/#{user_id}/followees"
113
+
114
+ get(path)
115
+ end
116
+
117
+ # ユーザをフォローしているユーザ一覧を取得
118
+ def fetch_followers(user_id:)
119
+ path = "/api/v2/users/#{user_id}/followers"
120
+
121
+ get(path)
122
+ end
123
+
124
+ # ユーザへのフォローを外します。
125
+ def delete_following(user_id:)
126
+ path = "/api/v2/users/#{user_id}/following"
127
+
128
+ delete(path)
129
+ end
130
+
131
+ # ユーザをフォローしている場合に204を返す
132
+ def check_following(user_id:)
133
+ path = "/api/v2/users/#{user_id}/following"
134
+
135
+ get(path)
136
+ end
137
+
138
+ # ユーザをフォロー
139
+ def follow_user(user_id:)
140
+ path = "/api/v2/users/#{user_id}/following"
141
+
142
+ put(path, {})
143
+ end
144
+
145
+ # 認証中のユーザの記事の一覧を作成日時の降順で返す
146
+ def fetch_my_items
147
+ path = '/api/v2/authenticated_user/items'
148
+
149
+ get(path)
150
+ end
151
+
152
+ # 記事の一覧を作成日時の降順で返す
153
+ def fetch_items
154
+ path = '/api/v2/items'
155
+
156
+ get(path)
157
+ end
158
+
159
+ # 新たに記事を作成
160
+ def post_item(title:, body:, tweet: false, tags: [], restricted: false)
161
+ path = '/api/v2/items'
162
+
163
+ params = {
164
+ title: title,
165
+ body: body,
166
+ tweet: tweet,
167
+ tags: tags,
168
+ private: restricted
169
+ }
170
+
171
+ post(path, params)
172
+ end
173
+
174
+ # 記事を削除
175
+ def delete_item(item_id:)
176
+ path = "/api/v2/items/#{item_id}"
177
+
178
+ delete(path)
179
+ end
180
+
181
+ # 記事を取得
182
+ def fetch_item(item_id:)
183
+ path = "/api/v2/items/#{item_id}"
184
+
185
+ get(path)
186
+ end
187
+
188
+ # 記事を更新
189
+ def update_item(item_id:, title: nil, body: nil, restricted: nil, tags: nil)
190
+ path = "/api/v2/items/#{item_id}"
191
+ params = {
192
+ item_id: item_id,
193
+ title: title,
194
+ body: body,
195
+ private: restricted,
196
+ tags: tags
197
+ }
198
+
199
+ patch(path, params)
200
+ end
201
+
202
+ # 記事をストック
203
+ def stock_item(item_id:)
204
+ path = "/api/v2/items/#{item_id}/stock"
205
+
206
+ put(path, {})
207
+ end
208
+
209
+ # 記事をストックから取り除く
210
+ def delete_stock(item_id:)
211
+ path = "/api/v2/items/#{item_id}/stock"
212
+
213
+ delete(path)
214
+ end
215
+
216
+ # 記事をストックしているかどうか調べる
217
+ def check_item_stock(item_id:)
218
+ path = "/api/v2/items/#{item_id}/stock"
219
+
220
+ get(path)
221
+ end
222
+
223
+ # タグの記事一覧
224
+ def fetch_tag_items(tag_id:)
225
+ path = "/api/v2/tags/#{tag_id}/items"
226
+
227
+ get(path)
228
+ end
229
+
230
+ # 指定されたユーザの記事一覧
231
+ def fetch_user_items(user_id:)
232
+ path = "/api/v2/tags/#{user_id}/items"
233
+
234
+ get(path)
235
+ end
236
+
237
+ # 指定されたユーザがストックした記事一覧
238
+ def fetch_user_stocks(user_id:)
239
+ path = "/api/v2/users/#{user_id}/stocks"
240
+
241
+ get(path)
242
+ end
243
+
244
+ # コメントに絵文字リアクションを付ける
245
+ def attach_reaction_to_comment(comment_id:, name:)
246
+ path = "/api/v2/comments/#{comment_id}/reactions"
247
+ params = {
248
+ name: name
249
+ }
250
+
251
+ post(path, params)
252
+ end
253
+
254
+ # 記事に絵文字リアクションを付ける
255
+ def attach_reaction_to_item(item_id:, name:)
256
+ path = "/api/v2/items/#{item_id}/reactions"
257
+ params = {
258
+ name: name
259
+ }
260
+
261
+ post(path, params)
262
+ end
263
+
264
+ # コメントから絵文字リアクションを削除
265
+ def delete_comment_reaction(comment_id:, reaction_name:)
266
+ path = "/api/v2/comments/#{comment_id}/reactions/#{reaction_name}"
267
+
268
+ delete(path)
269
+ end
270
+
271
+ # 記事から絵文字リアクションを削除
272
+ def delete_item_reaction(item_id:, reaction_name:)
273
+ path = "/api/v2/items/#{item_id}/reactions/#{reaction_name}"
274
+
275
+ delete(path)
276
+ end
277
+
278
+ # コメントに付けられた絵文字リアクション一覧
279
+ def fetch_comment_reactions(comment_id:)
280
+ path = "/api/v2/comments/#{comment_id}/reactions"
281
+
282
+ get(path)
283
+ end
284
+
285
+ # 記事に付けられた絵文字リアクション一覧
286
+ def fetch_item_reactions(item_id:)
287
+ path = "/api/v2/items/#{item_id}/reactions"
288
+
289
+ get(path)
290
+ end
291
+
292
+ # アクセストークンに紐付いたユーザを返す
293
+ def fetch_authenticated_user
294
+ path = '/api/v2/authenticated_user'
295
+
296
+ get(path)
297
+ end
298
+ end
299
+ end
300
+ end
@@ -5,366 +5,65 @@ module Qiita
5
5
  require 'uri'
6
6
  require 'json'
7
7
 
8
- API_BASE_URL = 'https://qiita.com'
8
+ include Qiita::Sdk::ApiActions
9
9
 
10
- DEFAULT_HEADERS = {
11
- "Accept" => "application/json",
12
- "Content-Type" => "application/json"
13
- }
10
+ # @return [String]
11
+ attr_accessor :access_token
14
12
 
15
- def initialize(access_token: nil)
16
- @access_token = access_token
13
+ API_BASE_URL = 'https://qiita.com'.freeze
14
+
15
+ def initialize(options = {})
16
+ options.each do |key, value|
17
+ instance_variable_set("@#{key}", value)
18
+ end
19
+ yield(self) if block_given?
20
+ end
21
+
22
+ def credential
23
+ "Bearer #{@access_token}" if @access_token
17
24
  end
18
25
 
19
- def default_headers
20
- headers = DEFAULT_HEADERS.clone
21
- headers["Authorization"] = "Bearer #{@access_token}" if @access_token
26
+ def headers
27
+ headers = {
28
+ 'Accept' => 'application/json',
29
+ 'Content-Type' => 'application/json'
30
+ }
31
+ headers['Authorization'] = credential if credential
22
32
  headers
23
33
  end
24
34
 
25
- def get(url)
35
+ def get(path)
36
+ url = endpoint + path
26
37
  httpclient = HTTPClient.new
27
- httpclient.get(url, default_headers)
38
+ httpclient.get(url, headers)
28
39
  end
29
40
 
30
- def patch(url, params)
41
+ def patch(path, params)
42
+ url = endpoint + path
31
43
  httpclient = HTTPClient.new
32
- httpclient.patch(url, params.to_json, default_headers)
44
+ httpclient.patch(url, params.to_json, headers)
33
45
  end
34
46
 
35
- def put(url)
47
+ def put(path, params)
48
+ url = endpoint + path
36
49
  httpclient = HTTPClient.new
37
- httpclient.put(url)
50
+ httpclient.put(url, params)
38
51
  end
39
52
 
40
- def post(url, params)
53
+ def post(path, params)
54
+ url = endpoint + path
41
55
  httpclient = HTTPClient.new
42
- httpclient.post(url, params.to_json, default_headers)
56
+ httpclient.post(url, params.to_json, headers)
43
57
  end
44
58
 
45
- def delete(url)
59
+ def delete(path)
60
+ url = endpoint + path
46
61
  httpclient = HTTPClient.new
47
62
  httpclient.delete(url)
48
63
  end
49
64
 
50
- # 全てのユーザの一覧
51
- def fetch_users
52
- path = '/api/v2/users'
53
- url = API_BASE_URL + path
54
-
55
- get(url)
56
- end
57
-
58
- # 記事につけられた「LGTM!」一覧
59
- def fetch_item_likes(item_id:)
60
- path = "/api/v2/items/#{item_id}/likes"
61
- url = API_BASE_URL + path
62
-
63
- get(url)
64
- end
65
-
66
- # コメントを削除
67
- def delete_comment(comment_id:)
68
- path = "/api/v2/comments/#{comment_id}"
69
- url = API_BASE_URL + path
70
-
71
- delete(url)
72
- end
73
-
74
- # コメントを取得
75
- def fetch_comment(comment_id:)
76
- path = "/api/v2/comments/#{comment_id}"
77
- url = API_BASE_URL + path
78
-
79
- get(url)
80
- end
81
-
82
- # コメントを更新
83
- def update_comment(comment_id:, body:)
84
- path = "/api/v2/comments/#{comment_id}"
85
- url = API_BASE_URL + path
86
-
87
- params = {
88
- body: body
89
- }
90
-
91
- patch(url, params)
92
- end
93
-
94
- # 投稿に付けられたコメント一覧
95
- def fetch_item_comments(item_id:)
96
- path = "/api/v2/items/#{item_id}/comments"
97
- url = API_BASE_URL + path
98
-
99
- get(url)
100
- end
101
-
102
- # 記事に対してコメントを投稿
103
- def post_comment(item_id:, body:)
104
- path = "/api/v2/items/#{item_id}/comments"
105
- url = API_BASE_URL + path
106
-
107
- params = {
108
- body: body
109
- }
110
-
111
- post(url, params)
112
- end
113
-
114
- # タグを取得
115
- def fetch_tag(tag_id:)
116
- path = "/api/v2/tags/#{tag_id}"
117
- url = API_BASE_URL + path
118
-
119
- get(url)
120
- end
121
-
122
- # ユーザがフォローしているタグ一覧
123
- def fetch_following_tags(user_id:)
124
- path = "/api/v2/users/#{user_id}/following_tags"
125
- url = API_BASE_URL + path
126
-
127
- get(url)
128
- end
129
-
130
- # タグのフォローを外す
131
- def delete_following(tag_id:)
132
- path = "/api/v2/tags/#{tag_id}/following"
133
- url = API_BASE_URL + path
134
-
135
- delete(url)
136
- end
137
-
138
- # タグをフォローしているかどうかを調る
139
- def check_tag_following(tag_id:)
140
- path = "/api/v2/tags/#{tag_id}/following"
141
- url = API_BASE_URL + path
142
-
143
- get(url)
144
- end
145
-
146
- # タグをフォロー
147
- def follow_tag(tag_id:)
148
- path = "/api/v2/tags/#{tag_id}/following"
149
- url = API_BASE_URL + path
150
-
151
- put(url)
152
- end
153
-
154
- # 記事をストックしているユーザ一覧を、ストックした日時の降順で返す
155
- def fetch_item_stockers(item_id:)
156
- path = "/api/v2/items/#{item_id}/stockers"
157
- url = API_BASE_URL + path
158
-
159
- get(url)
160
- end
161
-
162
- # 全てのユーザの一覧を作成日時の降順で取得
163
- def fetch_users
164
- path = "/api/v2/users"
165
- url = API_BASE_URL + path
166
-
167
- get(url)
168
- end
169
-
170
- # ユーザを取得
171
- def fetch_user(user_id:)
172
- path = "/api/v2/users/#{user_id}"
173
- url = API_BASE_URL + path
174
-
175
- get(url)
176
- end
177
-
178
- # ユーザがフォローしているユーザ一覧を取得
179
- def fetch_followees(user_id:)
180
- path = "/api/v2/users/#{user_id}/followees"
181
- url = API_BASE_URL + path
182
-
183
- get(url)
184
- end
185
-
186
- # ユーザをフォローしているユーザ一覧を取得
187
- def fetch_followers(user_id:)
188
- path = "/api/v2/users/#{user_id}/followers"
189
- url = API_BASE_URL + path
190
-
191
- get(url)
192
- end
193
-
194
- # ユーザへのフォローを外します。
195
- def delete_following(user_id:)
196
- path = "/api/v2/users/#{user_id}/following"
197
- url = API_BASE_URL + path
198
-
199
- delete(url)
200
- end
201
-
202
- # ユーザをフォローしている場合に204を返す
203
- def check_following(user_id:)
204
- path = "/api/v2/users/#{user_id}/following"
205
- url = API_BASE_URL + path
206
-
207
- get(url)
208
- end
209
-
210
- # ユーザをフォロー
211
- def follow_user(user_id:)
212
- path = "/api/v2/users/#{user_id}/following"
213
- url = API_BASE_URL + path
214
-
215
- put(url)
216
- end
217
-
218
- # 認証中のユーザの記事の一覧を作成日時の降順で返す
219
- def fetch_my_items
220
- path = "/api/v2/authenticated_user/items"
221
- url = API_BASE_URL + path
222
-
223
- get(url)
224
- end
225
-
226
- # 記事の一覧を作成日時の降順で返す
227
- def fetch_items
228
- path = '/api/v2/items'
229
- url = API_BASE_URL + path
230
-
231
- get(url)
232
- end
233
-
234
- # 新たに記事を作成
235
- def post_item(params:)
236
- path = "/api/v2/items"
237
- url = API_BASE_URL + path
238
-
239
- post(url, params)
240
- end
241
-
242
- # 記事を削除
243
- def delete_item(item_id:)
244
- path = "/api/v2/items/#{item_id}"
245
- url = API_BASE_URL + path
246
-
247
- delete(url)
248
- end
249
-
250
- # 記事を取得
251
- def fetch_item(item_id:)
252
- path = "/api/v2/items/#{item_id}"
253
- url = API_BASE_URL + path
254
-
255
- get(url)
256
- end
257
-
258
- # 記事を更新
259
- def update_item(item_id:, params:)
260
- path = "/api/v2/items/#{item_id}"
261
- url = API_BASE_URL + path
262
-
263
- patch(url, params)
264
- end
265
-
266
- # 記事をストック
267
- def stock_item(item_id:)
268
- path = "/api/v2/items/#{item_id}"
269
- url = API_BASE_URL + path
270
-
271
- put(url)
272
- end
273
-
274
- # 記事をストックから取り除く
275
- def delete_stock(item_id:)
276
- path = "/api/v2/items/#{item_id}"
277
- url = API_BASE_URL + path
278
-
279
- delete(url)
280
- end
281
-
282
- # 記事をストックしているかどうか調べる
283
- def check_item_stock(item_id:)
284
- path = "/api/v2/items/#{item_id}/stock"
285
- url = API_BASE_URL + path
286
-
287
- get(url)
288
- end
289
-
290
- # タグの記事一覧
291
- def fetch_tag_items(tag_id:)
292
- path = "/api/v2/tags/#{tag_id}/items"
293
- url = API_BASE_URL + path
294
-
295
- get(url)
296
- end
297
-
298
- # 指定されたユーザの記事一覧
299
- def fetch_user_items(user_id:)
300
- path = "/api/v2/tags/#{user_id}/items"
301
- url = API_BASE_URL + path
302
-
303
- get(url)
304
- end
305
-
306
- # 指定されたユーザがストックした記事一覧
307
- def fetch_user_stocks(user_id:)
308
- path = "/api/v2/users/#{user_id}/stocks"
309
- url = API_BASE_URL + path
310
-
311
- get(url)
312
- end
313
-
314
- # コメントに絵文字リアクションを付ける
315
- def attach_reaction_to_comment(comment_id:, params)
316
- path = "/api/v2/comments/#{comment_id}/reactions"
317
- url = API_BASE_URL + path
318
-
319
- post(url, params)
320
- end
321
-
322
- # 記事に絵文字リアクションを付ける
323
- def attach_reaction_to_item(item_id: params)
324
- path = "/api/v2/items/#{item_id}/reactions"
325
- url = API_BASE_URL + path
326
-
327
- post(url, params)
328
- end
329
-
330
- # コメントから絵文字リアクションを削除
331
- def delete_comment_reaction(comment_id:, reaction_name:)
332
- path = "/api/v2/comments/#{comment_id}/reactions/#{reaction_name}"
333
- url = API_BASE_URL + path
334
-
335
- delete(url)
336
- end
337
-
338
- # 記事から絵文字リアクションを削除
339
- def delete_item_reaction(item_id:, reaction_name:)
340
- path = "/api/v2/items/#{item_id}/reactions/#{reaction_name}"
341
- url = API_BASE_URL + path
342
-
343
- delete(url)
344
- end
345
-
346
- # コメントに付けられた絵文字リアクション一覧
347
- def fetch_comment_reactions(comment_id:)
348
- path = "/api/v2/comments/#{comment_id}/reactions"
349
- url = API_BASE_URL + path
350
-
351
- get(url)
352
- end
353
-
354
- # 記事に付けられた絵文字リアクション一覧
355
- def fetch_item_reactions(item_id:)
356
- path = "/api/v2/items/#{item_id}/reactions"
357
- url = API_BASE_URL + path
358
-
359
- get(url)
360
- end
361
-
362
- # アクセストークンに紐付いたユーザを返す
363
- def fetch_authenticated_user
364
- path = "/api/v2/authenticated_user"
365
- url = API_BASE_URL + path
366
-
367
- get(url)
65
+ def endpoint
66
+ @endpoint ||= API_BASE_URL
368
67
  end
369
68
  end
370
69
  end
@@ -41,4 +41,3 @@ module Qiita
41
41
  end
42
42
  end
43
43
  end
44
-
@@ -1,5 +1,5 @@
1
1
  module Qiita
2
2
  module Sdk
3
- VERSION = "0.1.0"
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -1,28 +1,27 @@
1
1
  require_relative 'lib/qiita/sdk/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = "qiita-sdk"
4
+ spec.name = 'qiita-sdk'
5
5
  spec.version = Qiita::Sdk::VERSION
6
- spec.authors = ["yonetani"]
7
- spec.email = ["sbkn0919@gmail.com"]
6
+ spec.authors = ['yonetani']
7
+ spec.email = ['sbkn0919@gmail.com']
8
8
 
9
- spec.summary = %q{qiita sdk}
10
- spec.description = %q{qiita sdk}
11
- spec.homepage = "http://example.com/"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
9
+ spec.summary = 'qiita sdk'
10
+ spec.description = 'qiita sdk'
11
+ spec.homepage = 'http://example.com/'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
14
 
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = "http://example.com/"
18
- spec.metadata["changelog_uri"] = "http://example.com/"
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'http://example.com/'
17
+ spec.metadata['changelog_uri'] = 'http://example.com/'
19
18
 
20
19
  # Specify which files should be added to the gem when it is released.
21
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
23
  end
25
- spec.bindir = "exe"
24
+ spec.bindir = 'exe'
26
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
26
+ spec.require_paths = ['lib']
28
27
  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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yonetani
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-26 00:00:00.000000000 Z
11
+ date: 2020-08-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: qiita sdk
14
14
  email:
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".gitignore"
21
21
  - ".rspec"
22
+ - ".rubocop.yml"
22
23
  - ".travis.yml"
23
24
  - CODE_OF_CONDUCT.md
24
25
  - Gemfile
@@ -29,6 +30,7 @@ files:
29
30
  - bin/console
30
31
  - bin/setup
31
32
  - lib/qiita/sdk.rb
33
+ - lib/qiita/sdk/api_actions.rb
32
34
  - lib/qiita/sdk/client.rb
33
35
  - lib/qiita/sdk/httpclient.rb
34
36
  - lib/qiita/sdk/version.rb